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/admin/settings/class-charitable-settings.php +667 -94 1.7.0.7 → 1.8.13 View file →
@@ -3,9 +3,9 @@
3 3 * Charitable Settings UI.
4 4 *
5 5 * @package Charitable/Classes/Charitable_Settings
6 6 * @author David Bisset
7 - * @copyright Copyright (c) 2022, WP Charitable LLC
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.0.0
10 10 * @version 1.0.0
11 11 */
@@ -57,9 +57,9 @@
57 57 */
58 58 private function __construct() {
59 59 do_action( 'charitable_admin_settings_start', $this );
60 60
61 - add_action( 'charitable_after_admin_settings', [ $this, 'settings_cta' ] );
61 + add_action( 'charitable_after_admin_settings', array( $this, 'settings_cta' ) );
62 62 }
63 63
64 64 /**
65 65 * Returns and/or create the single instance of this class.
@@ -86,36 +86,121 @@
86 86 public function get_sections() {
87 87 /**
88 88 * Filter the settings tabs.
89 89 *
90 - * @since 1.0.0
90 + * @since 1.0.0
91 + * @version 1.8.1.6 removed 'tools' tab
92 + * @version 1.8.5.1 added marketing and security tabs depending on addon status.
91 93 *
92 94 * @param string[] $tabs List of tabs in key=>label format.
93 95 */
96 + $tabs = array(
97 + 'general' => __( 'General', 'charitable' ),
98 + 'gateways' => __( 'Payment Gateways', 'charitable' ),
99 + 'emails' => __( 'Emails', 'charitable' ),
100 + 'donors' => __( 'Donors', 'charitable' ),
101 + 'privacy' => __( 'Privacy', 'charitable' ),
102 + 'advanced' => __( 'Advanced', 'charitable' ),
103 + );
104 +
105 + // Always show marketing tab. Sub-tabs (Newsletters, Conversion Tracking, Google Analytics)
106 + // handle the per-feature display: Newsletter Connect addon (which works with Lite) renders
107 + // its real UI under the Newsletters sub-tab when active; Conversion Tracking and Google
108 + // Analytics always render Pro CTAs in Lite.
109 + $tabs = charitable_add_settings_tab(
110 + $tabs,
111 + 'marketing',
112 + __( 'Marketing', 'charitable' ),
113 + array(
114 + 'index' => 5,
115 + )
116 + );
117 +
118 + // Always show security tab.
119 + // When spam blocker is active, it will handle the settings.
120 + // When spam blocker is inactive, core security features will handle the settings.
121 + $tabs = charitable_add_settings_tab(
122 + $tabs,
123 + 'security',
124 + __( 'Security', 'charitable' ),
125 + array(
126 + 'index' => 6,
127 + )
128 + );
129 +
130 + // Ensure the advanced tab is always last by moving it to the end of the array.
131 + if ( isset( $tabs['advanced'] ) ) {
132 + $advanced_tab = $tabs['advanced'];
133 + unset( $tabs['advanced'] );
134 + $tabs['advanced'] = $advanced_tab;
135 + }
136 +
137 + return apply_filters( 'charitable_settings_tabs', $tabs );
138 + }
139 +
140 + /**
141 + * Return the array of sub tabs used on the Marketing settings page.
142 + *
143 + * Each label carries an inline "Pro" badge:
144 + * - Newsletters: the Newsletter Connect addon works on Lite, but the badge
145 + * still appears since the bulk of newsletter functionality is Pro-tier.
146 + * - Conversion Tracking / Google Analytics: Pro-only — badge always shown.
147 + *
148 + * @since 1.8.11.3
149 + *
150 + * @return string[] key => label.
151 + */
152 + public function get_sub_sections_marketing() {
153 + $pro_badge = ' <span class="charitable-pro-badge">' . esc_html__( 'PRO', 'charitable' ) . '</span>';
154 +
94 155 return apply_filters(
95 - 'charitable_settings_tabs',
156 + 'charitable_settings_sub_tabs_marketing',
96 157 array(
97 - 'general' => __( 'General', 'charitable' ),
98 - 'gateways' => __( 'Payment Gateways', 'charitable' ),
99 - 'emails' => __( 'Emails', 'charitable' ),
100 - 'privacy' => __( 'Privacy', 'charitable' ),
101 - 'tools' => __( 'Tools', 'charitable' ),
102 - 'advanced' => __( 'Advanced', 'charitable' ),
158 + 'marketing__newsletters' => __( 'Newsletters', 'charitable' ) . $pro_badge,
159 + 'marketing__conversion_tracking' => __( 'Conversion Tracking', 'charitable' ) . $pro_badge,
160 + 'marketing__google_analytics' => __( 'Google Analytics', 'charitable' ) . $pro_badge,
103 161 )
104 162 );
163 + }
105 164
165 + /**
166 + * Redirect to the default Marketing sub-tab when no sub_tab is supplied.
167 + *
168 + * @since 1.8.11.3
169 + *
170 + * @return void
171 + */
172 + public function marketing_sub_tab_default() {
173 + // Don't redirect during form submissions.
174 + if ( ! empty( $_POST ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
175 + return;
176 + }
177 +
178 + if ( ! charitable_is_settings_view( 'marketing' ) ) {
179 + return;
180 + }
181 +
182 + if ( isset( $_GET['sub_tab'] ) || isset( $_GET['group'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
183 + return;
184 + }
185 +
186 + wp_safe_redirect(
187 + admin_url( 'admin.php?page=charitable-settings&tab=marketing&sub_tab=newsletters' )
188 + );
189 + exit;
106 190 }
107 191
108 192 /**
109 193 * Optionally add the extensions tab.
110 194 *
111 - * @since 1.3.0
195 + * @since 1.3.0
196 + * @version 1.8.5.1 Adjust index so it comes before the advanced tab.
112 197 *
113 198 * @param string[] $tabs The existing set of tabs.
114 199 * @return string[]
115 200 */
116 201 public function maybe_add_extensions_tab( $tabs ) {
117 - $actual_tab = isset( $_GET['tab'] ) ? $_GET['tab'] : 'general';
202 + $actual_tab = isset( $_GET['tab'] ) ? esc_attr( $_GET['tab'] ) : 'general'; // phpcs:ignore
118 203
119 204 /* Set the tab to 'extensions' */
120 205 $_GET['tab'] = 'extensions';
121 206
@@ -136,13 +221,20 @@
136 221 $tabs,
137 222 'extensions',
138 223 __( 'Extensions', 'charitable' ),
139 224 array(
140 - 'index' => 4,
225 + 'index' => 7,
141 226 )
142 227 );
143 228 }
144 229
230 + // Ensure the advanced tab is always last by moving it to the end of the array.
231 + if ( isset( $tabs['advanced'] ) ) {
232 + $advanced_tab = $tabs['advanced'];
233 + unset( $tabs['advanced'] );
234 + $tabs['advanced'] = $advanced_tab;
235 + }
236 +
145 237 return $tabs;
146 238 }
147 239
148 240 /**
@@ -182,10 +274,32 @@
182 274 }
183 275
184 276 register_setting( 'charitable_settings', 'charitable_settings', array( $this, 'sanitize_settings' ) );
185 277
278 + // Bridge the Newsletter Connect addon (which gates its filter on
279 + // charitable_is_settings_view('extensions')) so its fields contribute
280 + // when the user is on Marketing → Newsletters. We spoof $_GET['tab']
281 + // for the duration of get_fields() so the addon's gate passes; the
282 + // extensions section is what the view's form group already targets
283 + // on the Newsletters sub-tab. The Extensions top-level tab continues
284 + // to work as before — this only adds an additional render path.
285 + $charitable_bridge_newsletters = (
286 + isset( $_GET['tab'] ) && 'marketing' === $_GET['tab'] // phpcs:ignore WordPress.Security.NonceVerification.Recommended
287 + && isset( $_GET['sub_tab'] ) && 'newsletters' === $_GET['sub_tab'] // phpcs:ignore WordPress.Security.NonceVerification.Recommended
288 + && class_exists( 'Charitable_Newsletter_Connect' )
289 + );
290 +
291 + if ( $charitable_bridge_newsletters ) {
292 + $charitable_real_tab = $_GET['tab']; // phpcs:ignore WordPress.Security.NonceVerification.Recommended
293 + $_GET['tab'] = 'extensions'; // phpcs:ignore WordPress.Security.NonceVerification.Recommended
294 + }
295 +
186 296 $fields = $this->get_fields();
187 297
298 + if ( $charitable_bridge_newsletters ) {
299 + $_GET['tab'] = $charitable_real_tab; // phpcs:ignore WordPress.Security.NonceVerification.Recommended
300 + }
301 +
188 302 if ( empty( $fields ) ) {
189 303 return;
190 304 }
191 305
@@ -245,27 +359,60 @@
245 359 }
246 360
247 361 $settings_keys = array_keys( $new_values );
248 362
249 - if ( defined( 'CHARITABLE_DEBUG' ) && CHARITABLE_DEBUG ) {
250 - error_log( 'santiize_settings' );
251 - error_log( 'values:' );
252 - error_log( print_r( $values, true ) );
253 - error_log( 'old_values:' );
254 - error_log( print_r( $old_values, true ) );
255 - error_log( 'new_values:' );
256 - error_log( print_r( $new_values, true ) );
363 + if ( charitable_is_debug() ) {
364 + error_log( 'santiize_settings' ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
365 + error_log( 'values:' ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
366 + error_log( print_r( $values, true ) ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log,WordPress.PHP.DevelopmentFunctions.error_log_print_r
367 + error_log( 'old_values:' ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
368 + error_log( print_r( $old_values, true ) ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log,WordPress.PHP.DevelopmentFunctions.error_log_print_r
369 + error_log( 'new_values:' ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
370 + error_log( print_r( $new_values, true ) ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log,WordPress.PHP.DevelopmentFunctions.error_log_print_r
257 371 }
258 372
259 - // determine if Charitable gateway "test mode" is being changed, and if so add a notice to the user.
260 - if ( array_key_exists('test_mode', $new_values ) && array_key_exists('test_mode', $old_values ) && $old_values['test_mode'] !== $new_values['test_mode'] ) {
373 + // determine if Charitable gateway "test_mode" is being changed, and if so add a notice to the user.
374 + if ( array_key_exists( 'test_mode', $new_values ) && array_key_exists( 'test_mode', $old_values ) && $old_values['test_mode'] !== $new_values['test_mode'] ) {
261 375 $old_settings_keys = array_keys( $old_values );
262 376 $dismissible = true;
377 +
378 + // Check if Square has connection issues for the new mode
379 + $square_has_issues = $this->check_square_connection_for_mode_change( $new_values['test_mode'] );
380 +
381 + // Determine notice type and message
382 + $notice_type = $square_has_issues ? 'error' : 'warning';
383 + $gateway_list = array();
384 +
263 385 if ( in_array( 'gateways_stripe', $old_settings_keys ) ) {
264 - charitable_get_admin_notices()->add_notice( 'Some active payment gateways <strong>(including Stripe)</strong> might have reset their connections due to an update in the test mode. Please check your active payment gateways in ensure they are still connected.', 'warning', false, $dismissible );
386 + $gateway_list[] = 'Stripe';
387 + }
388 +
389 + if ( $square_has_issues ) {
390 + $gateway_list[] = 'Square';
391 + }
392 +
393 + if ( ! empty( $gateway_list ) ) {
394 + $gateway_text = implode( ' and ', $gateway_list );
395 + $message = sprintf(
396 + /* translators: %s: comma-separated list of gateway names */
397 + __( 'Some active payment gateways <strong>(including %s)</strong> might have reset their connections due to an update in the test mode. Please check your active payment gateways to ensure they are still connected.', 'charitable' ),
398 + $gateway_text
399 + );
265 400 } else {
266 - charitable_get_admin_notices()->add_notice( 'Some active payment gateways might have reset their connections due to an update in the test mode. Please check your active payment gateways in ensure they are still connected.', 'warning', false, $dismissible );
401 + $message = __( 'Some active payment gateways might have reset their connections due to an update in the test mode. Please check your active payment gateways to ensure they are still connected.', 'charitable' );
267 402 }
403 +
404 + // Add additional Square-specific message if Square has connection issues
405 + if ( $square_has_issues ) {
406 + $mode_label = $new_values['test_mode'] ? __( 'test', 'charitable' ) : __( 'live', 'charitable' );
407 + $message .= '<br><br><strong>' . sprintf(
408 + /* translators: %s: mode (test or live) */
409 + __( 'Square payment gateway is enabled but not connected in %s mode. Please connect your Square account to continue processing payments.', 'charitable' ),
410 + $mode_label
411 + ) . '</strong>';
412 + }
413 +
414 + charitable_get_admin_notices()->add_notice( $message, $notice_type, false, $dismissible );
268 415 }
269 416
270 417 if ( in_array( 'gateways_stripe', $settings_keys ) && charitable()->is_stripe_connect_addon() && false === charitable_using_stripe_connect() ) {
271 418 // non-existant array keys in the array for API keys might be a result of the "manual update key" feature which is based on ajax and might not load keys into form if the user doesn't click on the link in the settings to view/edit them.
@@ -280,18 +427,18 @@
280 427 }
281 428 if ( ! array_key_exists( 'test_public_key', $values['gateways_stripe'] ) && isset( $old_values['gateways_stripe']['test_public_key'] ) && ( false !== $old_values['gateways_stripe']['test_public_key'] ) ) {
282 429 $values['gateways_stripe']['test_public_key'] = $old_values['gateways_stripe']['test_public_key'];
283 430 }
284 - if ( defined( 'CHARITABLE_DEBUG' ) && CHARITABLE_DEBUG ) {
285 - error_log( 'update:' );
286 - error_log( print_r( $values, true ) );
431 + if ( charitable_is_debug() ) {
432 + error_log( 'update:' ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
433 + error_log( print_r( $values, true ) ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log,WordPress.PHP.DevelopmentFunctions.error_log_print_r
287 434 }
288 435 }
289 436
290 - // determine if stripe is being returned as new values - if so, then perform the API key save workaround
437 + // determine if stripe is being returned as new values - if so, then perform the API key save workaround.
291 438 if ( in_array( 'gateways_stripe', $settings_keys ) && charitable()->is_stripe_connect_addon() && false === charitable_using_stripe_connect() ) {
292 - if ( defined( 'CHARITABLE_DEBUG' ) && CHARITABLE_DEBUG ) {
293 - error_log( 'there is a stripe connect addon but we are not using stripe connect' );
439 + if ( charitable_is_debug() ) {
440 + error_log( 'there is a stripe connect addon but we are not using stripe connect' ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
294 441 }
295 442 // the stripe connect addon is installed AND the AM Stripe Connect isn't being used... so it's possible the keys could be manual and the user could be updating them... therefore let's just make sure the new values match the values incoming.
296 443 $new_values['gateways_stripe']['live_secret_key'] = ( isset( $values['gateways_stripe']['live_secret_key'] ) && ( false !== $values['gateways_stripe']['live_secret_key'] ) ) ? $values['gateways_stripe']['live_secret_key'] : null;
297 444 $new_values['gateways_stripe']['live_public_key'] = ( isset( $values['gateways_stripe']['live_public_key'] ) && ( false !== $values['gateways_stripe']['live_public_key'] ) ) ? $values['gateways_stripe']['live_public_key'] : null;
@@ -296,12 +443,12 @@
296 443 $new_values['gateways_stripe']['live_secret_key'] = ( isset( $values['gateways_stripe']['live_secret_key'] ) && ( false !== $values['gateways_stripe']['live_secret_key'] ) ) ? $values['gateways_stripe']['live_secret_key'] : null;
297 444 $new_values['gateways_stripe']['live_public_key'] = ( isset( $values['gateways_stripe']['live_public_key'] ) && ( false !== $values['gateways_stripe']['live_public_key'] ) ) ? $values['gateways_stripe']['live_public_key'] : null;
298 445 $new_values['gateways_stripe']['test_secret_key'] = ( isset( $values['gateways_stripe']['test_secret_key'] ) && ( false !== $values['gateways_stripe']['test_secret_key'] ) ) ? $values['gateways_stripe']['test_secret_key'] : null;
299 446 $new_values['gateways_stripe']['test_public_key'] = ( isset( $values['gateways_stripe']['test_public_key'] ) && ( false !== $values['gateways_stripe']['test_public_key'] ) ) ? $values['gateways_stripe']['test_public_key'] : null;
300 - } else if ( in_array( 'gateways_stripe', $settings_keys ) ) {
301 - // otherwise we preserve the keys
302 - if ( defined( 'CHARITABLE_DEBUG' ) && CHARITABLE_DEBUG ) {
303 - error_log( 'charitable debug, final with debug on:' );
447 + } elseif ( in_array( 'gateways_stripe', $settings_keys ) ) {
448 + // otherwise we preserve the keys.
449 + if ( charitable_is_debug() ) {
450 + error_log( 'charitable debug, final with debug on:' ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
304 451 $new_values['gateways_stripe']['live_secret_key'] = ( isset( $values['gateways_stripe']['live_secret_key'] ) && ( false !== $values['gateways_stripe']['live_secret_key'] ) ) ? $values['gateways_stripe']['live_secret_key'] : null;
305 452 $new_values['gateways_stripe']['live_public_key'] = ( isset( $values['gateways_stripe']['live_public_key'] ) && ( false !== $values['gateways_stripe']['live_public_key'] ) ) ? $values['gateways_stripe']['live_public_key'] : null;
306 453 $new_values['gateways_stripe']['test_secret_key'] = ( isset( $values['gateways_stripe']['test_secret_key'] ) && ( false !== $values['gateways_stripe']['test_secret_key'] ) ) ? $values['gateways_stripe']['test_secret_key'] : null;
307 454 $new_values['gateways_stripe']['test_public_key'] = ( isset( $values['gateways_stripe']['test_public_key'] ) && ( false !== $values['gateways_stripe']['test_public_key'] ) ) ? $values['gateways_stripe']['test_public_key'] : null;
@@ -314,12 +461,12 @@
314 461 }
315 462
316 463 // preserve any webhook keys, regardless if stripe connect addon is active or not.
317 464 if ( in_array( 'gateways_stripe', $settings_keys ) ) {
318 - if ( array_key_exists( 'test_webhook_id', $old_values['gateways_stripe'] ) && isset( $old_values['gateways_stripe']['test_webhook_id'] ) ) {
465 + if ( ! empty( $old_values['gateways_stripe'] ) && array_key_exists( 'test_webhook_id', $old_values['gateways_stripe'] ) && isset( $old_values['gateways_stripe']['test_webhook_id'] ) ) {
319 466 $new_values['gateways_stripe']['test_webhook_id'] = $old_values['gateways_stripe']['test_webhook_id'];
320 467 }
321 - if ( array_key_exists( 'live_webhook_id', $old_values['gateways_stripe'] ) && isset( $old_values['gateways_stripe']['live_webhook_id'] ) ) {
468 + if ( ! empty( $old_values['gateways_stripe'] ) && array_key_exists( 'live_webhook_id', $old_values['gateways_stripe'] ) && isset( $old_values['gateways_stripe']['live_webhook_id'] ) ) {
322 469 $new_values['gateways_stripe']['live_webhook_id'] = $old_values['gateways_stripe']['live_webhook_id'];
323 470 }
324 471 }
325 472
@@ -324,15 +471,15 @@
324 471 }
325 472
326 473 // account for incoming legacy licenses (1.7.0.4+)
327 474 // all we are doing is adding the licenses into the values so that the save_license hook can retreieve them and validate, etc.
328 - if ( ! empty( $values['legacy_licenses'] ) && isset( $values['advanced']['section'] ) && 'licenses' === $values['advanced']['section'] ) {
475 + if ( ! empty( $values['legacy_licenses'] ) && isset( $values['advanced']['section_hidden_licenses'] ) && 'licenses' === $values['advanced']['section_hidden_licenses'] ) {
329 476 if ( ! isset( $new_values['licenses']['legacy'] ) ) {
330 477 $new_values['licenses_legacy'] = (array) $values['legacy_licenses'];
331 478 }
332 479 }
333 480
334 - // ensure any hex color text files are valid hex fields
481 + // ensure any hex color text files are valid hex fields.
335 482 if ( isset( $new_values['donation_form_default_highlight_colour'] ) ) {
336 483 $color_to_test = esc_html( $new_values['donation_form_default_highlight_colour'] );
337 484 $color_valid = false;
338 485 // check for a hex color string
@@ -339,9 +486,9 @@
339 486 if ( preg_match( '/^#[a-f0-9]{6}$/i', $color_to_test ) ) {
340 487 // hex color is valid
341 488 $color_valid = true;
342 489 }
343 - // Check for a hex color string without hash
490 + // Check for a hex color string without hash.
344 491 if ( preg_match( '/^[a-f0-9]{6}$/i', $color_to_test ) ) {
345 492 // hex color is valid
346 493 $color_valid = true;
347 494 $new_values['donation_form_default_highlight_colour'] = '#' . $color_to_test;
@@ -349,17 +496,26 @@
349 496 if ( false === $color_valid ) {
350 497 // not valid, make sure it is blank.
351 498 $new_values['donation_form_default_highlight_colour'] = false;
352 499 }
353 - // clear the transient that stores the color styles
500 + // clear the transient that stores the color styles.
354 501 delete_transient( 'charitable_custom_styles' );
355 502 }
356 503
357 504 $values = wp_parse_args( $new_values, $old_values );
358 505
506 + // Sanitize decimal_count to prevent XSS attacks.
507 + if ( isset( $values['decimal_count'] ) ) {
508 + $values['decimal_count'] = absint( $values['decimal_count'] );
509 + // Ensure decimal_count is between 0 and 10.
510 + $values['decimal_count'] = min( max( $values['decimal_count'], 0 ), 10 );
511 + }
512 +
359 513 if ( defined( 'CHARITABLE_DEBUG' ) && CHARITABLE_DEBUG ) {
360 - error_log( 'santiize_settings values updated' );
361 - error_log( print_r( $values, true ) );
514 + if ( charitable_is_debug() ) {
515 + error_log( 'santiize_settings values updated' ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
516 + error_log( print_r( $values, true ) ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log,WordPress.PHP.DevelopmentFunctions.error_log_print_r
517 + }
362 518 }
363 519
364 520 /**
365 521 * Filter sanitized settings.
@@ -372,8 +528,21 @@
372 528 */
373 529
374 530 $values = apply_filters( 'charitable_save_settings', $values, $new_values, $old_values );
375 531
532 + // save a temp transient for legacy licenses (1.7.0.8+)
533 + // purpose is to provide better error reporting (transient should be deleted after settings page (advanced tab) is loaded).
534 + // phpcs:disable WordPress.Security.NonceVerification.Missing
535 + if ( isset( $_POST['charitable_settings']['legacy_licenses'] ) ) {
536 + $referer = wp_get_referer();
537 + if ( false !== strpos( $referer, 'admin.php?page=charitable-settings&tab=advanced' ) ) {
538 + // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Array data, sanitized later
539 + $legacy_licenses = wp_unslash( $_POST['charitable_settings']['legacy_licenses'] );
540 + set_transient( '_charitable_legacy_license_info', $legacy_licenses, MINUTE_IN_SECONDS );
541 + }
542 + }
543 + // phpcs:enable WordPress.Security.NonceVerification.Missing
544 +
376 545 $this->add_update_message( __( 'Settings saved', 'charitable' ), 'success' );
377 546
378 547 return $values;
379 548 }
@@ -444,9 +613,10 @@
444 613
445 614 /**
446 615 * Recursively add settings fields, given an array.
447 616 *
448 - * @since 1.0.0
617 + * @since 1.0.0
618 + * @version 1.8.7
449 619 *
450 620 * @param array $field The setting field.
451 621 * @param array $keys Array containing the section key and field key.
452 622 * @return void
@@ -465,9 +635,10 @@
465 635 array_shift( $keys );
466 636 }
467 637
468 638 $field['key'] = $keys;
469 - $field['classes'] = $this->get_field_classes( $field );
639 + $field['classes'] = $this->get_field_classes( $field ); // deprecated?
640 + $field['class'] = $this->get_field_classes( $field );
470 641 $callback = isset( $field['callback'] ) ? $field['callback'] : array( $this, 'render_field' );
471 642 $label = $this->get_field_label( $field, end( $keys ) );
472 643
473 644 add_settings_field(
@@ -488,9 +659,9 @@
488 659 * @param array $field The field definition.
489 660 * @param string $key The field key.
490 661 * @return string
491 662 */
492 - private function get_field_label( $field, $key ) {
663 + private function get_field_label( $field, $key ) { // phpcs:ignore
493 664 $label = '';
494 665
495 666 if ( isset( $field['label_for'] ) ) {
496 667 $label = $field['label_for'];
@@ -591,9 +762,9 @@
591 762
592 763 switch ( $field_type ) {
593 764
594 765 case 'checkbox':
595 - $value = intval( array_key_exists( $key, $submitted ) && 'on' == $submitted[ $key ] );
766 + $value = intval( array_key_exists( $key, $submitted ) && ( 'on' === $submitted[ $key ] || 1 === (int) $submitted[ $key ] ) );
596 767 break;
597 768
598 769 case 'multi-checkbox':
599 770 $value = isset( $submitted[ $key ] ) ? $submitted[ $key ] : array();
@@ -730,14 +901,27 @@
730 901
731 902 /**
732 903 * Display upgrade notice at the bottom on the plugin settings pages.
733 904 *
734 - * @since 1.7.0.4
905 + * @since 1.7.0.4
906 + * @version 1.8.8
735 907 *
736 908 * @param string $view Current view inside the plugin settings page.
909 + * @param string $css_class CSS class for the cta.
910 + * @param bool $show_close_button Whether to show the close button.
737 911 */
738 - public function settings_cta( $view = false ) {
912 + public function settings_cta( $view = false, $css_class = 'reports-lite-cta', $show_close_button = false ) { // phpcs:ignore
739 913
914 + $no_show_cta = array(
915 + 'donors',
916 + 'security',
917 + 'marketing',
918 + );
919 +
920 + if ( in_array( $view, $no_show_cta ) ) {
921 + return;
922 + }
923 +
740 924 if ( charitable_is_pro() ) {
741 925 // no need to display this cta since they have a valid license.
742 926 return;
743 927 }
@@ -745,53 +929,14 @@
745 929 if ( get_option( 'charitable_lite_settings_upgrade', false ) || apply_filters( 'charitable_lite_settings_upgrade', false ) ) {
746 930 return;
747 931 }
748 932 ?>
749 - <div class="settings-lite-cta">
750 - <button type="button" class="button-link charitable-banner-dismiss dismiss">x</button>
751 - <h5><?php esc_html_e( 'Get Charitable Pro and Unlock all the Powerful Features', 'charitable-lite' ); ?></h5>
752 - <p><?php esc_html_e( 'Thanks for being a loyal Charitable Lite user. Upgrade to Charitable Pro to unlock all the awesome features and experience why Charitable is consistently rated a top WordPress donation and fundraising plugin.', 'charitable-lite' ); ?></p>
753 - <p>
754 - <?php
755 - printf( __( 'We know that you will truly love Charitable. Over 10,000+ non-profits who have chosen Charitable to get more donations from their website can\'t be wrong!', 'charitable-lite' ) );
756 - ?>
757 - </p>
758 - <h6><?php esc_html_e( 'Pro Features:', 'charitable-lite' ); ?></h6>
759 - <div class="list">
760 - <ul>
761 - <li><?php esc_html_e( 'Offer recurring donations to donors', 'charitable-lite' ); ?></li>
762 - <li><?php esc_html_e( 'Use fee relief to keep more donation dollars', 'charitable-lite' ); ?></li>
763 - <li><?php esc_html_e( 'Integrate with popular email marketing platforms', 'charitable-lite' ); ?></li>
764 - <li><?php esc_html_e( 'Expand your reach with peer-to-peer fundraising', 'charitable-lite' ); ?></li>
765 - <li><?php esc_html_e( 'Allow donors to crowdfund donations', 'charitable-lite' ); ?></li>
766 - </ul>
767 - <ul>
768 - <li><?php esc_html_e( 'Automate common tasks with Zapier and smart workflows', 'charitable-lite' ); ?></li>
769 - <li><?php esc_html_e( 'Run campaigns with ambassador and team support', 'charitable-lite' ); ?></li>
770 - <li><?php esc_html_e( 'Advanced donation management with annual receipts' ); ?></li>
771 - <li><?php esc_html_e( 'Allow donors to give donations anonymously', 'charitable-lite' ); ?></li>
772 - <li><?php esc_html_e( 'Add videos and updates to all campaigns', 'charitable-lite' ); ?></li>
773 - </ul>
933 + <?php if ( $show_close_button ) : ?>
934 + <div class="charitable-cta-dismiss-container">
935 + <button type="button" class="button-link charitable-banner-dismiss dismiss">x</button>
774 936 </div>
775 - <p>
776 - <a href="<?php echo esc_url( charitable_pro_upgrade_url( 'settings-upgrade' ) ); ?>" target="_blank" rel="noopener noreferrer">
777 - <?php esc_html_e( 'Get Charitable Pro Today and Unlock all the Powerful Features »', 'charitable-lite' ); ?>
778 - </a>
779 - </p>
780 - <p>
781 - <?php
782 - echo wp_kses(
783 - __( '<strong>Bonus:</strong> Charitable Lite users get up to <span class="green">$200 off regular price</span>, automatically applied at checkout.', 'charitable-lite' ),
784 - [
785 - 'strong' => [],
786 - 'span' => [
787 - 'class' => [],
788 - ],
789 - ]
790 - );
791 - ?>
792 - </p>
793 - </div>
937 + <?php endif; ?>
938 + <?php charitable_render_global_upgrade_cta( $css_class ); ?>
794 939 <script type="text/javascript">
795 940 jQuery( function ( $ ) {
796 941 $( document ).on( 'click', '.settings-lite-cta .dismiss', function ( event ) {
797 942 event.preventDefault();
@@ -796,9 +941,9 @@
796 941 $( document ).on( 'click', '.settings-lite-cta .dismiss', function ( event ) {
797 942 event.preventDefault();
798 943 $.post( ajaxurl, {
799 944 action: 'charitable_lite_settings_upgrade',
800 - chartiable_action: 'remove_lite_cta'
945 + charitable_action: 'remove_lite_cta'
801 946 } );
802 947 $( '.settings-lite-cta' ).remove();
803 948 } );
804 949 } );
@@ -806,11 +951,400 @@
806 951 <?php
807 952 }
808 953
809 954 /**
955 + * Show the settings CTA.
956 + *
957 + * @since 1.8.5.1
958 + * @version 1.8.9
959 + *
960 + * @return void
961 + */
962 + public function show_settings_cta() {
963 +
964 + $tab_values_to_check = array(
965 + 'marketing',
966 + 'donors',
967 + 'security',
968 + );
969 +
970 + $tab_value = isset( $_GET['tab'] ) ? esc_attr( $_GET['tab'] ) : ''; // phpcs:ignore
971 + $sub_tab_value = isset( $_GET['sub_tab'] ) ? esc_attr( $_GET['sub_tab'] ) : ''; // phpcs:ignore
972 +
973 + if ( in_array( $tab_value, $tab_values_to_check ) ) { // phpcs:ignore
974 + // UTM medium follows the sub_tab when present (e.g. marketing-conversion-tracking)
975 + // so each upgrade button is attributable.
976 + $upgrade_medium = ( 'marketing' === $tab_value && ! empty( $sub_tab_value ) )
977 + ? 'marketing-' . str_replace( '_', '-', $sub_tab_value )
978 + : $tab_value;
979 +
980 + ob_start();
981 + ?>
982 +
983 + <div class="charitable-education-page">
984 +
985 + <?php
986 + if ( 'marketing' === $tab_value ) {
987 + // Default to the Newsletters CTA when no sub_tab is supplied
988 + // (the marketing_sub_tab_default redirect should normally prevent this,
989 + // but render safely if a redirect was skipped — e.g. during POST).
990 + $marketing_sub_tab = '' !== $sub_tab_value ? $sub_tab_value : 'newsletters';
991 +
992 + if ( 'conversion_tracking' === $marketing_sub_tab ) {
993 + $this->get_settings_cta_education_content_conversion_tracking();
994 + } elseif ( 'google_analytics' === $marketing_sub_tab ) {
995 + $this->get_settings_cta_education_content_google_analytics();
996 + } else {
997 + $this->get_settings_cta_education_content_marketing_settings();
998 + }
999 + } elseif ( 'donors' === $tab_value ) {
1000 + $this->get_settings_cta_education_content_donor_settings();
1001 + } elseif ( 'security' === $tab_value && ! charitable_is_pro() ) {
1002 + $this->get_settings_cta_education_content_advanced_security_settings();
1003 + }
1004 + ?>
1005 + <?php if ( charitable_is_pro() ) : ?>
1006 + <div class="charitable-education-page-disabled-download">
1007 + <p>
1008 + <?php
1009 + printf(
1010 + /* translators: %s: Documentation URL */
1011 + esc_html__( 'Please add your license and upgrade to Charitable Pro for more advanced security features. Please %s on how to download Charitable Pro.', 'charitable' ),
1012 + '<a href="https://wpcharitable.com/docs/download-charitable-pro/" target="_blank">' . esc_html__( 'see our documentation', 'charitable' ) . '</a>'
1013 + );
1014 + ?>
1015 + </p>
1016 + </div>
1017 + <?php else : ?>
1018 + <div class="charitable-education-page-button">
1019 + <a href="<?php echo esc_url( charitable_utm_link( 'https://wpcharitable.com/lite-upgrade/', $upgrade_medium, __( 'Upgrade to Charitable Pro', 'charitable' ) ) ); ?>" class="button button-primary" target="_blank"><?php esc_html_e( 'Upgrade to Charitable Pro', 'charitable' ); ?></a>
1020 + </div>
1021 + <?php endif; ?>
1022 + </div>
1023 + <?php
1024 + echo ob_get_clean(); // phpcs:ignore
1025 + }
1026 + }
1027 +
1028 + /**
1029 + * Get the settings CTA education content for the donor referrals sub tab.
1030 + *
1031 + * @since 1.8.5.1
1032 + *
1033 + * @return void
1034 + */
1035 + public function get_settings_cta_education_content_donor_settings() {
1036 + ?>
1037 +
1038 + <div class="charitable-education-page-heading">
1039 + <h4><?php esc_html_e( 'New Donor Features', 'charitable' ); ?></h4>
1040 + <p><?php esc_html_e( 'Give donors the power to manage their contributions to your organization with a new donor dashboard. Encourage donors to spread the word about your organization by offering rewards for successful referrals. And give donors the ability to post comments to campaigns when they donate.', 'charitable' ); ?></p>
1041 + <p><?php esc_html_e( 'All of this is possible with the Charitable Pro plugin.', 'charitable' ); ?></p>
1042 + </div>
1043 +
1044 + <div class="charitable-education-page-media">
1045 + <div class="charitable-education-page-images">
1046 + <figure>
1047 + <div class="charitable-education-page-images-image">
1048 + <img src="<?php echo esc_url( charitable()->get_path( 'assets', false ) ); ?>images/education/donor-dashboard/education-1.png" alt="<?php esc_attr_e( 'Donor Dashboard', 'charitable' ); ?>">
1049 + <a href="<?php echo esc_url( charitable()->get_path( 'assets', false ) ); ?>images/education/donor-dashboard/education-1.png" class="hover" data-lity="" data-lity-desc="<?php esc_attr_e( 'Donor Dashboard', 'charitable' ); ?>"></a>
1050 + </div>
1051 + <figcaption><?php esc_html_e( 'Donor Dashboard', 'charitable' ); ?></figcaption>
1052 + </figure>
1053 + <figure>
1054 + <div class="charitable-education-page-images-image">
1055 + <img src="<?php echo esc_url( charitable()->get_path( 'assets', false ) ); ?>images/education/donor-referrals/education-2.png" alt="<?php esc_attr_e( 'Donor Referrals', 'charitable' ); ?>">
1056 + <a href="<?php echo esc_url( charitable()->get_path( 'assets', false ) ); ?>images/education/donor-referrals/education-2.png" class="hover" data-lity="" data-lity-desc="<?php esc_attr_e( 'Donor Referrals', 'charitable' ); ?>"></a>
1057 + </div>
1058 + <figcaption><?php esc_html_e( 'Donor Referrals', 'charitable' ); ?></figcaption>
1059 + </figure>
1060 + <figure>
1061 + <div class="charitable-education-page-images-image">
1062 + <img src="<?php echo esc_url( charitable()->get_path( 'assets', false ) ); ?>images/education/donor-comments/education-3.png" alt="<?php esc_attr_e( 'Donor Comments', 'charitable' ); ?>">
1063 + <a href="<?php echo esc_url( charitable()->get_path( 'assets', false ) ); ?>images/education/donor-comments/education-3.png" class="hover" data-lity="" data-lity-desc="<?php esc_attr_e( 'Donor Comments', 'charitable' ); ?>"></a>
1064 + </div>
1065 + <figcaption><?php esc_html_e( 'Donor Comments', 'charitable' ); ?></figcaption>
1066 + </figure>
1067 + </div>
1068 + </div>
1069 +
1070 + <div class="charitable-education-page-caps">
1071 + <p><?php esc_html_e( 'Give donors the power to manage their contributions to your organization.', 'charitable' ); ?></p>
1072 + <ul>
1073 + <li><i class="fa fa-solid fa-check"></i> <?php esc_html_e( 'Increased Donor Engagement', 'charitable' ); ?></li>
1074 + <li><i class="fa fa-solid fa-check"></i> <?php esc_html_e( 'Customizable Dashboard', 'charitable' ); ?></li>
1075 + <li><i class="fa fa-solid fa-check"></i> <?php esc_html_e( 'Donation History', 'charitable' ); ?></li>
1076 + <li><i class="fa fa-solid fa-check"></i> <?php esc_html_e( 'View Campaigns', 'charitable' ); ?></li>
1077 + <li><i class="fa fa-solid fa-check"></i> <?php esc_html_e( 'View Comments', 'charitable' ); ?></li>
1078 + <li><i class="fa fa-solid fa-check"></i> <?php esc_html_e( 'Download Donation Receipts', 'charitable' ); ?></li>
1079 + <li><i class="fa fa-solid fa-check"></i> <?php esc_html_e( 'Tracking Personalized Notifications', 'charitable' ); ?></li>
1080 + <li><i class="fa fa-solid fa-check"></i> <?php esc_html_e( 'Donor Profile Management', 'charitable' ); ?></li>
1081 + <li><i class="fa fa-solid fa-check"></i> <?php esc_html_e( 'See Each Donor\'s Referrals', 'charitable' ); ?></li>
1082 + <li><i class="fa fa-solid fa-check"></i> <?php esc_html_e( 'Track Referral Success Rates', 'charitable' ); ?></li>
1083 + <li><i class="fa fa-solid fa-check"></i> <?php esc_html_e( 'Customizable Referral Rewards', 'charitable' ); ?></li>
1084 + <li><i class="fa fa-solid fa-check"></i> <?php esc_html_e( 'Easy Promotion of Campaigns', 'charitable' ); ?></li>
1085 +
1086 + </ul>
1087 + </div>
1088 + <?php
1089 + }
1090 +
1091 + /**
1092 + * Get the settings CTA education content for the donor referrals sub tab.
1093 + *
1094 + * @since 1.8.5.1
1095 + *
1096 + * @return void
1097 + */
1098 + public function get_settings_cta_education_content_marketing_settings() {
1099 + ?>
1100 +
1101 + <div class="charitable-education-page-heading">
1102 + <h4><?php esc_html_e( 'Marketing', 'charitable' ); ?></h4>
1103 + <p><?php esc_html_e( 'Turn one-time donors into ongoing supporters with your newsletter list. This feature allows you to connect to your email marketing account and automatically add donors to your email newsletter list. You can integrate your campaigns seamlessly with MailChimp, Campaign Monitor, MailerLite, ActiveCampaign, Mailster and MailPoet, allowing you to enable one or more providers.', 'charitable' ); ?></p>
1104 + </div>
1105 +
1106 + <div class="charitable-education-page-media">
1107 + <div class="charitable-education-page-images">
1108 + <figure>
1109 + <div class="charitable-education-page-images-image">
1110 + <img src="<?php echo esc_url( charitable()->get_path( 'assets', false ) ); ?>images/education/marketing/education-1.png" alt="<?php esc_attr_e( 'Marketing', 'charitable' ); ?>">
1111 + <a href="<?php echo esc_url( charitable()->get_path( 'assets', false ) ); ?>images/education/marketing/education-1.png" class="hover" data-lity="" data-lity-desc="<?php esc_attr_e( 'Marketing', 'charitable' ); ?>"></a>
1112 + </div>
1113 + <figcaption><?php esc_html_e( 'Choose a default list', 'charitable' ); ?></figcaption>
1114 + </figure>
1115 + <figure>
1116 + <div class="charitable-education-page-images-image">
1117 + <img src="<?php echo esc_url( charitable()->get_path( 'assets', false ) ); ?>images/education/marketing/education-2.png" alt="<?php esc_attr_e( 'Marketing', 'charitable' ); ?>">
1118 + <a href="<?php echo esc_url( charitable()->get_path( 'assets', false ) ); ?>images/education/marketing/education-2.png" class="hover" data-lity="" data-lity-desc="<?php esc_attr_e( 'Marketing', 'charitable' ); ?>"></a>
1119 + </div>
1120 + <figcaption><?php esc_html_e( 'Sync lists', 'charitable' ); ?></figcaption>
1121 + </figure>
1122 + <figure>
1123 + <div class="charitable-education-page-images-image">
1124 + <img src="<?php echo esc_url( charitable()->get_path( 'assets', false ) ); ?>images/education/marketing/education-3.png" alt="<?php esc_attr_e( 'Marketing', 'charitable' ); ?>">
1125 + <a href="<?php echo esc_url( charitable()->get_path( 'assets', false ) ); ?>images/education/marketing/education-3.png" class="hover" data-lity="" data-lity-desc="<?php esc_attr_e( 'Marketing', 'charitable' ); ?>"></a>
1126 + </div>
1127 + <figcaption><?php esc_html_e( 'Donation form options', 'charitable' ); ?></figcaption>
1128 + </figure>
1129 + </div>
1130 + </div>
1131 +
1132 + <div class="charitable-education-page-caps">
1133 + <p><?php esc_html_e( 'Turn one-time donors into ongoing supporters.', 'charitable' ); ?></p>
1134 + <ul>
1135 + <li><i class="fa fa-solid fa-check"></i> <?php esc_html_e( 'Easy Integration', 'charitable' ); ?></li>
1136 + <li><i class="fa fa-solid fa-check"></i> <?php esc_html_e( 'Built-in contact consent options', 'charitable' ); ?></li>
1137 + <li><i class="fa fa-solid fa-check"></i> <?php esc_html_e( 'Automatically add donors to your email list', 'charitable' ); ?></li>
1138 + <li><i class="fa fa-solid fa-check"></i> <?php esc_html_e( 'Organize donors with tags', 'charitable' ); ?></li>
1139 + <li><i class="fa fa-solid fa-check"></i> <?php esc_html_e( 'Send email series to keep donors engaged', 'charitable' ); ?></li>
1140 + <li><i class="fa fa-solid fa-check"></i> <?php esc_html_e( 'Enable multiple email services', 'charitable' ); ?></li>
1141 + </ul>
1142 + </div>
1143 + <?php
1144 + }
1145 +
1146 + /**
1147 + * Get the settings CTA education content for the Marketing → Conversion Tracking sub-tab.
1148 + *
1149 + * @since 1.8.11.3
1150 + *
1151 + * @return void
1152 + */
1153 + public function get_settings_cta_education_content_conversion_tracking() {
1154 + $assets_url = charitable()->get_path( 'assets', false );
1155 + ?>
1156 +
1157 + <div class="charitable-education-page-heading">
1158 + <h4><?php esc_html_e( 'Conversion Tracking', 'charitable' ); ?></h4>
1159 + <p><?php esc_html_e( 'Send Charitable donation events into Meta Pixel, TikTok Pixel, and Google Tag Manager. Native, code-free conversion tracking that ties every completed donation to the ad campaigns and audiences that drove it.', 'charitable' ); ?></p>
1160 + <p><?php esc_html_e( 'See which ads actually produce donations, optimize spend toward real revenue, and build remarketing audiences from your highest-value supporters.', 'charitable' ); ?></p>
1161 + </div>
1162 +
1163 + <div class="charitable-education-page-media">
1164 + <div class="charitable-education-page-video">
1165 + <figure>
1166 + <div class="charitable-education-page-video-embed">
1167 + <iframe src="https://www.youtube-nocookie.com/embed/sS-F6x6F-Fs?rel=0&amp;modestbranding=1&amp;iv_load_policy=3&amp;loop=1&amp;playlist=sS-F6x6F-Fs" title="<?php esc_attr_e( 'Introducing Conversion Tracking', 'charitable' ); ?>" allow="accelerometer; autoplay; clipboard-write; encrypted-media; picture-in-picture" allowfullscreen frameborder="0"></iframe>
1168 + </div>
1169 + <figcaption><a href="https://youtu.be/sS-F6x6F-Fs" target="_blank" rel="noopener noreferrer"><?php esc_html_e( 'Watch: Introducing Conversion Tracking', 'charitable' ); ?></a></figcaption>
1170 + </figure>
1171 + </div>
1172 + <div class="charitable-education-page-images">
1173 + <figure>
1174 + <div class="charitable-education-page-images-image">
1175 + <img src="<?php echo esc_url( $assets_url ); ?>images/education/conversion-tracking/education-1.png" alt="<?php esc_attr_e( 'Conversion tracking settings', 'charitable' ); ?>">
1176 + <a href="<?php echo esc_url( $assets_url ); ?>images/education/conversion-tracking/education-1.png" class="hover" data-lity="" data-lity-desc="<?php esc_attr_e( 'Pixel + GTM settings', 'charitable' ); ?>"></a>
1177 + </div>
1178 + <figcaption><?php esc_html_e( 'Pixel + GTM settings', 'charitable' ); ?></figcaption>
1179 + </figure>
1180 + <figure>
1181 + <div class="charitable-education-page-images-image">
1182 + <img src="<?php echo esc_url( $assets_url ); ?>images/education/conversion-tracking/education-2.png" alt="<?php esc_attr_e( 'Per-donation tracking status', 'charitable' ); ?>">
1183 + <a href="<?php echo esc_url( $assets_url ); ?>images/education/conversion-tracking/education-2.png" class="hover" data-lity="" data-lity-desc="<?php esc_attr_e( 'Per-donation tracking status', 'charitable' ); ?>"></a>
1184 + </div>
1185 + <figcaption><?php esc_html_e( 'Per-donation tracking status', 'charitable' ); ?></figcaption>
1186 + </figure>
1187 + <figure>
1188 + <div class="charitable-education-page-images-image">
1189 + <img src="<?php echo esc_url( $assets_url ); ?>images/education/conversion-tracking/education-3.png" alt="<?php esc_attr_e( 'WP Consent API compliant', 'charitable' ); ?>">
1190 + <a href="<?php echo esc_url( $assets_url ); ?>images/education/conversion-tracking/education-3.png" class="hover" data-lity="" data-lity-desc="<?php esc_attr_e( 'WP Consent API compliant', 'charitable' ); ?>"></a>
1191 + </div>
1192 + <figcaption><?php esc_html_e( 'WP Consent API compliant', 'charitable' ); ?></figcaption>
1193 + </figure>
1194 + </div>
1195 + </div>
1196 +
1197 + <div class="charitable-education-page-caps">
1198 + <p><?php esc_html_e( 'Track conversions with…', 'charitable' ); ?></p>
1199 + <ul>
1200 + <li><i class="fa fa-solid fa-check"></i> <?php esc_html_e( 'Meta Pixel (Facebook / Instagram)', 'charitable' ); ?></li>
1201 + <li><i class="fa fa-solid fa-check"></i> <?php esc_html_e( 'TikTok Pixel', 'charitable' ); ?></li>
1202 + <li><i class="fa fa-solid fa-check"></i> <?php esc_html_e( 'Google Tag Manager (GTM)', 'charitable' ); ?></li>
1203 + <li><i class="fa fa-solid fa-check"></i> <?php esc_html_e( 'Campaign page view tracking', 'charitable' ); ?></li>
1204 + <li><i class="fa fa-solid fa-check"></i> <?php esc_html_e( 'Donation form open tracking', 'charitable' ); ?></li>
1205 + <li><i class="fa fa-solid fa-check"></i> <?php esc_html_e( 'WP Consent API (GDPR) integration', 'charitable' ); ?></li>
1206 + </ul>
1207 + </div>
1208 + <?php
1209 + }
1210 +
1211 + /**
1212 + * Get the settings CTA education content for the Marketing → Google Analytics sub-tab.
1213 + *
1214 + * @since 1.8.11.3
1215 + *
1216 + * @return void
1217 + */
1218 + public function get_settings_cta_education_content_google_analytics() {
1219 + $assets_url = charitable()->get_path( 'assets', false );
1220 + ?>
1221 +
1222 + <div class="charitable-education-page-heading">
1223 + <h4><?php esc_html_e( 'Google Analytics', 'charitable' ); ?></h4>
1224 + <p><?php esc_html_e( 'Send Charitable donation events into Google Analytics 4. Native GA4 integration fires purchase, refund, sign-up, and login events both browser-side via gtag.js and server-side via the Measurement Protocol — so every donation, including off-site gateways and webhook-confirmed completions, makes it into GA4.', 'charitable' ); ?></p>
1225 + <p><?php esc_html_e( 'See which campaigns and sources actually produce donations, stitch sessions across devices with hashed-email user_id, and stay EEA-compliant out of the box via Google Consent Mode v2 and the WP Consent API.', 'charitable' ); ?></p>
1226 + </div>
1227 +
1228 + <div class="charitable-education-page-media">
1229 + <div class="charitable-education-page-images">
1230 + <figure>
1231 + <div class="charitable-education-page-images-image">
1232 + <img src="<?php echo esc_url( $assets_url ); ?>images/education/google-analytics/education-1.png" alt="<?php esc_attr_e( 'Google Analytics settings', 'charitable' ); ?>">
1233 + <a href="<?php echo esc_url( $assets_url ); ?>images/education/google-analytics/education-1.png" class="hover" data-lity="" data-lity-desc="<?php esc_attr_e( 'GA4 settings + Test Connection', 'charitable' ); ?>"></a>
1234 + </div>
1235 + <figcaption><?php esc_html_e( 'GA4 settings + Test Connection', 'charitable' ); ?></figcaption>
1236 + </figure>
1237 + <figure>
1238 + <div class="charitable-education-page-images-image">
1239 + <img src="<?php echo esc_url( $assets_url ); ?>images/education/google-analytics/education-2.png" alt="<?php esc_attr_e( 'Per-donation GA metabox', 'charitable' ); ?>">
1240 + <a href="<?php echo esc_url( $assets_url ); ?>images/education/google-analytics/education-2.png" class="hover" data-lity="" data-lity-desc="<?php esc_attr_e( 'Per-donation tracking metabox', 'charitable' ); ?>"></a>
1241 + </div>
1242 + <figcaption><?php esc_html_e( 'Per-donation tracking metabox', 'charitable' ); ?></figcaption>
1243 + </figure>
1244 + <figure>
1245 + <div class="charitable-education-page-images-image">
1246 + <img src="<?php echo esc_url( $assets_url ); ?>images/education/google-analytics/education-3.png" alt="<?php esc_attr_e( 'Test connection success', 'charitable' ); ?>">
1247 + <a href="<?php echo esc_url( $assets_url ); ?>images/education/google-analytics/education-3.png" class="hover" data-lity="" data-lity-desc="<?php esc_attr_e( 'Validate your GA4 setup', 'charitable' ); ?>"></a>
1248 + </div>
1249 + <figcaption><?php esc_html_e( 'Validate your GA4 setup', 'charitable' ); ?></figcaption>
1250 + </figure>
1251 + </div>
1252 + </div>
1253 +
1254 + <div class="charitable-education-page-caps">
1255 + <p><?php esc_html_e( 'Track donations in GA4 with…', 'charitable' ); ?></p>
1256 + <ul>
1257 + <li><i class="fa fa-solid fa-check"></i> <?php esc_html_e( 'GA4 purchase events (browser + Measurement Protocol)', 'charitable' ); ?></li>
1258 + <li><i class="fa fa-solid fa-check"></i> <?php esc_html_e( 'Server-side refund, sign_up, and login events', 'charitable' ); ?></li>
1259 + <li><i class="fa fa-solid fa-check"></i> <?php esc_html_e( 'Full UTM capture (including utm_term and utm_id)', 'charitable' ); ?></li>
1260 + <li><i class="fa fa-solid fa-check"></i> <?php esc_html_e( 'Hashed-email user_id for cross-device session stitching', 'charitable' ); ?></li>
1261 + <li><i class="fa fa-solid fa-check"></i> <?php esc_html_e( 'Google Consent Mode v2 + WP Consent API integration', 'charitable' ); ?></li>
1262 + <li><i class="fa fa-solid fa-check"></i> <?php esc_html_e( '"Test Connection" button to validate your GA4 setup', 'charitable' ); ?></li>
1263 + </ul>
1264 + </div>
1265 + <?php
1266 + }
1267 +
1268 + /**
1269 + * Get the settings CTA education content for the donor referrals sub tab.
1270 + *
1271 + * @since 1.8.5.1
1272 + *
1273 + * @return void
1274 + */
1275 + public function get_settings_cta_education_content_security_settings() {
1276 + ?>
1277 +
1278 + <div class="charitable-education-page-heading">
1279 + <h4><?php esc_html_e( 'Security', 'charitable' ); ?></h4>
1280 + <p><?php esc_html_e( 'It is important to protect against potential misuse while maintaining donor trust. CAPTCHA integration adds an essential layer of protection against automated attacks and spam donations. Every transaction is meticulously logged with IP address documentation and timestamp verification, providing a clear audit trail and helping prevent fraudulent activities.', 'charitable' ); ?></p>
1281 + </div>
1282 +
1283 + <div class="charitable-education-page-media">
1284 + <div class="charitable-education-page-images">
1285 + <figure>
1286 + <div class="charitable-education-page-images-image">
1287 + <img src="<?php echo esc_url( charitable()->get_path( 'assets', false ) ); ?>images/education/security/education-1.png" alt="<?php esc_attr_e( 'Security', 'charitable' ); ?>">
1288 + <a href="<?php echo esc_url( charitable()->get_path( 'assets', false ) ); ?>images/education/security/education-1.png" class="hover" data-lity="" data-lity-desc="<?php esc_attr_e( 'Security', 'charitable' ); ?>"></a>
1289 + </div>
1290 + <figcaption><?php esc_html_e( 'Captchas', 'charitable' ); ?></figcaption>
1291 + </figure>
1292 + <figure>
1293 + <div class="charitable-education-page-images-image">
1294 + <img src="<?php echo esc_url( charitable()->get_path( 'assets', false ) ); ?>images/education/security/education-3.png" alt="<?php esc_attr_e( 'Security', 'charitable' ); ?>">
1295 + <a href="<?php echo esc_url( charitable()->get_path( 'assets', false ) ); ?>images/education/security/education-3.png" class="hover" data-lity="" data-lity-desc="<?php esc_attr_e( 'Security', 'charitable' ); ?>"></a>
1296 + </div>
1297 + <figcaption><?php esc_html_e( 'Form options', 'charitable' ); ?></figcaption>
1298 + </figure>
1299 + </div>
1300 + </div>
1301 +
1302 + <div class="charitable-education-page-caps">
1303 + <p><?php esc_html_e( 'Protect against potential misuse while maintaining donor trust.', 'charitable' ); ?></p>
1304 + <ul>
1305 + <li><i class="fa fa-solid fa-check"></i> <?php esc_html_e( 'Easy Activation', 'charitable' ); ?></li>
1306 + <li><i class="fa fa-solid fa-check"></i> <?php esc_html_e( 'Record IP Addresses', 'charitable' ); ?></li>
1307 + <li><i class="fa fa-solid fa-check"></i> <?php esc_html_e( 'Block Bad Bots', 'charitable' ); ?></li>
1308 + </ul>
1309 + </div>
1310 + <?php
1311 + }
1312 +
1313 + /**
1314 + * Get the settings CTA education content for advanced security features.
1315 + *
1316 + * @since 1.8.9
1317 + *
1318 + * @return void
1319 + */
1320 + public function get_settings_cta_education_content_advanced_security_settings() {
1321 + ?>
1322 +
1323 + <div class="charitable-education-page-heading">
1324 + <h4><?php esc_html_e( 'Advanced Security Features', 'charitable' ); ?></h4>
1325 + <p><?php esc_html_e( 'Charitable Pro offers a fortified layer of safety designed for high-volume campaigns. Upgrade to unlock sophisticated spam filtering and enhanced payment protection, ensuring the highest level of trust and security for your donors.', 'charitable' ); ?></p>
1326 + </div>
1327 + <div class="charitable-education-page-caps">
1328 + <p><?php esc_html_e( 'Protect against potential misuse while maintaining donor trust.', 'charitable' ); ?></p>
1329 + <ul>
1330 + <li><i class="fa fa-solid fa-check"></i> <?php esc_html_e( 'General Rate Limiting', 'charitable' ); ?></li>
1331 + <li><i class="fa fa-solid fa-check"></i> <?php esc_html_e( 'Stripe Rate Limiting', 'charitable' ); ?></li>
1332 + <li><i class="fa fa-solid fa-check"></i> <?php esc_html_e( 'IP Blacklist/Whitelist', 'charitable' ); ?></li>
1333 + <li><i class="fa fa-solid fa-check"></i> <?php esc_html_e( 'Email Pattern Blocking', 'charitable' ); ?></li>
1334 + <li><i class="fa fa-solid fa-check"></i> <?php esc_html_e( 'Minimum Donation Features', 'charitable' ); ?></li>
1335 + <li><i class="fa fa-solid fa-check"></i> <?php esc_html_e( 'Math Field Protection', 'charitable' ); ?></li>
1336 + </ul>
1337 + </div>
1338 + <?php
1339 + }
1340 +
1341 + /**
810 1342 * Dismiss upgrade notice at the bottom on the plugin settings pages.
811 1343 *
812 1344 * @since 1.7.0.4
1345 + *
1346 + * @return void
813 1347 */
814 1348 public function settings_cta_dismiss() {
815 1349
816 1350 if ( ! charitable_current_user_can() ) {
@@ -819,8 +1353,47 @@
819 1353
820 1354 update_option( 'charitable_lite_settings_upgrade', time() );
821 1355
822 1356 wp_send_json_success();
1357 + }
1358 +
1359 + /**
1360 + * Check Square connection for the new mode.
1361 + *
1362 + * @since 1.8.5
1363 + *
1364 + * @param string $new_mode The new test mode.
1365 + * @return boolean True if Square has connection issues, false otherwise.
1366 + */
1367 + private function check_square_connection_for_mode_change( $new_mode ) {
1368 + // Check if Square gateway is active.
1369 + $active_gateways = charitable_get_helper( 'gateways' )->get_active_gateways();
1370 +
1371 + if ( ! is_array( $active_gateways ) || ! in_array( 'Charitable_Gateway_Square', $active_gateways ) ) {
1372 + return false;
1373 + }
1374 +
1375 + // Determine the mode string.
1376 + $mode = $new_mode ? 'test' : 'live';
1377 +
1378 + // Check if there's a Square connection for this mode.
1379 + $connection = Charitable_Square_Connection::get( $mode );
1380 +
1381 + // Check if connection exists and is properly configured.
1382 + if ( ! $connection || ! $connection->is_configured() || ! $connection->is_valid() ) {
1383 +
1384 + // Set a warning flag that will be checked on the payment page.
1385 + update_option( 'charitable_square_mode_connection_warning', array(
1386 + 'mode' => $mode,
1387 + 'timestamp' => time(),
1388 + ) );
1389 +
1390 + return true; // Square has connection issues.
1391 + } else {
1392 + // Clear the warning if connection exists.
1393 + delete_option( 'charitable_square_mode_connection_warning' );
1394 + return false; // Square has no connection issues.
1395 + }
823 1396 }
824 1397 }
825 1398
826 1399 endif;