mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 10:55:00 +08:00
Remove the str_replace CVC placeholder adjusting in favor of using the existing translation
This commit is contained in:
parent
f3da7a3162
commit
fd4a21a356
2 changed files with 19 additions and 11 deletions
|
@ -97,17 +97,6 @@ class CardFieldsModule implements ModuleInterface {
|
|||
}
|
||||
}
|
||||
|
||||
if ( apply_filters( 'woocommerce_paypal_payments_card_fields_translate_card_cvv', true ) ) {
|
||||
if ( isset( $default_fields['card-cvc-field'] ) ) {
|
||||
// Replaces the default card cvc placeholder with a translatable one (which also matches the CVV field label).
|
||||
$default_fields['card-cvc-field'] = str_replace(
|
||||
'CVC',
|
||||
esc_attr__( 'CVV', 'woocommerce-paypal-payments' ),
|
||||
$default_fields['card-cvc-field']
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return $default_fields;
|
||||
},
|
||||
10,
|
||||
|
|
|
@ -291,8 +291,10 @@ class CreditCardGateway extends \WC_Payment_Gateway_CC {
|
|||
*/
|
||||
public function form() {
|
||||
add_action( 'gettext', array( $this, 'replace_credit_card_cvv_label' ), 10, 3 );
|
||||
add_action( 'gettext', array( $this, 'replace_credit_card_cvv_placeholder' ), 10, 3 );
|
||||
parent::form();
|
||||
remove_action( 'gettext', 'replace_credit_card_cvv_label' );
|
||||
remove_action( 'gettext', 'replace_credit_card_cvv_placeholder' );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -312,6 +314,23 @@ class CreditCardGateway extends \WC_Payment_Gateway_CC {
|
|||
return __( 'CVV', 'woocommerce-paypal-payments' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Replace WooCommerce credit card CVV field placeholder.
|
||||
*
|
||||
* @param string $translation Translated text.
|
||||
* @param string $text Original text to translate.
|
||||
* @param string $domain Text domain.
|
||||
*
|
||||
* @return string Translated field.
|
||||
*/
|
||||
public function replace_credit_card_cvv_placeholder( string $translation, string $text, string $domain ): string {
|
||||
if ( 'woocommerce' !== $domain || 'CVC' !== $text || ! apply_filters( 'woocommerce_paypal_payments_card_fields_translate_card_cvv', true ) ) {
|
||||
return $translation;
|
||||
}
|
||||
|
||||
return __( 'CVV', 'woocommerce-paypal-payments' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the icons of the gateway.
|
||||
*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue