From d69fb5bc7043a0898e58df834bf8cb6c543107b1 Mon Sep 17 00:00:00 2001 From: Philipp Stracker Date: Wed, 5 Jun 2024 18:05:06 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Load=20button=20preview=20JS=20o?= =?UTF-8?q?n=20ACDC=20settings=20page?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Renamed the DI service name; this service is only used in two places (APM modules), which were also updated. --- modules/ppcp-applepay/src/ApplepayModule.php | 2 +- .../ppcp-googlepay/src/GooglepayModule.php | 2 +- modules/ppcp-wc-gateway/services.php | 19 ++++++++++++++++--- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/modules/ppcp-applepay/src/ApplepayModule.php b/modules/ppcp-applepay/src/ApplepayModule.php index 5ac6a62cb..409a9c81e 100644 --- a/modules/ppcp-applepay/src/ApplepayModule.php +++ b/modules/ppcp-applepay/src/ApplepayModule.php @@ -205,7 +205,7 @@ class ApplepayModule implements ModuleInterface { add_action( 'admin_enqueue_scripts', static function () use ( $c, $button ) { - if ( ! is_admin() || ! $c->get( 'wcgateway.is-ppcp-settings-standard-payments-page' ) ) { + if ( ! is_admin() || ! $c->get( 'wcgateway.is-ppcp-settings-payment-methods-page' ) ) { return; } diff --git a/modules/ppcp-googlepay/src/GooglepayModule.php b/modules/ppcp-googlepay/src/GooglepayModule.php index e478881ba..e2b0ea8c5 100644 --- a/modules/ppcp-googlepay/src/GooglepayModule.php +++ b/modules/ppcp-googlepay/src/GooglepayModule.php @@ -112,7 +112,7 @@ class GooglepayModule implements ModuleInterface { add_action( 'admin_enqueue_scripts', static function () use ( $c, $button ) { - if ( ! is_admin() || ! $c->get( 'wcgateway.is-ppcp-settings-standard-payments-page' ) ) { + if ( ! is_admin() || ! $c->get( 'wcgateway.is-ppcp-settings-payment-methods-page' ) ) { return; } diff --git a/modules/ppcp-wc-gateway/services.php b/modules/ppcp-wc-gateway/services.php index 9ba0021b0..da7ba6908 100644 --- a/modules/ppcp-wc-gateway/services.php +++ b/modules/ppcp-wc-gateway/services.php @@ -201,9 +201,22 @@ return array( ); }, - 'wcgateway.is-ppcp-settings-standard-payments-page' => static function ( ContainerInterface $container ): bool { - return $container->get( 'wcgateway.is-ppcp-settings-page' ) - && $container->get( 'wcgateway.current-ppcp-settings-page-id' ) === PayPalGateway::ID; + // Checks, if the current admin page contains settings for this plugin's payment methods. + 'wcgateway.is-ppcp-settings-payment-methods-page' => static function ( ContainerInterface $container ) : bool { + if ( ! $container->get( 'wcgateway.is-ppcp-settings-page' ) ) { + return false; + } + + $active_tab = $container->get( 'wcgateway.current-ppcp-settings-page-id' ); + + return in_array( + $active_tab, + array( + PayPalGateway::ID, + CreditCardGateway::ID, + ), + true + ); }, 'wcgateway.current-ppcp-settings-page-id' => static function ( ContainerInterface $container ): string {