From eb3396328bc3417c40ad1f9e17649c82fa0f7662 Mon Sep 17 00:00:00 2001 From: Mike Jolley Date: Wed, 20 Sep 2017 16:03:26 +0100 Subject: [PATCH 1/8] Apply default locale before country locale --- assets/js/frontend/address-i18n.js | 259 ++++++++++++------------- assets/js/frontend/address-i18n.min.js | 2 +- 2 files changed, 129 insertions(+), 132 deletions(-) diff --git a/assets/js/frontend/address-i18n.js b/assets/js/frontend/address-i18n.js index 359fd0808b2..e3a0b0596b1 100644 --- a/assets/js/frontend/address-i18n.js +++ b/assets/js/frontend/address-i18n.js @@ -1,155 +1,152 @@ /*global wc_address_i18n_params */ jQuery( function( $ ) { - // wc_address_i18n_params is required to continue, ensure the object exists - if ( typeof wc_address_i18n_params === 'undefined' ) { - return false; - } - - var locale_json = wc_address_i18n_params.locale.replace( /"/g, '"' ), - locale = $.parseJSON( locale_json ); - - function field_is_required( field, is_required ) { - if ( is_required ) { - field.find( 'label' ).append( ' *' ); - field.addClass( 'validate-required' ); - } else { - field.find( 'label abbr' ).remove(); - field.removeClass( 'validate-required' ); + // wc_address_i18n_params is required to continue, ensure the object exists + if ( typeof wc_address_i18n_params === 'undefined' ) { + return false; } - } - $( document.body ) + var locale_json = wc_address_i18n_params.locale.replace( /"/g, '"' ), + locale = $.parseJSON( locale_json ); - // Handle locale - .bind( 'country_to_state_changing', function( event, country, wrapper ) { - - var thisform = wrapper, thislocale; - - if ( typeof locale[ country ] !== 'undefined' ) { - thislocale = locale[ country ]; + function field_is_required( field, is_required ) { + if ( is_required ) { + field.find( 'label' ).append( ' *' ); + field.addClass( 'validate-required' ); } else { - thislocale = locale['default']; + field.find( 'label abbr' ).remove(); + field.removeClass( 'validate-required' ); } + } - var $postcodefield = thisform.find( '#billing_postcode_field, #shipping_postcode_field' ), - $cityfield = thisform.find( '#billing_city_field, #shipping_city_field' ), - $statefield = thisform.find( '#billing_state_field, #shipping_state_field' ); + $( document.body ) - if ( ! $postcodefield.attr( 'data-o_class' ) ) { - $postcodefield.attr( 'data-o_class', $postcodefield.attr( 'class' ) ); - $cityfield.attr( 'data-o_class', $cityfield.attr( 'class' ) ); - $statefield.attr( 'data-o_class', $statefield.attr( 'class' ) ); - } + // Handle locale + .bind( 'country_to_state_changing', function( event, country, wrapper ) { - var locale_fields = $.parseJSON( wc_address_i18n_params.locale_fields ); + var thisform = wrapper, thislocale; - $.each( locale_fields, function( key, value ) { - - var field = thisform.find( value ); - - if ( thislocale[ key ] ) { - - if ( thislocale[ key ].label ) { - field.find( 'label' ).html( thislocale[ key ].label ); - } - - if ( thislocale[ key ].placeholder ) { - field.find( 'input' ).attr( 'placeholder', thislocale[ key ].placeholder ); - field.find( '.select2-selection__placeholder' ).text( thislocale[ key ].placeholder ); - - // Use the i18n label as a placeholder if there is no label element or i18n placeholder. - } else if ( thislocale[ key ].label && ! field.find( 'label' ).length ) { - field.find( 'input' ).attr( 'placeholder', thislocale[ key ].label ); - field.find( '.select2-selection__placeholder' ).text( thislocale[ key ].label ); - } - - field_is_required( field, false ); - - if ( typeof thislocale[ key ].required === 'undefined' && locale['default'][ key ].required === true ) { - field_is_required( field, true ); - } else if ( thislocale[ key ].required === true ) { - field_is_required( field, true ); - } - - if ( key !== 'state' ) { - if ( thislocale[ key ].hidden === true ) { - field.hide().find( 'input' ).val( '' ); - } else { - field.show(); - } - } - - if ( thislocale[ key ].priority ) { - field.data( 'priority', thislocale[ key ].priority ); - } else if ( locale['default'][ key ].priority ) { - field.data( 'priority', locale['default'][ key ].priority ); - } - - } else if ( locale['default'][ key ] ) { - - if ( 'state' !== key ) { - if ( typeof locale['default'][ key ].hidden === 'undefined' || locale['default'][ key ].hidden === false ) { - field.show(); - } else if ( locale['default'][ key ].hidden === true ) { - field.hide().find( 'input' ).val( '' ); - } - } - - if ( 'postcode' === key || 'city' === key || 'state' === key ) { - if ( locale['default'][ key ].label ) { - field.find( 'label' ).html( locale['default'][ key ].label ); - } - - if ( locale['default'][ key ].placeholder ) { - field.find( 'input' ).attr( 'placeholder', locale['default'][ key ].placeholder ); - } - } - - if ( locale['default'][ key ].required === true ) { - if ( field.find( 'label abbr' ).length === 0 ) { - field_is_required( field, true ); - } - } - - if ( locale['default'][ key ].priority ) { - field.data( 'priority', locale['default'][ key ].priority ); - } + if ( typeof locale[ country ] !== 'undefined' ) { + thislocale = locale[ country ]; + } else { + thislocale = locale['default']; } - }); + var $postcodefield = thisform.find( '#billing_postcode_field, #shipping_postcode_field' ), + $cityfield = thisform.find( '#billing_city_field, #shipping_city_field' ), + $statefield = thisform.find( '#billing_state_field, #shipping_state_field' ); - var fieldsets = $('.woocommerce-billing-fields__field-wrapper, .woocommerce-shipping-fields__field-wrapper, .woocommerce-address-fields__field-wrapper, .woocommerce-additional-fields__field-wrapper .woocommerce-account-fields'); + if ( ! $postcodefield.attr( 'data-o_class' ) ) { + $postcodefield.attr( 'data-o_class', $postcodefield.attr( 'class' ) ); + $cityfield.attr( 'data-o_class', $cityfield.attr( 'class' ) ); + $statefield.attr( 'data-o_class', $statefield.attr( 'class' ) ); + } - fieldsets.each( function( index, fieldset ) { - var rows = $( fieldset ).find( '.form-row' ); - var wrapper = rows.first().parent(); + var locale_fields = $.parseJSON( wc_address_i18n_params.locale_fields ); - // Before sorting, ensure all fields have a priority for bW compatibility. - var last_priority = 0; + $.each( locale_fields, function( key, value ) { - rows.each( function() { - if ( ! $( this ).data( 'priority' ) ) { - $( this ).data( 'priority', last_priority + 1 ); + var field = thisform.find( value ); + + // Set to defaults. + if ( locale['default'][ key ] ) { + if ( 'state' !== key ) { + if ( typeof locale['default'][ key ].hidden === 'undefined' || locale['default'][ key ].hidden === false ) { + field.show(); + } else if ( locale['default'][ key ].hidden === true ) { + field.hide().find( 'input' ).val( '' ); + } + } + + if ( 'postcode' === key || 'city' === key || 'state' === key ) { + if ( locale['default'][ key ].label ) { + field.find( 'label' ).html( locale['default'][ key ].label ); + } + + if ( locale['default'][ key ].placeholder ) { + field.find( 'input' ).attr( 'placeholder', locale['default'][ key ].placeholder ); + } + } + + if ( locale['default'][ key ].required === true ) { + if ( field.find( 'label abbr' ).length === 0 ) { + field_is_required( field, true ); + } + } + + if ( locale['default'][ key ].priority ) { + field.data( 'priority', locale['default'][ key ].priority ); + } } - last_priority = $( this ).data( 'priority' ); - } ); - // Sort the fields. - rows.sort( function( a, b ) { - var asort = $( a ).data( 'priority' ), - bsort = $( b ).data( 'priority' ); + // Set to locale. + if ( thislocale[ key ] ) { + + if ( thislocale[ key ].label ) { + field.find( 'label' ).html( thislocale[ key ].label ); + } + + if ( thislocale[ key ].placeholder ) { + field.find( 'input' ).attr( 'placeholder', thislocale[ key ].placeholder ); + } + + field_is_required( field, false ); + + if ( typeof thislocale[ key ].required === 'undefined' && locale['default'][ key ].required === true ) { + field_is_required( field, true ); + } else if ( thislocale[ key ].required === true ) { + field_is_required( field, true ); + } + + if ( key !== 'state' ) { + if ( thislocale[ key ].hidden === true ) { + field.hide().find( 'input' ).val( '' ); + } else { + field.show(); + } + } + + if ( thislocale[ key ].priority ) { + field.data( 'priority', thislocale[ key ].priority ); + } else if ( locale['default'][ key ].priority ) { + field.data( 'priority', locale['default'][ key ].priority ); + } - if ( asort > bsort ) { - return 1; } - if ( asort < bsort ) { - return -1; - } - return 0; + }); - rows.detach().appendTo( wrapper ); - } ); - }); -}); + var fieldsets = $('.woocommerce-billing-fields__field-wrapper, .woocommerce-shipping-fields__field-wrapper, .woocommerce-address-fields__field-wrapper, .woocommerce-additional-fields__field-wrapper .woocommerce-account-fields'); + + fieldsets.each( function( index, fieldset ) { + var rows = $( fieldset ).find( '.form-row' ); + var wrapper = rows.first().parent(); + + // Before sorting, ensure all fields have a priority for bW compatibility. + var last_priority = 0; + + rows.each( function() { + if ( ! $( this ).data( 'priority' ) ) { + $( this ).data( 'priority', last_priority + 1 ); + } + last_priority = $( this ).data( 'priority' ); + } ); + + // Sort the fields. + rows.sort( function( a, b ) { + var asort = $( a ).data( 'priority' ), + bsort = $( b ).data( 'priority' ); + + if ( asort > bsort ) { + return 1; + } + if ( asort < bsort ) { + return -1; + } + return 0; + }); + + rows.detach().appendTo( wrapper ); + } ); + }); + }); diff --git a/assets/js/frontend/address-i18n.min.js b/assets/js/frontend/address-i18n.min.js index 18a1335d2b7..ec79e4f2bda 100644 --- a/assets/js/frontend/address-i18n.min.js +++ b/assets/js/frontend/address-i18n.min.js @@ -1 +1 @@ -jQuery(function(e){function a(e,a){a?(e.find("label").append(' *'),e.addClass("validate-required")):(e.find("label abbr").remove(),e.removeClass("validate-required"))}if("undefined"==typeof wc_address_i18n_params)return!1;var i=wc_address_i18n_params.locale.replace(/"/g,'"'),t=e.parseJSON(i);e(document.body).bind("country_to_state_changing",function(i,d,l){var r,o=l;r="undefined"!=typeof t[d]?t[d]:t["default"];var n=o.find("#billing_postcode_field, #shipping_postcode_field"),f=o.find("#billing_city_field, #shipping_city_field"),s=o.find("#billing_state_field, #shipping_state_field");n.attr("data-o_class")||(n.attr("data-o_class",n.attr("class")),f.attr("data-o_class",f.attr("class")),s.attr("data-o_class",s.attr("class")));var p=e.parseJSON(wc_address_i18n_params.locale_fields);e.each(p,function(e,i){var d=o.find(i);r[e]?(r[e].label&&d.find("label").html(r[e].label),r[e].placeholder?(d.find("input").attr("placeholder",r[e].placeholder),d.find(".select2-selection__placeholder").text(r[e].placeholder)):r[e].label&&!d.find("label").length&&(d.find("input").attr("placeholder",r[e].label),d.find(".select2-selection__placeholder").text(r[e].label)),a(d,!1),"undefined"==typeof r[e].required&&!0===t["default"][e].required?a(d,!0):!0===r[e].required&&a(d,!0),"state"!==e&&(!0===r[e].hidden?d.hide().find("input").val(""):d.show()),r[e].priority?d.data("priority",r[e].priority):t["default"][e].priority&&d.data("priority",t["default"][e].priority)):t["default"][e]&&("state"!==e&&("undefined"==typeof t["default"][e].hidden||!1===t["default"][e].hidden?d.show():!0===t["default"][e].hidden&&d.hide().find("input").val("")),"postcode"!==e&&"city"!==e&&"state"!==e||(t["default"][e].label&&d.find("label").html(t["default"][e].label),t["default"][e].placeholder&&d.find("input").attr("placeholder",t["default"][e].placeholder)),!0===t["default"][e].required&&0===d.find("label abbr").length&&a(d,!0),t["default"][e].priority&&d.data("priority",t["default"][e].priority))}),e(".woocommerce-billing-fields__field-wrapper, .woocommerce-shipping-fields__field-wrapper, .woocommerce-address-fields__field-wrapper, .woocommerce-additional-fields__field-wrapper .woocommerce-account-fields").each(function(a,i){var t=e(i).find(".form-row"),d=t.first().parent(),l=0;t.each(function(){e(this).data("priority")||e(this).data("priority",l+1),l=e(this).data("priority")}),t.sort(function(a,i){var t=e(a).data("priority"),d=e(i).data("priority");return t>d?1:t*'),e.addClass("validate-required")):(e.find("label abbr").remove(),e.removeClass("validate-required"))}if("undefined"==typeof wc_address_i18n_params)return!1;var i=wc_address_i18n_params.locale.replace(/"/g,'"'),t=e.parseJSON(i);e(document.body).bind("country_to_state_changing",function(i,d,r){var l,o=r;l="undefined"!=typeof t[d]?t[d]:t["default"];var n=o.find("#billing_postcode_field, #shipping_postcode_field"),f=o.find("#billing_city_field, #shipping_city_field"),s=o.find("#billing_state_field, #shipping_state_field");n.attr("data-o_class")||(n.attr("data-o_class",n.attr("class")),f.attr("data-o_class",f.attr("class")),s.attr("data-o_class",s.attr("class")));var p=e.parseJSON(wc_address_i18n_params.locale_fields);e.each(p,function(e,i){var d=o.find(i);t["default"][e]&&("state"!==e&&("undefined"==typeof t["default"][e].hidden||!1===t["default"][e].hidden?d.show():!0===t["default"][e].hidden&&d.hide().find("input").val("")),"postcode"!==e&&"city"!==e&&"state"!==e||(t["default"][e].label&&d.find("label").html(t["default"][e].label),t["default"][e].placeholder&&d.find("input").attr("placeholder",t["default"][e].placeholder)),!0===t["default"][e].required&&0===d.find("label abbr").length&&a(d,!0),t["default"][e].priority&&d.data("priority",t["default"][e].priority)),l[e]&&(l[e].label&&d.find("label").html(l[e].label),l[e].placeholder&&d.find("input").attr("placeholder",l[e].placeholder),a(d,!1),"undefined"==typeof l[e].required&&!0===t["default"][e].required?a(d,!0):!0===l[e].required&&a(d,!0),"state"!==e&&(!0===l[e].hidden?d.hide().find("input").val(""):d.show()),l[e].priority?d.data("priority",l[e].priority):t["default"][e].priority&&d.data("priority",t["default"][e].priority))}),e(".woocommerce-billing-fields__field-wrapper, .woocommerce-shipping-fields__field-wrapper, .woocommerce-address-fields__field-wrapper, .woocommerce-additional-fields__field-wrapper .woocommerce-account-fields").each(function(a,i){var t=e(i).find(".form-row"),d=t.first().parent(),r=0;t.each(function(){e(this).data("priority")||e(this).data("priority",r+1),r=e(this).data("priority")}),t.sort(function(a,i){var t=e(a).data("priority"),d=e(i).data("priority");return t>d?1:t Date: Wed, 20 Sep 2017 16:03:30 +0100 Subject: [PATCH 2/8] JSMIN --- assets/js/admin/wc-enhanced-select.min.js | 2 +- assets/js/frontend/price-slider.js | 2 +- assets/js/frontend/price-slider.min.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/assets/js/admin/wc-enhanced-select.min.js b/assets/js/admin/wc-enhanced-select.min.js index 6693b8d6bfd..75ee79d69d8 100644 --- a/assets/js/admin/wc-enhanced-select.min.js +++ b/assets/js/admin/wc-enhanced-select.min.js @@ -1 +1 @@ -jQuery(function(e){function t(){return{language:{errorLoading:function(){return wc_enhanced_select_params.i18n_searching},inputTooLong:function(e){var t=e.input.length-e.maximum;return 1===t?wc_enhanced_select_params.i18n_input_too_long_1:wc_enhanced_select_params.i18n_input_too_long_n.replace("%qty%",t)},inputTooShort:function(e){var t=e.minimum-e.input.length;return 1===t?wc_enhanced_select_params.i18n_input_too_short_1:wc_enhanced_select_params.i18n_input_too_short_n.replace("%qty%",t)},loadingMore:function(){return wc_enhanced_select_params.i18n_load_more},maximumSelected:function(e){return 1===e.maximum?wc_enhanced_select_params.i18n_selection_too_long_1:wc_enhanced_select_params.i18n_selection_too_long_n.replace("%qty%",e.maximum)},noResults:function(){return wc_enhanced_select_params.i18n_no_matches},searching:function(){return wc_enhanced_select_params.i18n_searching}}}}try{e(document.body).on("wc-enhanced-select-init",function(){e(":input.wc-enhanced-select, :input.chosen_select").filter(":not(.enhanced)").each(function(){var n=e.extend({minimumResultsForSearch:10,allowClear:!!e(this).data("allow_clear"),placeholder:e(this).data("placeholder")},t());e(this).selectWoo(n).addClass("enhanced")}),e(":input.wc-enhanced-select-nostd, :input.chosen_select_nostd").filter(":not(.enhanced)").each(function(){var n=e.extend({minimumResultsForSearch:10,allowClear:!0,placeholder:e(this).data("placeholder")},t());e(this).selectWoo(n).addClass("enhanced")}),e(":input.wc-product-search").filter(":not(.enhanced)").each(function(){var n={allowClear:!!e(this).data("allow_clear"),placeholder:e(this).data("placeholder"),minimumInputLength:e(this).data("minimum_input_length")?e(this).data("minimum_input_length"):"3",escapeMarkup:function(e){return e},ajax:{url:wc_enhanced_select_params.ajax_url,dataType:"json",delay:250,data:function(t){return{term:t.term,action:e(this).data("action")||"woocommerce_json_search_products_and_variations",security:wc_enhanced_select_params.search_products_nonce,exclude:e(this).data("exclude"),include:e(this).data("include"),limit:e(this).data("limit")}},processResults:function(t){var n=[];return t&&e.each(t,function(e,t){n.push({id:e,text:t})}),{results:n}},cache:!0}};if(n=e.extend(n,t()),e(this).selectWoo(n).addClass("enhanced"),e(this).data("sortable")){var a=e(this),c=e(this).next(".select2-container").find("ul.select2-selection__rendered");c.sortable({placeholder:"ui-state-highlight select2-selection__choice",forcePlaceholderSize:!0,items:"li:not(.select2-search__field)",tolerance:"pointer",stop:function(){e(c.find(".select2-selection__choice").get().reverse()).each(function(){var t=e(this).data("data").id,n=a.find('option[value="'+t+'"]')[0];a.prepend(n)})}})}else e(this).prop("multiple")&&e(this).on("change",function(){var t=e(this).children();t.sort(function(e,t){var n=e.text.toLowerCase(),a=t.text.toLowerCase();return n>a?1:na?1:n Date: Thu, 21 Sep 2017 20:50:45 -0700 Subject: [PATCH 3/8] Allow registration to redirect to same page Fixes #16889 --- includes/class-wc-form-handler.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/includes/class-wc-form-handler.php b/includes/class-wc-form-handler.php index 4636c927fc9..c8d6c0cd776 100644 --- a/includes/class-wc-form-handler.php +++ b/includes/class-wc-form-handler.php @@ -1086,7 +1086,15 @@ class WC_Form_Handler { wc_set_customer_auth_cookie( $new_customer ); } - wp_safe_redirect( apply_filters( 'woocommerce_registration_redirect', wp_get_referer() ? wp_get_referer() : wc_get_page_permalink( 'myaccount' ) ) ); + if ( ! empty( $_POST['redirect'] ) ) { + $redirect = $_POST['redirect']; + } elseif ( wc_get_raw_referer() ) { + $redirect = wc_get_raw_referer(); + } else { + $redirect = wc_get_page_permalink( 'myaccount' ); + } + + wp_redirect( wp_validate_redirect( apply_filters( 'woocommerce_registration_redirect', $redirect ), wc_get_page_permalink( 'myaccount' ) ) ); exit; } catch ( Exception $e ) { From b3f70bb7b565ad6e04910a2795fe8b5d6593ba7f Mon Sep 17 00:00:00 2001 From: claudiulodro Date: Fri, 22 Sep 2017 12:31:08 -0700 Subject: [PATCH 4/8] Make labels work on Cart page again --- assets/js/frontend/address-i18n.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/assets/js/frontend/address-i18n.js b/assets/js/frontend/address-i18n.js index e3a0b0596b1..14b90a90dde 100644 --- a/assets/js/frontend/address-i18n.js +++ b/assets/js/frontend/address-i18n.js @@ -88,6 +88,10 @@ jQuery( function( $ ) { if ( thislocale[ key ].placeholder ) { field.find( 'input' ).attr( 'placeholder', thislocale[ key ].placeholder ); + // Use the i18n label as a placeholder if there is no label element or i18n placeholder. + } else if ( thislocale[ key ].label && ! field.find( 'label' ).length ) { + field.find( 'input' ).attr( 'placeholder', thislocale[ key ].label ); + field.find( '.select2-selection__placeholder' ).text( thislocale[ key ].label ); } field_is_required( field, false ); From 877a8491ad50e65be3b7310c3c6143794230ce85 Mon Sep 17 00:00:00 2001 From: claudiulodro Date: Fri, 22 Sep 2017 14:14:00 -0700 Subject: [PATCH 5/8] Cleanup --- assets/js/frontend/address-i18n.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/assets/js/frontend/address-i18n.js b/assets/js/frontend/address-i18n.js index 14b90a90dde..a89d1072c7f 100644 --- a/assets/js/frontend/address-i18n.js +++ b/assets/js/frontend/address-i18n.js @@ -88,7 +88,9 @@ jQuery( function( $ ) { if ( thislocale[ key ].placeholder ) { field.find( 'input' ).attr( 'placeholder', thislocale[ key ].placeholder ); - // Use the i18n label as a placeholder if there is no label element or i18n placeholder. + field.find( '.select2-selection__placeholder' ).text( thislocale[ key ].placeholder ); + + // Use the i18n label as a placeholder if there is no label element and no i18n placeholder. } else if ( thislocale[ key ].label && ! field.find( 'label' ).length ) { field.find( 'input' ).attr( 'placeholder', thislocale[ key ].label ); field.find( '.select2-selection__placeholder' ).text( thislocale[ key ].label ); From b757f0db283875da0b0b54b77416dbdec1441898 Mon Sep 17 00:00:00 2001 From: claudiulodro Date: Fri, 22 Sep 2017 14:22:53 -0700 Subject: [PATCH 6/8] Fix #16868 on Cart page --- assets/js/frontend/address-i18n.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/assets/js/frontend/address-i18n.js b/assets/js/frontend/address-i18n.js index a89d1072c7f..4f7d6c7078a 100644 --- a/assets/js/frontend/address-i18n.js +++ b/assets/js/frontend/address-i18n.js @@ -65,7 +65,13 @@ jQuery( function( $ ) { if ( locale['default'][ key ].placeholder ) { field.find( 'input' ).attr( 'placeholder', locale['default'][ key ].placeholder ); + + // Use the label as a placeholder if there is no label element and no placeholder. + } else if ( locale['default'][ key ].label && ! field.find( 'label' ).length ) { + field.find( 'input' ).attr( 'placeholder', locale['default'][ key ].label ); + field.find( '.select2-selection__placeholder' ).text( locale['default'][ key ].label ); } + } if ( locale['default'][ key ].required === true ) { From fa9bef7ce4eca0a58043f3608a3b8284b182e5b9 Mon Sep 17 00:00:00 2001 From: claudiulodro Date: Fri, 22 Sep 2017 14:24:10 -0700 Subject: [PATCH 7/8] Minify --- assets/js/frontend/address-i18n.min.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets/js/frontend/address-i18n.min.js b/assets/js/frontend/address-i18n.min.js index ec79e4f2bda..bbedbd43350 100644 --- a/assets/js/frontend/address-i18n.min.js +++ b/assets/js/frontend/address-i18n.min.js @@ -1 +1 @@ -jQuery(function(e){function a(e,a){a?(e.find("label").append(' *'),e.addClass("validate-required")):(e.find("label abbr").remove(),e.removeClass("validate-required"))}if("undefined"==typeof wc_address_i18n_params)return!1;var i=wc_address_i18n_params.locale.replace(/"/g,'"'),t=e.parseJSON(i);e(document.body).bind("country_to_state_changing",function(i,d,r){var l,o=r;l="undefined"!=typeof t[d]?t[d]:t["default"];var n=o.find("#billing_postcode_field, #shipping_postcode_field"),f=o.find("#billing_city_field, #shipping_city_field"),s=o.find("#billing_state_field, #shipping_state_field");n.attr("data-o_class")||(n.attr("data-o_class",n.attr("class")),f.attr("data-o_class",f.attr("class")),s.attr("data-o_class",s.attr("class")));var p=e.parseJSON(wc_address_i18n_params.locale_fields);e.each(p,function(e,i){var d=o.find(i);t["default"][e]&&("state"!==e&&("undefined"==typeof t["default"][e].hidden||!1===t["default"][e].hidden?d.show():!0===t["default"][e].hidden&&d.hide().find("input").val("")),"postcode"!==e&&"city"!==e&&"state"!==e||(t["default"][e].label&&d.find("label").html(t["default"][e].label),t["default"][e].placeholder&&d.find("input").attr("placeholder",t["default"][e].placeholder)),!0===t["default"][e].required&&0===d.find("label abbr").length&&a(d,!0),t["default"][e].priority&&d.data("priority",t["default"][e].priority)),l[e]&&(l[e].label&&d.find("label").html(l[e].label),l[e].placeholder&&d.find("input").attr("placeholder",l[e].placeholder),a(d,!1),"undefined"==typeof l[e].required&&!0===t["default"][e].required?a(d,!0):!0===l[e].required&&a(d,!0),"state"!==e&&(!0===l[e].hidden?d.hide().find("input").val(""):d.show()),l[e].priority?d.data("priority",l[e].priority):t["default"][e].priority&&d.data("priority",t["default"][e].priority))}),e(".woocommerce-billing-fields__field-wrapper, .woocommerce-shipping-fields__field-wrapper, .woocommerce-address-fields__field-wrapper, .woocommerce-additional-fields__field-wrapper .woocommerce-account-fields").each(function(a,i){var t=e(i).find(".form-row"),d=t.first().parent(),r=0;t.each(function(){e(this).data("priority")||e(this).data("priority",r+1),r=e(this).data("priority")}),t.sort(function(a,i){var t=e(a).data("priority"),d=e(i).data("priority");return t>d?1:t*'),e.addClass("validate-required")):(e.find("label abbr").remove(),e.removeClass("validate-required"))}if("undefined"==typeof wc_address_i18n_params)return!1;var t=wc_address_i18n_params.locale.replace(/"/g,'"'),i=e.parseJSON(t);e(document.body).bind("country_to_state_changing",function(t,l,d){var r,n=d;r="undefined"!=typeof i[l]?i[l]:i["default"];var o=n.find("#billing_postcode_field, #shipping_postcode_field"),f=n.find("#billing_city_field, #shipping_city_field"),s=n.find("#billing_state_field, #shipping_state_field");o.attr("data-o_class")||(o.attr("data-o_class",o.attr("class")),f.attr("data-o_class",f.attr("class")),s.attr("data-o_class",s.attr("class")));var p=e.parseJSON(wc_address_i18n_params.locale_fields);e.each(p,function(e,t){var l=n.find(t);i["default"][e]&&("state"!==e&&("undefined"==typeof i["default"][e].hidden||!1===i["default"][e].hidden?l.show():!0===i["default"][e].hidden&&l.hide().find("input").val("")),"postcode"!==e&&"city"!==e&&"state"!==e||(i["default"][e].label&&l.find("label").html(i["default"][e].label),i["default"][e].placeholder?l.find("input").attr("placeholder",i["default"][e].placeholder):i["default"][e].label&&!l.find("label").length&&(l.find("input").attr("placeholder",i["default"][e].label),l.find(".select2-selection__placeholder").text(i["default"][e].label))),!0===i["default"][e].required&&0===l.find("label abbr").length&&a(l,!0),i["default"][e].priority&&l.data("priority",i["default"][e].priority)),r[e]&&(r[e].label&&l.find("label").html(r[e].label),r[e].placeholder?(l.find("input").attr("placeholder",r[e].placeholder),l.find(".select2-selection__placeholder").text(r[e].placeholder)):r[e].label&&!l.find("label").length&&(l.find("input").attr("placeholder",r[e].label),l.find(".select2-selection__placeholder").text(r[e].label)),a(l,!1),"undefined"==typeof r[e].required&&!0===i["default"][e].required?a(l,!0):!0===r[e].required&&a(l,!0),"state"!==e&&(!0===r[e].hidden?l.hide().find("input").val(""):l.show()),r[e].priority?l.data("priority",r[e].priority):i["default"][e].priority&&l.data("priority",i["default"][e].priority))}),e(".woocommerce-billing-fields__field-wrapper, .woocommerce-shipping-fields__field-wrapper, .woocommerce-address-fields__field-wrapper, .woocommerce-additional-fields__field-wrapper .woocommerce-account-fields").each(function(a,t){var i=e(t).find(".form-row"),l=i.first().parent(),d=0;i.each(function(){e(this).data("priority")||e(this).data("priority",d+1),d=e(this).data("priority")}),i.sort(function(a,t){var i=e(a).data("priority"),l=e(t).data("priority");return i>l?1:i Date: Fri, 22 Sep 2017 20:52:38 -0700 Subject: [PATCH 8/8] sanitize _POST --- includes/class-wc-form-handler.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/class-wc-form-handler.php b/includes/class-wc-form-handler.php index c8d6c0cd776..d61c8d3cca4 100644 --- a/includes/class-wc-form-handler.php +++ b/includes/class-wc-form-handler.php @@ -1087,7 +1087,7 @@ class WC_Form_Handler { } if ( ! empty( $_POST['redirect'] ) ) { - $redirect = $_POST['redirect']; + $redirect = wp_sanitize_redirect( $_POST['redirect'] ); } elseif ( wc_get_raw_referer() ) { $redirect = wc_get_raw_referer(); } else {