Skip to content

Commit b093d4a

Browse files
committed
Compat for removal of wc_select_params localize variable in WC 2.3.6
If `wc_select_params` is defined, the js falls back to using those values. However, if neither `wc_select_params` of `wc_enhanced_select_params` are defined, we fall back to not localizing the strings in order to avoid JS errors.
1 parent 8ea8300 commit b093d4a

File tree

3 files changed

+26
-14
lines changed

3 files changed

+26
-14
lines changed

woocommerce/changelog.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
*** SkyVerge WooCommerce Plugin Framework Changelog ***
22

3+
2015.nn.nn - version 3.1.1-1
4+
* Fix - JS variable `wc_select_params` undefined in WC 2.3.6+
5+
36
2015.03.10 - version 3.1.1
47
* Tweak - Add `get_cancel_order_url_raw()` compatibility method
58

woocommerce/class-sv-wc-helper.php

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -554,50 +554,59 @@ public static function render_select2_ajax() {
554554
// ensure localized strings are used
555555
$javascript .= "
556556
function getEnhancedSelectFormatString() {
557+
558+
if ( 'undefined' !== typeof wc_select_params ) {
559+
wc_enhanced_select_params = wc_select_params;
560+
}
561+
562+
if ( 'undefined' === typeof wc_enhanced_select_params ) {
563+
return {};
564+
}
565+
557566
var formatString = {
558567
formatMatches: function( matches ) {
559568
if ( 1 === matches ) {
560-
return wc_select_params.i18n_matches_1;
569+
return wc_enhanced_select_params.i18n_matches_1;
561570
}
562571
563-
return wc_select_params.i18n_matches_n.replace( '%qty%', matches );
572+
return wc_enhanced_select_params.i18n_matches_n.replace( '%qty%', matches );
564573
},
565574
formatNoMatches: function() {
566-
return wc_select_params.i18n_no_matches;
575+
return wc_enhanced_select_params.i18n_no_matches;
567576
},
568577
formatAjaxError: function( jqXHR, textStatus, errorThrown ) {
569-
return wc_select_params.i18n_ajax_error;
578+
return wc_enhanced_select_params.i18n_ajax_error;
570579
},
571580
formatInputTooShort: function( input, min ) {
572581
var number = min - input.length;
573582
574583
if ( 1 === number ) {
575-
return wc_select_params.i18n_input_too_short_1
584+
return wc_enhanced_select_params.i18n_input_too_short_1
576585
}
577586
578-
return wc_select_params.i18n_input_too_short_n.replace( '%qty%', number );
587+
return wc_enhanced_select_params.i18n_input_too_short_n.replace( '%qty%', number );
579588
},
580589
formatInputTooLong: function( input, max ) {
581590
var number = input.length - max;
582591
583592
if ( 1 === number ) {
584-
return wc_select_params.i18n_input_too_long_1
593+
return wc_enhanced_select_params.i18n_input_too_long_1
585594
}
586595
587-
return wc_select_params.i18n_input_too_long_n.replace( '%qty%', number );
596+
return wc_enhanced_select_params.i18n_input_too_long_n.replace( '%qty%', number );
588597
},
589598
formatSelectionTooBig: function( limit ) {
590599
if ( 1 === limit ) {
591-
return wc_select_params.i18n_selection_too_long_1;
600+
return wc_enhanced_select_params.i18n_selection_too_long_1;
592601
}
593602
594-
return wc_select_params.i18n_selection_too_long_n.replace( '%qty%', number );
603+
return wc_enhanced_select_params.i18n_selection_too_long_n.replace( '%qty%', number );
595604
},
596605
formatLoadMore: function( pageNumber ) {
597-
return wc_select_params.i18n_load_more;
606+
return wc_enhanced_select_params.i18n_load_more;
598607
},
599608
formatSearching: function() {
600-
return wc_select_params.i18n_searching;
609+
return wc_enhanced_select_params.i18n_searching;
601610
}
602611
};
603612

woocommerce/class-sv-wc-plugin.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,12 @@
8484
* Use the standard WordPress/WooCommerce `is_*` methods when adding the notice
8585
* to control which pages it does (or does not) display on.
8686
*
87-
* @version 3.1.1
87+
* @version 3.1.1-1
8888
*/
8989
abstract class SV_WC_Plugin {
9090

9191
/** Plugin Framework Version */
92-
const VERSION = '3.1.1';
92+
const VERSION = '3.1.1-1';
9393

9494
/** @var object single instance of plugin */
9595
protected static $instance;

0 commit comments

Comments
 (0)