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 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 All 212 releases
← All changes | includes/endpoints/class-charitable-profile-endpoint.php +61 -10 1.6.6 → 1.8.13 View file →
@@ -2,16 +2,18 @@
2 2 /**
3 3 * Profile endpoint.
4 4 *
5 5 * @package Charitable/Classes/Charitable_Profile_Endpoint
6 - * @author Eric Daams
7 - * @copyright Copyright (c) 2018, Studio 164a
6 + * @author David Bisset
7 + * @copyright Copyright (c) 2023, WP Charitable LLC
8 8 * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
9 9 * @since 1.5.0
10 - * @version 1.5.4
10 + * @version 1.6.29
11 11 */
12 12
13 -if ( ! defined( 'ABSPATH' ) ) { exit; } // Exit if accessed directly
13 +if ( ! defined( 'ABSPATH' ) ) {
14 + exit;
15 +}
14 16
15 17 if ( ! class_exists( 'Charitable_Profile_Endpoint' ) ) :
16 18
17 19 /**
@@ -16,13 +18,13 @@
16 18
17 19 /**
18 20 * Charitable_Profile_Endpoint
19 21 *
20 - * @since 1.5.0
22 + * @since 1.5.0
21 23 */
22 24 class Charitable_Profile_Endpoint extends Charitable_Endpoint {
23 25
24 - /* @var string */
26 + /** Endpoint ID. */
25 27 const ID = 'profile';
26 28
27 29 /**
28 30 * Object instantiation.
@@ -63,22 +65,71 @@
63 65 * Return whether we are currently viewing the endpoint.
64 66 *
65 67 * @since 1.5.0
66 68 *
67 - * @global WP_Post $post
69 + * @global WP_Post $post
70 + * @global WP_Query $wp_query
68 71 * @param array $args Mixed args.
69 72 * @return boolean
70 73 */
71 74 public function is_page( $args = array() ) {
72 - global $post;
75 + global $post, $wp_query;
73 76
74 - if ( is_null( $post ) ) {
77 + if ( is_null( $post ) || ! $wp_query->is_main_query() ) {
75 78 return false;
76 79 }
77 80
78 81 $page = charitable_get_option( 'profile_page', false );
79 82
80 - return false != $page && $page == $post->ID;
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;
81 132 }
82 133 }
83 134
84 135 endif;