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/class-charitable-admin-notices.php +84 -0 1.8.11 → 1.8.13 View file →
@@ -62,8 +62,9 @@
62 62 add_action( 'admin_notices', array( $this, 'render_license_expiring_banner' ) );
63 63 add_action( 'admin_notices', array( $this, 'render_license_expired_banner' ) );
64 64 add_action( 'admin_notices', array( $this, 'render_five_star_rating' ) );
65 65 add_action( 'admin_notices', array( $this, 'render_square_connection_error' ) );
66 + add_action( 'admin_notices', array( $this, 'render_paypal_account_type_required_notice' ) );
66 67 add_action( 'charitable_dismiss_notice', array( $this, 'dismiss_five_star_notice' ), 10, 1 );
67 68 add_action( 'charitable_dismiss_notice', array( $this, 'dismiss_campaign_builder_notice' ), 10, 1 );
68 69 add_action( 'charitable_dismiss_notice', array( $this, 'dismiss_dashboard_reporting_notice' ), 10, 1 );
69 70 add_action( 'charitable_dismiss_notice', array( $this, 'dismiss_square_connection_error_notice' ), 10, 1 );
@@ -414,8 +415,14 @@
414 415 if ( ! function_exists( 'get_current_screen' ) ) {
415 416 return;
416 417 }
417 418
419 + // Dashboard has its own inline version of this notice — skip the top-bar one.
420 + $page = isset( $_GET['page'] ) ? sanitize_text_field( wp_unslash( $_GET['page'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended
421 + if ( 'charitable-dashboard' === $page ) {
422 + return;
423 + }
424 +
418 425 $screen = get_current_screen();
419 426
420 427 // determine if we are on the current screen.
421 428 if ( ! is_null( $screen ) && ( in_array( $screen->id, charitable_get_charitable_screens() ) || ( isset( $screen->taxonomy ) && 'campaign_category' === $screen->taxonomy ) || ( isset( $screen->taxonomy ) && 'campaign_tag' === $screen->taxonomy ) ) ) {
@@ -464,8 +471,85 @@
464 471
465 472 $message = charitable_admin_view( 'notices/admin-notice-square-connection-error', array( 'message' => $admin_notice['message'], 'status_code' => $admin_notice['status_code'] ), true ); // phpcs:ignore
466 473 $key = 'square-connection-error';
467 474 $this->render_notice( $message, 'error', true, $key, false );
475 + }
476 +
477 + /**
478 + * Render a persistent banner across all Charitable admin screens when
479 + * the PayPal Commerce gateway is connected but the merchant has not
480 + * yet chosen an Account Type (Nonprofit vs Business).
481 + *
482 + * Per the 1.8.12 spec (B-strict default-handling) this banner is
483 + * intentionally NOT dismissible — the underlying state blocks
484 + * donations at validate_donation(), so dismissing the banner without
485 + * resolving the setting would mask broken donation processing from
486 + * the merchant. The banner persists until the setting is saved.
487 + *
488 + * @since 1.8.12
489 + *
490 + * @return void
491 + */
492 + public function render_paypal_account_type_required_notice() {
493 + // Gate behind manage_options. The notice exposes gateway
494 + // configuration state and links to the settings page; only users
495 + // who can actually fix it should see it.
496 + if ( ! current_user_can( 'manage_options' ) ) {
497 + return;
498 + }
499 +
500 + // Only fire on Charitable admin screens to avoid leaking into
501 + // unrelated plugins' admin contexts.
502 + $screen = get_current_screen();
503 + if ( is_null( $screen ) || ! in_array( $screen->id, charitable_get_charitable_screens(), true ) ) {
504 + return;
505 + }
506 +
507 + if ( ! class_exists( 'Charitable_Gateway_Paypal_Commerce' ) ) {
508 + return;
509 + }
510 +
511 + // Only fire when PayPal Commerce is actually an enabled gateway.
512 + // Stale merchant ID meta can survive from a prior connected session
513 + // even after the gateway is disabled in Settings > Payment Gateways;
514 + // without this check the notice would scold merchants who are not
515 + // using the gateway at all, and the deep-link target (the
516 + // gateways_paypal_commerce settings group) is not even registered
517 + // when the gateway is off, so clicking the notice's CTA would
518 + // bounce them to the gateway list page instead.
519 + $gateways = charitable_get_helper( 'gateways' );
520 + if ( ! $gateways || ! $gateways->is_active_gateway( Charitable_Gateway_Paypal_Commerce::ID ) ) {
521 + return;
522 + }
523 +
524 + $gateway = new Charitable_Gateway_Paypal_Commerce();
525 +
526 + // Only relevant for sites that have actually connected PayPal
527 + // Commerce. A disconnected gateway has nothing to gate.
528 + if ( ! $gateway->is_seller_connected() ) {
529 + return;
530 + }
531 +
532 + if ( $gateway->is_account_type_configured() ) {
533 + return;
534 + }
535 +
536 + $settings_url = admin_url( 'admin.php?page=charitable-settings&tab=gateways&group=gateways_paypal_commerce' );
537 + $message = sprintf(
538 + /* translators: %s: settings URL */
539 + __( '<strong>PayPal Commerce: Action Required.</strong> Donations are currently blocked because your Account Type has not been set. <a href="%s">Choose Nonprofit or Business</a> on the PayPal Commerce settings page to resume accepting donations.', 'charitable' ),
540 + esc_url( $settings_url )
541 + );
542 +
543 + echo '<div class="notice notice-error" style="border-left-width:4px;"><p>' . wp_kses(
544 + $message,
545 + array(
546 + 'strong' => array(),
547 + 'a' => array(
548 + 'href' => array(),
549 + ),
550 + )
551 + ) . '</p></div>';
468 552 }
469 553
470 554 /**
471 555 * Render a banner to promote the new campaign builder in version 1.8.0.