This commit is contained in:
David Remer 2020-09-02 12:41:10 +03:00
parent c269f35d61
commit 0e45cc5cb6
3 changed files with 9 additions and 7 deletions

View file

@ -298,14 +298,15 @@ class PayPalGateway extends \WC_Payment_Gateway {
return $content;
}
// phpcs:disable WordPress.Security.NonceVerification.Recommended
/**
* Defines the method title. If we are on the credit card tab in the settings, we want to change this.
*
* @return string
*/
private function define_method_title(): string {
if (is_admin() && isset($_GET[SectionsRenderer::KEY]) && CreditCardGateway::ID === sanitize_text_field(wp_unslash($_GET[SectionsRenderer::KEY]))) {
return __('PayPal Card Processing', 'paypal-for-woocommerce');
if ( is_admin() && isset( $_GET[ SectionsRenderer::KEY ] ) && CreditCardGateway::ID === sanitize_text_field( wp_unslash( $_GET[ SectionsRenderer::KEY ] ) ) ) {
return __( 'PayPal Card Processing', 'paypal-for-woocommerce' );
}
return __( 'PayPal Checkout', 'paypal-for-woocommerce' );
}
@ -316,7 +317,7 @@ class PayPalGateway extends \WC_Payment_Gateway {
* @return string
*/
private function define_method_description(): string {
if (is_admin() && isset($_GET[SectionsRenderer::KEY]) && CreditCardGateway::ID === sanitize_text_field(wp_unslash($_GET[SectionsRenderer::KEY]))) {
if ( is_admin() && isset( $_GET[ SectionsRenderer::KEY ] ) && CreditCardGateway::ID === sanitize_text_field( wp_unslash( $_GET[ SectionsRenderer::KEY ] ) ) ) {
return __(
'Accept debit and credit cards, and local payment methods with PayPals latest solution.',
'paypal-for-woocommerce'
@ -328,4 +329,5 @@ class PayPalGateway extends \WC_Payment_Gateway {
'paypal-for-woocommerce'
);
}
// phpcs:enable WordPress.Security.NonceVerification.Recommended
}

View file

@ -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', 'paypal-for-woocommerce' ),
CreditCardGateway::ID => __( 'Credit Card', 'paypal-for-woocommerce' ),
);
echo '<ul class="subsubsub">';

View file

@ -119,11 +119,11 @@ class SettingsListener {
$raw_data = ( isset( $_POST['ppcp'] ) ) ? (array) wp_unslash( $_POST['ppcp'] ) : array();
// phpcs:enable phpcs:disable WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
$settings = $this->retrieve_settings_from_raw_data( $raw_data );
if ( ! isset( $_GET[SectionsRenderer::KEY] ) || PayPalGateway::ID === $_GET[SectionsRenderer::KEY] ) {
if ( ! isset( $_GET[ SectionsRenderer::KEY ] ) || PayPalGateway::ID === $_GET[ SectionsRenderer::KEY ] ) {
$settings['enabled'] = isset( $_POST['woocommerce_ppcp-gateway_enabled'] )
&& 1 === absint( $_POST['woocommerce_ppcp-gateway_enabled'] );
}
if ( isset( $_GET[SectionsRenderer::KEY] ) && CreditCardGateway::ID === $_GET[SectionsRenderer::KEY] ) {
if ( isset( $_GET[ SectionsRenderer::KEY ] ) && CreditCardGateway::ID === $_GET[ SectionsRenderer::KEY ] ) {
$dcc_enabled_post_key = 'woocommerce_ppcp-credit-card-gateway_enabled';
$settings['dcc_gateway_enabled'] = isset( $_POST[ $dcc_enabled_post_key ] )
&& 1 === absint( $_POST[ $dcc_enabled_post_key ] );