PluginProbe
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) / 1.8.13
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) v1.8.13
1.8.13 1.8.12.3 1.8.12.2 1.8.12.1 1.8.12 1.8.11.3 1.8.11.2 1.8.11.1 1.8.11 1.6.6 1.6.60 1.6.7 1.6.8 1.6.9 1.7.0 1.7.0.1 1.7.0.11 1.7.0.12 1.7.0.14 1.7.0.2 1.7.0.3 1.7.0.5 1.7.0.6 1.7.0.7 1.7.0.9 All 211 releases
charitable / includes / endpoints / class-charitable-profile-endpoint.php

class-charitable-profile-endpoint.php in Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) 1.8.13, at includes/endpoints/class-charitable-profile-endpoint.php

136 lines 2.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Profile endpoint.
4 *
5 * @package Charitable/Classes/Charitable_Profile_Endpoint
6 * @author David Bisset
7 * @copyright Copyright (c) 2023, WP Charitable LLC
8 * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
9 * @since 1.5.0
10 * @version 1.6.29
11 */
12
13 if ( ! defined( 'ABSPATH' ) ) {
14 exit;
15 }
16
17 if ( ! class_exists( 'Charitable_Profile_Endpoint' ) ) :
18
19 /**
20 * Charitable_Profile_Endpoint
21 *
22 * @since 1.5.0
23 */
24 class Charitable_Profile_Endpoint extends Charitable_Endpoint {
25
26 /** Endpoint ID. */
27 const ID = 'profile';
28
29 /**
30 * Object instantiation.
31 *
32 * @since 1.5.4
33 */
34 public function __construct() {
35 $this->cacheable = false;
36 }
37
38 /**
39 * Return the endpoint ID.
40 *
41 * @since 1.5.0
42 *
43 * @return string
44 */
45 public static function get_endpoint_id() {
46 return self::ID;
47 }
48
49 /**
50 * Return the endpoint URL.
51 *
52 * @since 1.5.0
53 *
54 * @global WP_Rewrite $wp_rewrite
55 * @param array $args Mixed args.
56 * @return string
57 */
58 public function get_page_url( $args = array() ) {
59 $page = charitable_get_option( 'profile_page', false );
60
61 return $page ? get_permalink( $page ) : '';
62 }
63
64 /**
65 * Return whether we are currently viewing the endpoint.
66 *
67 * @since 1.5.0
68 *
69 * @global WP_Post $post
70 * @global WP_Query $wp_query
71 * @param array $args Mixed args.
72 * @return boolean
73 */
74 public function is_page( $args = array() ) {
75 global $post, $wp_query;
76
77 if ( is_null( $post ) || ! $wp_query->is_main_query() ) {
78 return false;
79 }
80
81 $page = charitable_get_option( 'profile_page', false );
82
83 if ( ! $page || $page != $post->ID ) {
84 return false;
85 }
86
87 return ! $this->is_descendent_page();
88 }
89
90 /**
91 * Check that this is not a descendant page.
92 *
93 * For example, the email verification endpoint uses /profile/ as
94 * its base, so we need to make sure that `email_verification` is
95 * not set in the query vars.
96 *
97 * @since 1.6.23
98 *
99 * @global WP_Query $wp_query
100 * @return boolean
101 */
102 public function is_descendent_page() {
103 global $wp_query;
104
105 /**
106 * Filter the query vars that indicate a descendent page.
107 *
108 * @since 1.6.23
109 *
110 * @param array List of query vars.
111 */
112 $descendent_query_vars = apply_filters(
113 'charitable_profile_endpoint_descendent_query_vars',
114 array( 'email_verification' )
115 );
116
117 /* If the query vars keys contains one of the descendent query vars, return true. */
118 $found_vars = array_intersect( array_keys( $wp_query->query_vars ), $descendent_query_vars );
119
120 return ! empty( $found_vars );
121 }
122
123 /**
124 * Get the nav menu object.
125 *
126 * @since 1.6.29
127 *
128 * @return object
129 */
130 public function nav_menu_object() {
131 return charitable_get_option( 'profile_page', false ) ? $this->get_nav_menu_object( __( 'Profile', 'charitable' ) ) : null;
132 }
133 }
134
135 endif;
136