Skip to content

Commit 0ee066f

Browse files
authored
Merge pull request #495 from skyverge/ch54568/fix-i18n-strings
Fix gateway payment form i18n strings
2 parents 0ef00ad + c37aee2 commit 0ee066f

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

woocommerce/payment-gateway/class-sv-wc-payment-gateway.php

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -443,16 +443,17 @@ protected function enqueue_payment_form_assets() {
443443
return;
444444
}
445445

446-
$handle = 'sv-wc-payment-gateway-payment-form';
446+
$handle = 'sv-wc-payment-gateway-payment-form';
447+
$versioned_handle = $handle . '-v5_7_1';
447448

448449
// Frontend JS
449-
wp_enqueue_script( "$handle-v5_7_1", $this->get_plugin()->get_payment_gateway_framework_assets_url() . '/js/frontend/' . $handle . '.min.js', array( 'jquery-payment' ), SV_WC_Plugin::VERSION, true );
450+
wp_enqueue_script( $versioned_handle, $this->get_plugin()->get_payment_gateway_framework_assets_url() . '/js/frontend/' . $handle . '.min.js', array( 'jquery-payment' ), SV_WC_Plugin::VERSION, true );
450451

451452
// Frontend CSS
452-
wp_enqueue_style( "$handle-v5_7_1", $this->get_plugin()->get_payment_gateway_framework_assets_url() . '/css/frontend/' . $handle . '.min.css', array(), SV_WC_Plugin::VERSION );
453+
wp_enqueue_style( $versioned_handle, $this->get_plugin()->get_payment_gateway_framework_assets_url() . '/css/frontend/' . $handle . '.min.css', array(), SV_WC_Plugin::VERSION );
453454

454455
// localized JS params
455-
$this->localize_script( $handle, $this->get_payment_form_js_localized_script_params() );
456+
$this->localize_script( $versioned_handle, $this->get_payment_form_js_localized_script_params(), 'sv_wc_payment_gateway_payment_form_params' );
456457
}
457458

458459

@@ -608,8 +609,9 @@ protected function get_gateway_js_localized_script_params() {
608609
* @since 4.3.0
609610
* @param string $handle script handle to localize
610611
* @param array $params script params to localize
612+
* @param string $object_name the localized object name. Defaults to a snake-cased version of $handle
611613
*/
612-
protected function localize_script( $handle, $params ) {
614+
protected function localize_script( $handle, $params, $object_name = '' ) {
613615

614616
// If the script isn't loaded, bail
615617
if ( ! wp_script_is( $handle, 'enqueued' ) ) {
@@ -618,7 +620,10 @@ protected function localize_script( $handle, $params ) {
618620

619621
global $wp_scripts;
620622

621-
$object_name = str_replace( '-', '_', $handle ) . '_params';
623+
// generate the object name from the handle if none is specified
624+
if ( ! $object_name ) {
625+
$object_name = str_replace( '-', '_', $handle ) . '_params';
626+
}
622627

623628
// If the plugin's JS params already exists in the localized data, bail
624629
if ( $wp_scripts instanceof \WP_Scripts && strpos( $wp_scripts->get_data( $handle, 'data' ), $object_name ) ) {

0 commit comments

Comments
 (0)