From ce9e9d13084534bf97f5c1b9caaebea255791cca Mon Sep 17 00:00:00 2001 From: David Remer Date: Thu, 3 Sep 2020 07:16:52 +0300 Subject: [PATCH] pcp-48 / set correct title for setting tabs --- .../src/Gateway/class-paypalgateway.php | 19 ++++++++++++++++++- .../src/Settings/class-sectionsrenderer.php | 4 ++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/modules/ppcp-wc-gateway/src/Gateway/class-paypalgateway.php b/modules/ppcp-wc-gateway/src/Gateway/class-paypalgateway.php index 63efd764b..cf8ce1853 100644 --- a/modules/ppcp-wc-gateway/src/Gateway/class-paypalgateway.php +++ b/modules/ppcp-wc-gateway/src/Gateway/class-paypalgateway.php @@ -310,6 +310,9 @@ class PayPalGateway extends \WC_Payment_Gateway { if ( $this->is_credit_card_tab() ) { return __( 'PayPal Card Processing', 'paypal-for-woocommerce' ); } + if ( $this->is_paypal_tab() ) { + return __( 'PayPal Checkout', 'paypal-for-woocommerce' ); + } return __( 'PayPal', 'paypal-for-woocommerce' ); } @@ -340,8 +343,22 @@ class PayPalGateway extends \WC_Payment_Gateway { * @return bool */ private function is_credit_card_tab() : bool { - return is_admin() && isset( $_GET[ SectionsRenderer::KEY ] ) && CreditCardGateway::ID === sanitize_text_field( wp_unslash( $_GET[ SectionsRenderer::KEY ] ) ); + return is_admin() + && isset( $_GET[ SectionsRenderer::KEY ] ) + && CreditCardGateway::ID === sanitize_text_field( wp_unslash( $_GET[ SectionsRenderer::KEY ] ) ); } + + /** + * Whether we are on the PayPal settings tab. + * + * @return bool + */ + private function is_paypal_tab() : bool { + return ! $this->is_credit_card_tab() + && is_admin() + && isset( $_GET['section'] ) + && self::ID === sanitize_text_field( wp_unslash( $_GET['section'] ) ); + } // phpcs:enable WordPress.Security.NonceVerification.Recommended } diff --git a/modules/ppcp-wc-gateway/src/Settings/class-sectionsrenderer.php b/modules/ppcp-wc-gateway/src/Settings/class-sectionsrenderer.php index 0ce2d9628..c7e95d416 100644 --- a/modules/ppcp-wc-gateway/src/Settings/class-sectionsrenderer.php +++ b/modules/ppcp-wc-gateway/src/Settings/class-sectionsrenderer.php @@ -41,8 +41,8 @@ class SectionsRenderer { //phpcs:ignore WordPress.Security.NonceVerification.Recommended $current = ! isset( $_GET[ self::KEY ] ) ? PayPalGateway::ID : sanitize_text_field( wp_unslash( $_GET[ self::KEY ] ) ); $sections = array( - PayPalGateway::ID => __( 'PayPal', 'paypal-for-woocommerce' ), - CreditCardGateway::ID => __( 'Credit Card', 'paypal-for-woocommerce' ), + PayPalGateway::ID => __( 'PayPal Checkout', 'paypal-for-woocommerce' ), + CreditCardGateway::ID => __( 'PayPal Card Processing', 'paypal-for-woocommerce' ), ); echo '