Merge branch 'master' into fix/20218-clearer-friendly-names

This commit is contained in:
Mike Jolley 2018-06-14 16:12:53 +01:00
commit 2c8106075a
148 changed files with 12980 additions and 9953 deletions

View File

@ -44,10 +44,11 @@ https://woocommerce.com/contact-us/
## Coding Guidelines
- **Ensure you stick to the [WordPress Coding Standards](https://make.wordpress.org/core/handbook/coding-standards/php/)**
- **Ensure you stick to the [WordPress Coding Standards](https://make.wordpress.org/core/handbook/best-practices/coding-standards/php/)**
- Install our pre-commit hook using composer. It'll help with the Coding Standards. To install run `composer install` from the command line within the woocommerce plugin directory.
- Ensure you use LF line endings in your code editor. Use [EditorConfig](http://editorconfig.org/) if your editor supports it so that indentation, line endings and other settings are auto configured.
- When committing, reference your issue number (#1234) and include a note about the fix.
- Ensure that your code is compatible with PHP 5.2+.
- Push the changes to your fork and submit a pull request on the master branch of the WooCommerce repository. Existing maintenance branches will be maintained by WooCommerce developers.
Please **don't** modify the changelog or update the .pot files. These will be maintained by the WooCommerce team.

3
.gitignore vendored
View File

@ -46,3 +46,6 @@ tests/cli/vendor
# Composer
/vendor/
contributors.md
# Screenshots for e2e tests failures
/screenshots/

View File

@ -1,5 +1,33 @@
== Changelog ==
= 3.4.1 - 2018-05-29 =
* Fix - Fix webhook admin filtering URLs. #20236
* Fix - Add missing wp_unslash calls to product data meta box to prevent quote characters being escaped on save. #20235
* Fix - Display price filter widget in LTR mode on RTL sites. #20221
* Fix - Refactor WC_Coupon constructor to allow for passing in coupon objects. #20193
* Fix - Path field in advanced CSV importer was broken due to an esc_url call. #20191
* Fix - Prevent shipping method instances trying to save settings on non-instance screens. #20217
* Fix - Wrapper function to get full mysql version string with mariadb handling. #20231
* Fix - woocommerce_pagination had some extra white space. #20214
* Fix - If a file size cannot be read, ignore range headers to prevent offsite downloads being 0kb. #20205
* Fix - Allow HTML when using `wc_attribute_label()`. #20202
* Fix - Update address-i18n.js to prevent appending multiple "(optional)" labels. #20195
* Fix - Check plugin properties exist when listening to auto_update_plugin hook. #20234
* Fix - Add extra checks in `get_canonical_package_rate_ids` to prevent notices. #20237
* Fix - Fix infinite loop with importing tax rates. #20253
* Fix - Echo attribute label for "empty" default option. #20256
* Fix - Fix download sample tax rates URL format. #20272
* Fix - Product properties should not be accessed directly PHP notice when calling `wc_get_product_attachment_props`. #20282
* Fix - If flexslider is disabled, gallery images also need to trigger photoswipe on click. #20290
* Fix - Product import file uploads on windows servers. #20273
* Fix - Fix variation attribute selection via the cart page/query string. #20293
* Fix - Add greater specificity to required styling in 2017 theme. #20296
* Enhancement - Export legacy paypal meta data in personal data exporter. #20200
* Enhancement - Improve performance of `wc_update_340_states` update routine to help prevent timeouts. #20241
* Dev - Remove red styling for PHP notice if using > 5.6. #20294
* Dev - Add an action hook after printing the cart item name. #20190
* Localization - Use "payment tokens" terminology in exports. #20197
= 3.4.0 - 2018-05-23 =
* Feature - GDPR: Tools to export WooCommerce data using the new export functionality in WordPress 4.9.6. #19330
* Feature - GDPR: Tools to bulk anonymize order data in admin. #19330

View File

@ -101,16 +101,9 @@ module.exports = function( grunt ) {
ext: '.min.js'
}]
},
simplify_commerce: {
flexslider: {
files: [{
expand: true,
cwd: 'includes/gateways/simplify-commerce/assets/js/',
src: [
'*.js',
'!*.min.js'
],
dest: 'includes/gateways/simplify-commerce/assets/js/',
ext: '.min.js'
'<%= dirs.js %>/flexslider/jquery.flexslider.min.js': ['<%= dirs.js %>/flexslider/jquery.flexslider.js']
}]
}
},
@ -284,12 +277,11 @@ module.exports = function( grunt ) {
{
config: 'authToken',
type: 'input',
message: '(optional) Provide a personal access token. This will allow 5000 requests per hour rather than 60 - use if nothing is generated.',
default: ''
message: '(optional) Provide a personal access token. This will allow 5000 requests per hour rather than 60 - use if nothing is generated.'
}
]
}
},
}
},
// Clean the directory.
@ -367,7 +359,8 @@ module.exports = function( grunt ) {
grunt.registerTask( 'js', [
'jshint',
'uglify:admin',
'uglify:frontend'
'uglify:frontend',
'uglify:flexslider'
]);
grunt.registerTask( 'css', [

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -64,6 +64,22 @@
.loader {
@include loader();
}
form .form-row {
.required {
color: firebrick;
text-decoration: none;
visibility: hidden; // Only show optional by default.
&[title] {
border: 0 !important;
}
}
.optional {
visibility: visible;
}
}
}
.woocommerce-breadcrumb {
@ -137,20 +153,6 @@
}
}
.required {
color: firebrick;
text-decoration: none;
visibility: hidden; // Only show optional by default.
&[title] {
border: 0 !important;
}
}
.optional {
visibility: visible;
}
.woocommerce-message,
.woocommerce-error,
.woocommerce-info {
@ -411,8 +413,8 @@ table.variations {
.flex-control-thumbs {
li {
list-style: none;
float: left;
cursor: pointer;
float: left;
}
img {
@ -427,6 +429,8 @@ table.variations {
img {
display: block;
width: 100%;
height: auto;
}
}
@ -810,19 +814,43 @@ table.variations {
}
}
.cart_totals {
th, td {
vertical-align: top;
padding: 1em 0;
line-height: 1.5em;
}
th {
padding-right: 1em;
}
.woocommerce-shipping-destination {
margin-bottom: 0;
}
}
.shipping-calculator-button {
margin-top: .5em;
display: inline-block;
}
.shipping-calculator-form {
margin: 1em 0 0 0;
}
#shipping_method {
list-style: none;
margin-top: 1em;
margin: 0;
li {
margin-bottom: .5em;
input {
float: left;
margin-top: 0.17em;
}
label {
line-height: 1.15;
line-height: 1.5em;
}
}
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1058,12 +1058,14 @@ p.demo_store,
th {
font-weight: 700;
padding: 9px 12px;
line-height: 1.5em;
}
td {
border-top: 1px solid rgba(0, 0, 0, 0.1);
padding: 6px 12px;
padding: 9px 12px;
vertical-align: middle;
line-height: 1.5em;
small {
font-weight: normal;
@ -1404,12 +1406,12 @@ p.demo_store,
padding: 0;
li {
margin: 0;
padding: 0.25em 0 0.25em 22px;
text-indent: -22px;
margin: 0 0 .5em;
line-height: 1.5em;
list-style: none outside;
input {
margin: 3px 0.5ex;
margin: 3px 0.4375em 0 0;
vertical-align: top;
}
label {
display: inline;
@ -1711,8 +1713,11 @@ p.demo_store,
/**
* Right to left styles
*/
.rtl.woocommerce div.product div.images .flex-control-thumbs li {
float: right;
.rtl.woocommerce .price_label,
.rtl.woocommerce .price_label span {
/* rtl:ignore */
direction: ltr;
unicode-bidi: embed;
}
.woocommerce-message {
@ -1841,16 +1846,18 @@ p.demo_store,
}
.cart-collaterals {
.shipping_calculator {
.button {
width: 100%;
float: none;
display: block;
}
.shipping-calculator-button {
float: none;
margin-top: .5em;
display: inline-block;
}
.shipping-calculator-button::after {
@include iconafter( '\e019' );
}
.shipping-calculator-button::after {
@include iconafter( '\e019' );
}
.shipping-calculator-form {
margin: 1em 0 0 0;
}
.cart_totals {
@ -1872,7 +1879,7 @@ p.demo_store,
}
th {
width: 40%;
width: 35%;
}
td,
@ -1900,6 +1907,9 @@ p.demo_store,
tr th {
border-top: 1px solid $secondary;
}
.woocommerce-shipping-destination {
margin-bottom: 0;
}
}
.cross-sells ul.products li.product {

File diff suppressed because one or more lines are too long

View File

@ -129,6 +129,6 @@ jQuery(function( $ ) {
});
$( '#wpbody' ).on( 'click', '.trash-product', function() {
return window.confirm( woocommerce_admin.i18_delete_product_notice );
return window.confirm( woocommerce_admin.i18n_delete_product_notice );
});
});

View File

@ -1,127 +1,172 @@
/* global woocommerce_settings_params */
( function( $ ) {
/* global woocommerce_settings_params, wp */
( function( $, params, wp ) {
$( function() {
// Sell Countries
$( 'select#woocommerce_allowed_countries' ).change( function() {
if ( 'specific' === $( this ).val() ) {
$( this ).closest('tr').next( 'tr' ).hide();
$( this ).closest('tr').next().next( 'tr' ).show();
} else if ( 'all_except' === $( this ).val() ) {
$( this ).closest('tr').next( 'tr' ).show();
$( this ).closest('tr').next().next( 'tr' ).hide();
} else {
$( this ).closest('tr').next( 'tr' ).hide();
$( this ).closest('tr').next().next( 'tr' ).hide();
}
}).change();
// Sell Countries
$( 'select#woocommerce_allowed_countries' ).change( function() {
if ( 'specific' === $( this ).val() ) {
$( this ).closest('tr').next( 'tr' ).hide();
$( this ).closest('tr').next().next( 'tr' ).show();
} else if ( 'all_except' === $( this ).val() ) {
$( this ).closest('tr').next( 'tr' ).show();
$( this ).closest('tr').next().next( 'tr' ).hide();
} else {
$( this ).closest('tr').next( 'tr' ).hide();
$( this ).closest('tr').next().next( 'tr' ).hide();
}
}).change();
// Ship Countries
$( 'select#woocommerce_ship_to_countries' ).change( function() {
if ( 'specific' === $( this ).val() ) {
$( this ).closest('tr').next( 'tr' ).show();
} else {
$( this ).closest('tr').next( 'tr' ).hide();
}
}).change();
// Ship Countries
$( 'select#woocommerce_ship_to_countries' ).change( function() {
if ( 'specific' === $( this ).val() ) {
$( this ).closest('tr').next( 'tr' ).show();
} else {
$( this ).closest('tr').next( 'tr' ).hide();
}
}).change();
// Stock management
$( 'input#woocommerce_manage_stock' ).change( function() {
if ( $( this ).is(':checked') ) {
$( this ).closest('tbody').find( '.manage_stock_field' ).closest( 'tr' ).show();
} else {
$( this ).closest('tbody').find( '.manage_stock_field' ).closest( 'tr' ).hide();
}
}).change();
// Stock management
$( 'input#woocommerce_manage_stock' ).change( function() {
if ( $( this ).is(':checked') ) {
$( this ).closest('tbody').find( '.manage_stock_field' ).closest( 'tr' ).show();
} else {
$( this ).closest('tbody').find( '.manage_stock_field' ).closest( 'tr' ).hide();
}
}).change();
// Color picker
$( '.colorpick' )
// Color picker
$( '.colorpick' )
.iris({
change: function( event, ui ) {
$( this ).parent().find( '.colorpickpreview' ).css({ backgroundColor: ui.color.toString() });
},
hide: true,
border: true
})
.iris({
change: function( event, ui ) {
$( this ).parent().find( '.colorpickpreview' ).css({ backgroundColor: ui.color.toString() });
},
hide: true,
border: true
})
.on( 'click focus', function( event ) {
event.stopPropagation();
$( '.iris-picker' ).hide();
$( this ).closest( 'td' ).find( '.iris-picker' ).show();
$( this ).data( 'original-value', $( this ).val() );
})
.on( 'click focus', function( event ) {
event.stopPropagation();
.on( 'change', function() {
if ( $( this ).is( '.iris-error' ) ) {
var original_value = $( this ).data( 'original-value' );
if ( original_value.match( /^\#([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$/ ) ) {
$( this ).val( $( this ).data( 'original-value' ) ).change();
} else {
$( this ).val( '' ).change();
}
}
});
$( 'body' ).on( 'click', function() {
$( '.iris-picker' ).hide();
$( this ).closest( 'td' ).find( '.iris-picker' ).show();
$( this ).data( 'original-value', $( this ).val() );
})
});
.on( 'change', function() {
if ( $( this ).is( '.iris-error' ) ) {
var original_value = $( this ).data( 'original-value' );
// Edit prompt
$( function() {
var changed = false;
if ( original_value.match( /^\#([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$/ ) ) {
$( this ).val( $( this ).data( 'original-value' ) ).change();
$( 'input, textarea, select, checkbox' ).change( function() {
changed = true;
});
$( '.woo-nav-tab-wrapper a' ).click( function() {
if ( changed ) {
window.onbeforeunload = function() {
return params.i18n_nav_warning;
};
} else {
$( this ).val( '' ).change();
window.onbeforeunload = '';
}
});
$( '.submit :input' ).click( function() {
window.onbeforeunload = '';
});
});
// Sorting
$( 'table.wc_gateways tbody, table.wc_shipping tbody' ).sortable({
items: 'tr',
cursor: 'move',
axis: 'y',
handle: 'td.sort',
scrollSensitivity: 40,
helper: function( event, ui ) {
ui.children().each( function() {
$( this ).width( $( this ).width() );
});
ui.css( 'left', '0' );
return ui;
},
start: function( event, ui ) {
ui.item.css( 'background-color', '#f6f6f6' );
},
stop: function( event, ui ) {
ui.item.removeAttr( 'style' );
ui.item.trigger( 'updateMoveButtons' );
}
});
// Select all/none
$( '.woocommerce' ).on( 'click', '.select_all', function() {
$( this ).closest( 'td' ).find( 'select option' ).attr( 'selected', 'selected' );
$( this ).closest( 'td' ).find( 'select' ).trigger( 'change' );
return false;
});
$( '.woocommerce' ).on( 'click', '.select_none', function() {
$( this ).closest( 'td' ).find( 'select option' ).removeAttr( 'selected' );
$( this ).closest( 'td' ).find( 'select' ).trigger( 'change' );
return false;
});
// Re-order buttons.
$( '.wc-item-reorder-nav').find( '.wc-move-up, .wc-move-down' ).on( 'click', function() {
var moveBtn = $( this ),
$row = moveBtn.closest( 'tr' );
moveBtn.focus();
var isMoveUp = moveBtn.is( '.wc-move-up' ),
isMoveDown = moveBtn.is( '.wc-move-down' );
if ( isMoveUp ) {
var $previewRow = $row.prev( 'tr' );
if ( $previewRow && $previewRow.length ) {
$previewRow.before( $row );
wp.a11y.speak( params.i18n_moved_up );
}
} else if ( isMoveDown ) {
var $nextRow = $row.next( 'tr' );
if ( $nextRow && $nextRow.length ) {
$nextRow.after( $row );
wp.a11y.speak( params.i18n_moved_down );
}
}
});
$( 'body' ).on( 'click', function() {
$( '.iris-picker' ).hide();
moveBtn.focus(); // Re-focus after the container was moved.
moveBtn.closest( 'table' ).trigger( 'updateMoveButtons' );
} );
$( '.wc-item-reorder-nav').closest( 'table' ).on( 'updateMoveButtons', function() {
var table = $( this ),
lastRow = $( this ).find( 'tbody tr:last' ),
firstRow = $( this ).find( 'tbody tr:first' );
table.find( '.wc-item-reorder-nav .wc-move-disabled' ).removeClass( 'wc-move-disabled' ).attr( { 'tabindex': '0', 'aria-hidden': 'false' } );
firstRow.find( '.wc-item-reorder-nav .wc-move-up' ).addClass( 'wc-move-disabled' ).attr( { 'tabindex': '-1', 'aria-hidden': 'true' } );
lastRow.find( '.wc-item-reorder-nav .wc-move-down' ).addClass( 'wc-move-disabled' ).attr( { 'tabindex': '-1', 'aria-hidden': 'true' } );
} );
$( '.wc-item-reorder-nav').closest( 'table' ).trigger( 'updateMoveButtons' );
});
// Edit prompt
$( function() {
var changed = false;
$( 'input, textarea, select, checkbox' ).change( function() {
changed = true;
});
$( '.woo-nav-tab-wrapper a' ).click( function() {
if ( changed ) {
window.onbeforeunload = function() {
return woocommerce_settings_params.i18n_nav_warning;
};
} else {
window.onbeforeunload = '';
}
});
$( '.submit input' ).click( function() {
window.onbeforeunload = '';
});
});
// Sorting
$( 'table.wc_gateways tbody, table.wc_shipping tbody' ).sortable({
items: 'tr',
cursor: 'move',
axis: 'y',
handle: 'td.sort',
scrollSensitivity: 40,
helper: function( event, ui ) {
ui.children().each( function() {
$( this ).width( $( this ).width() );
});
ui.css( 'left', '0' );
return ui;
},
start: function( event, ui ) {
ui.item.css( 'background-color', '#f6f6f6' );
},
stop: function( event, ui ) {
ui.item.removeAttr( 'style' );
}
});
// Select all/none
$( '.woocommerce' ).on( 'click', '.select_all', function() {
$( this ).closest( 'td' ).find( 'select option' ).attr( 'selected', 'selected' );
$( this ).closest( 'td' ).find( 'select' ).trigger( 'change' );
return false;
});
$( '.woocommerce' ).on( 'click', '.select_none', function() {
$( this ).closest( 'td' ).find( 'select option' ).removeAttr( 'selected' );
$( this ).closest( 'td' ).find( 'select' ).trigger( 'change' );
return false;
});
})( jQuery );
})( jQuery, woocommerce_settings_params, wp );

View File

@ -1 +1 @@
!function(t){t("select#woocommerce_allowed_countries").change(function(){"specific"===t(this).val()?(t(this).closest("tr").next("tr").hide(),t(this).closest("tr").next().next("tr").show()):"all_except"===t(this).val()?(t(this).closest("tr").next("tr").show(),t(this).closest("tr").next().next("tr").hide()):(t(this).closest("tr").next("tr").hide(),t(this).closest("tr").next().next("tr").hide())}).change(),t("select#woocommerce_ship_to_countries").change(function(){"specific"===t(this).val()?t(this).closest("tr").next("tr").show():t(this).closest("tr").next("tr").hide()}).change(),t("input#woocommerce_manage_stock").change(function(){t(this).is(":checked")?t(this).closest("tbody").find(".manage_stock_field").closest("tr").show():t(this).closest("tbody").find(".manage_stock_field").closest("tr").hide()}).change(),t(".colorpick").iris({change:function(e,i){t(this).parent().find(".colorpickpreview").css({backgroundColor:i.color.toString()})},hide:!0,border:!0}).on("click focus",function(e){e.stopPropagation(),t(".iris-picker").hide(),t(this).closest("td").find(".iris-picker").show(),t(this).data("original-value",t(this).val())}).on("change",function(){t(this).is(".iris-error")&&(t(this).data("original-value").match(/^\#([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$/)?t(this).val(t(this).data("original-value")).change():t(this).val("").change())}),t("body").on("click",function(){t(".iris-picker").hide()}),t(function(){var e=!1;t("input, textarea, select, checkbox").change(function(){e=!0}),t(".woo-nav-tab-wrapper a").click(function(){window.onbeforeunload=e?function(){return woocommerce_settings_params.i18n_nav_warning}:""}),t(".submit input").click(function(){window.onbeforeunload=""})}),t("table.wc_gateways tbody, table.wc_shipping tbody").sortable({items:"tr",cursor:"move",axis:"y",handle:"td.sort",scrollSensitivity:40,helper:function(e,i){return i.children().each(function(){t(this).width(t(this).width())}),i.css("left","0"),i},start:function(t,e){e.item.css("background-color","#f6f6f6")},stop:function(t,e){e.item.removeAttr("style")}}),t(".woocommerce").on("click",".select_all",function(){return t(this).closest("td").find("select option").attr("selected","selected"),t(this).closest("td").find("select").trigger("change"),!1}),t(".woocommerce").on("click",".select_none",function(){return t(this).closest("td").find("select option").removeAttr("selected"),t(this).closest("td").find("select").trigger("change"),!1})}(jQuery);
!function(t,e,i){t(function(){t("select#woocommerce_allowed_countries").change(function(){"specific"===t(this).val()?(t(this).closest("tr").next("tr").hide(),t(this).closest("tr").next().next("tr").show()):"all_except"===t(this).val()?(t(this).closest("tr").next("tr").show(),t(this).closest("tr").next().next("tr").hide()):(t(this).closest("tr").next("tr").hide(),t(this).closest("tr").next().next("tr").hide())}).change(),t("select#woocommerce_ship_to_countries").change(function(){"specific"===t(this).val()?t(this).closest("tr").next("tr").show():t(this).closest("tr").next("tr").hide()}).change(),t("input#woocommerce_manage_stock").change(function(){t(this).is(":checked")?t(this).closest("tbody").find(".manage_stock_field").closest("tr").show():t(this).closest("tbody").find(".manage_stock_field").closest("tr").hide()}).change(),t(".colorpick").iris({change:function(e,i){t(this).parent().find(".colorpickpreview").css({backgroundColor:i.color.toString()})},hide:!0,border:!0}).on("click focus",function(e){e.stopPropagation(),t(".iris-picker").hide(),t(this).closest("td").find(".iris-picker").show(),t(this).data("original-value",t(this).val())}).on("change",function(){t(this).is(".iris-error")&&(t(this).data("original-value").match(/^\#([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$/)?t(this).val(t(this).data("original-value")).change():t(this).val("").change())}),t("body").on("click",function(){t(".iris-picker").hide()}),t(function(){var i=!1;t("input, textarea, select, checkbox").change(function(){i=!0}),t(".woo-nav-tab-wrapper a").click(function(){window.onbeforeunload=i?function(){return e.i18n_nav_warning}:""}),t(".submit :input").click(function(){window.onbeforeunload=""})}),t("table.wc_gateways tbody, table.wc_shipping tbody").sortable({items:"tr",cursor:"move",axis:"y",handle:"td.sort",scrollSensitivity:40,helper:function(e,i){return i.children().each(function(){t(this).width(t(this).width())}),i.css("left","0"),i},start:function(t,e){e.item.css("background-color","#f6f6f6")},stop:function(t,e){e.item.removeAttr("style"),e.item.trigger("updateMoveButtons")}}),t(".woocommerce").on("click",".select_all",function(){return t(this).closest("td").find("select option").attr("selected","selected"),t(this).closest("td").find("select").trigger("change"),!1}),t(".woocommerce").on("click",".select_none",function(){return t(this).closest("td").find("select option").removeAttr("selected"),t(this).closest("td").find("select").trigger("change"),!1}),t(".wc-item-reorder-nav").find(".wc-move-up, .wc-move-down").on("click",function(){var o=t(this),s=o.closest("tr");o.focus();var n=o.is(".wc-move-up"),c=o.is(".wc-move-down");if(n){var r=s.prev("tr");r&&r.length&&(r.before(s),i.a11y.speak(e.i18n_moved_up))}else if(c){var a=s.next("tr");a&&a.length&&(a.after(s),i.a11y.speak(e.i18n_moved_down))}o.focus(),o.closest("table").trigger("updateMoveButtons")}),t(".wc-item-reorder-nav").closest("table").on("updateMoveButtons",function(){var e=t(this),i=t(this).find("tbody tr:last"),o=t(this).find("tbody tr:first");e.find(".wc-item-reorder-nav .wc-move-disabled").removeClass("wc-move-disabled").attr({tabindex:"0","aria-hidden":"false"}),o.find(".wc-item-reorder-nav .wc-move-up").addClass("wc-move-disabled").attr({tabindex:"-1","aria-hidden":"true"}),i.find(".wc-item-reorder-nav .wc-move-down").addClass("wc-move-disabled").attr({tabindex:"-1","aria-hidden":"true"})}),t(".wc-item-reorder-nav").closest("table").trigger("updateMoveButtons")})}(jQuery,woocommerce_settings_params,wp);

View File

@ -138,8 +138,9 @@
var $tr = view.$el.find( 'tr[data-id="' + rowData.instance_id + '"]');
if ( ! rowData.has_settings ) {
$tr.find( '.wc-shipping-zone-method-title a').replaceWith( $tr.find( '.wc-shipping-zone-method-title' ).text() );
$tr.find( '.wc-shipping-zone-method-settings' ).remove();
$tr.find( '.wc-shipping-zone-method-title > a' ).replaceWith('<span>' + $tr.find( '.wc-shipping-zone-method-title > a' ).text() + '</span>' );
var $del = $tr.find( '.wc-shipping-zone-method-delete' );
$tr.find( '.wc-shipping-zone-method-title .row-actions' ).empty().html($del);
}
} );

File diff suppressed because one or more lines are too long

View File

@ -1,338 +1,346 @@
/* global woocommerce_admin */
jQuery( function ( $ ) {
if ( 'undefined' === typeof woocommerce_admin ) {
return;
}
// Add buttons to product screen.
var $product_screen = $( '.edit-php.post-type-product' ),
$title_action = $product_screen.find( '.page-title-action:first' ),
$blankslate = $product_screen.find( '.woocommerce-BlankState' );
if ( 0 === $blankslate.length ) {
if ( woocommerce_admin.urls.export_products ) {
$title_action.after('<a href="' + woocommerce_admin.urls.export_products + '" class="page-title-action">' + woocommerce_admin.strings.export_products + '</a>');
( function( $, woocommerce_admin ) {
$( function() {
if ( 'undefined' === typeof woocommerce_admin ) {
return;
}
if ( woocommerce_admin.urls.import_products ) {
$title_action.after( '<a href="' + woocommerce_admin.urls.import_products + '" class="page-title-action">' + woocommerce_admin.strings.import_products + '</a>' );
// Add buttons to product screen.
var $product_screen = $( '.edit-php.post-type-product' ),
$title_action = $product_screen.find( '.page-title-action:first' ),
$blankslate = $product_screen.find( '.woocommerce-BlankState' );
if ( 0 === $blankslate.length ) {
if ( woocommerce_admin.urls.export_products ) {
$title_action.after('<a href="' + woocommerce_admin.urls.export_products + '" class="page-title-action">' + woocommerce_admin.strings.export_products + '</a>');
}
if ( woocommerce_admin.urls.import_products ) {
$title_action.after( '<a href="' + woocommerce_admin.urls.import_products + '" class="page-title-action">' + woocommerce_admin.strings.import_products + '</a>' );
}
} else {
$title_action.hide();
}
} else {
$title_action.hide();
}
// Progress indicators when showing steps.
$( '.woocommerce-progress-form-wrapper .button-next' ).on( 'click', function() {
$('.wc-progress-form-content').block({
message: null,
overlayCSS: {
background: '#fff',
opacity: 0.6
}
});
return true;
} );
// Progress indicators when showing steps.
$( '.woocommerce-progress-form-wrapper .button-next' ).on( 'click', function() {
$('.wc-progress-form-content').block({
message: null,
overlayCSS: {
background: '#fff',
opacity: 0.6
}
});
return true;
} );
// Field validation error tips
$( document.body )
// Field validation error tips
$( document.body )
.on( 'wc_add_error_tip', function( e, element, error_type ) {
var offset = element.position();
.on( 'wc_add_error_tip', function( e, element, error_type ) {
var offset = element.position();
if ( element.parent().find( '.wc_error_tip' ).length === 0 ) {
element.after( '<div class="wc_error_tip ' + error_type + '">' + woocommerce_admin[error_type] + '</div>' );
element.parent().find( '.wc_error_tip' )
.css( 'left', offset.left + element.width() - ( element.width() / 2 ) - ( $( '.wc_error_tip' ).width() / 2 ) )
.css( 'top', offset.top + element.height() )
.fadeIn( '100' );
}
})
if ( element.parent().find( '.wc_error_tip' ).length === 0 ) {
element.after( '<div class="wc_error_tip ' + error_type + '">' + woocommerce_admin[error_type] + '</div>' );
element.parent().find( '.wc_error_tip' )
.css( 'left', offset.left + element.width() - ( element.width() / 2 ) - ( $( '.wc_error_tip' ).width() / 2 ) )
.css( 'top', offset.top + element.height() )
.fadeIn( '100' );
}
})
.on( 'wc_remove_error_tip', function( e, element, error_type ) {
element.parent().find( '.wc_error_tip.' + error_type ).fadeOut( '100', function() { $( this ).remove(); } );
})
.on( 'wc_remove_error_tip', function( e, element, error_type ) {
element.parent().find( '.wc_error_tip.' + error_type ).fadeOut( '100', function() { $( this ).remove(); } );
})
.on( 'click', function() {
$( '.wc_error_tip' ).fadeOut( '100', function() { $( this ).remove(); } );
})
.on( 'click', function() {
$( '.wc_error_tip' ).fadeOut( '100', function() { $( this ).remove(); } );
})
.on( 'blur', '.wc_input_decimal[type=text], .wc_input_price[type=text], .wc_input_country_iso[type=text]', function() {
$( '.wc_error_tip' ).fadeOut( '100', function() { $( this ).remove(); } );
})
.on( 'blur', '.wc_input_decimal[type=text], .wc_input_price[type=text], .wc_input_country_iso[type=text]', function() {
$( '.wc_error_tip' ).fadeOut( '100', function() { $( this ).remove(); } );
})
.on( 'change', '.wc_input_price[type=text], .wc_input_decimal[type=text], .wc-order-totals #refund_amount[type=text]', function() {
var regex;
.on( 'change', '.wc_input_price[type=text], .wc_input_decimal[type=text], .wc-order-totals #refund_amount[type=text]', function() {
var regex;
if ( $( this ).is( '.wc_input_price' ) || $( this ).is( '#refund_amount' ) ) {
regex = new RegExp( '[^\-0-9\%\\' + woocommerce_admin.mon_decimal_point + ']+', 'gi' );
} else {
regex = new RegExp( '[^\-0-9\%\\' + woocommerce_admin.decimal_point + ']+', 'gi' );
}
if ( $( this ).is( '.wc_input_price' ) || $( this ).is( '#refund_amount' ) ) {
regex = new RegExp( '[^\-0-9\%\\' + woocommerce_admin.mon_decimal_point + ']+', 'gi' );
} else {
regex = new RegExp( '[^\-0-9\%\\' + woocommerce_admin.decimal_point + ']+', 'gi' );
}
var value = $( this ).val();
var newvalue = value.replace( regex, '' );
var value = $( this ).val();
var newvalue = value.replace( regex, '' );
if ( value !== newvalue ) {
$( this ).val( newvalue );
}
})
if ( value !== newvalue ) {
$( this ).val( newvalue );
}
})
.on( 'keyup', '.wc_input_price[type=text], .wc_input_decimal[type=text], .wc_input_country_iso[type=text], .wc-order-totals #refund_amount[type=text]', function() {
var regex, error;
.on( 'keyup', '.wc_input_price[type=text], .wc_input_decimal[type=text], .wc_input_country_iso[type=text], .wc-order-totals #refund_amount[type=text]', function() {
var regex, error;
if ( $( this ).is( '.wc_input_price' ) || $( this ).is( '#refund_amount' ) ) {
regex = new RegExp( '[^\-0-9\%\\' + woocommerce_admin.mon_decimal_point + ']+', 'gi' );
error = 'i18n_mon_decimal_error';
} else if ( $( this ).is( '.wc_input_country_iso' ) ) {
regex = new RegExp( '([^A-Z])+|(.){3,}', 'im' );
error = 'i18n_country_iso_error';
} else {
regex = new RegExp( '[^\-0-9\%\\' + woocommerce_admin.decimal_point + ']+', 'gi' );
error = 'i18n_decimal_error';
}
if ( $( this ).is( '.wc_input_price' ) || $( this ).is( '#refund_amount' ) ) {
regex = new RegExp( '[^\-0-9\%\\' + woocommerce_admin.mon_decimal_point + ']+', 'gi' );
error = 'i18n_mon_decimal_error';
} else if ( $( this ).is( '.wc_input_country_iso' ) ) {
regex = new RegExp( '([^A-Z])+|(.){3,}', 'im' );
error = 'i18n_country_iso_error';
} else {
regex = new RegExp( '[^\-0-9\%\\' + woocommerce_admin.decimal_point + ']+', 'gi' );
error = 'i18n_decimal_error';
}
var value = $( this ).val();
var newvalue = value.replace( regex, '' );
var value = $( this ).val();
var newvalue = value.replace( regex, '' );
if ( value !== newvalue ) {
$( document.body ).triggerHandler( 'wc_add_error_tip', [ $( this ), error ] );
} else {
$( document.body ).triggerHandler( 'wc_remove_error_tip', [ $( this ), error ] );
}
})
if ( value !== newvalue ) {
$( document.body ).triggerHandler( 'wc_add_error_tip', [ $( this ), error ] );
} else {
$( document.body ).triggerHandler( 'wc_remove_error_tip', [ $( this ), error ] );
}
})
.on( 'change', '#_sale_price.wc_input_price[type=text], .wc_input_price[name^=variable_sale_price]', function() {
var sale_price_field = $( this ), regular_price_field;
.on( 'change', '#_sale_price.wc_input_price[type=text], .wc_input_price[name^=variable_sale_price]', function() {
var sale_price_field = $( this ), regular_price_field;
if( sale_price_field.attr( 'name' ).indexOf( 'variable' ) !== -1 ) {
regular_price_field = sale_price_field.parents( '.variable_pricing' ).find( '.wc_input_price[name^=variable_regular_price]' );
} else {
regular_price_field = $( '#_regular_price' );
}
if( sale_price_field.attr( 'name' ).indexOf( 'variable' ) !== -1 ) {
regular_price_field = sale_price_field.parents( '.variable_pricing' ).find( '.wc_input_price[name^=variable_regular_price]' );
} else {
regular_price_field = $( '#_regular_price' );
}
var sale_price = parseFloat( window.accounting.unformat( sale_price_field.val(), woocommerce_admin.mon_decimal_point ) );
var regular_price = parseFloat( window.accounting.unformat( regular_price_field.val(), woocommerce_admin.mon_decimal_point ) );
var sale_price = parseFloat( window.accounting.unformat( sale_price_field.val(), woocommerce_admin.mon_decimal_point ) );
var regular_price = parseFloat( window.accounting.unformat( regular_price_field.val(), woocommerce_admin.mon_decimal_point ) );
if ( sale_price >= regular_price ) {
$( this ).val( '' );
}
})
if ( sale_price >= regular_price ) {
$( this ).val( '' );
}
})
.on( 'keyup', '#_sale_price.wc_input_price[type=text], .wc_input_price[name^=variable_sale_price]', function() {
var sale_price_field = $( this ), regular_price_field;
.on( 'keyup', '#_sale_price.wc_input_price[type=text], .wc_input_price[name^=variable_sale_price]', function() {
var sale_price_field = $( this ), regular_price_field;
if( sale_price_field.attr( 'name' ).indexOf( 'variable' ) !== -1 ) {
regular_price_field = sale_price_field.parents( '.variable_pricing' ).find( '.wc_input_price[name^=variable_regular_price]' );
} else {
regular_price_field = $( '#_regular_price' );
}
if( sale_price_field.attr( 'name' ).indexOf( 'variable' ) !== -1 ) {
regular_price_field = sale_price_field.parents( '.variable_pricing' ).find( '.wc_input_price[name^=variable_regular_price]' );
} else {
regular_price_field = $( '#_regular_price' );
}
var sale_price = parseFloat( window.accounting.unformat( sale_price_field.val(), woocommerce_admin.mon_decimal_point ) );
var regular_price = parseFloat( window.accounting.unformat( regular_price_field.val(), woocommerce_admin.mon_decimal_point ) );
var sale_price = parseFloat( window.accounting.unformat( sale_price_field.val(), woocommerce_admin.mon_decimal_point ) );
var regular_price = parseFloat( window.accounting.unformat( regular_price_field.val(), woocommerce_admin.mon_decimal_point ) );
if ( sale_price >= regular_price ) {
$( document.body ).triggerHandler( 'wc_add_error_tip', [ $(this), 'i18_sale_less_than_regular_error' ] );
} else {
$( document.body ).triggerHandler( 'wc_remove_error_tip', [ $(this), 'i18_sale_less_than_regular_error' ] );
}
})
if ( sale_price >= regular_price ) {
$( document.body ).triggerHandler( 'wc_add_error_tip', [ $(this), 'i18n_sale_less_than_regular_error' ] );
} else {
$( document.body ).triggerHandler( 'wc_remove_error_tip', [ $(this), 'i18n_sale_less_than_regular_error' ] );
}
})
.on( 'init_tooltips', function() {
.on( 'init_tooltips', function() {
$( '.tips, .help_tip, .woocommerce-help-tip' ).tipTip( {
'attribute': 'data-tip',
'fadeIn': 50,
'fadeOut': 50,
'delay': 200
} );
$( '.column-wc_actions .wc-action-button' ).tipTip( {
'fadeIn': 50,
'fadeOut': 50,
'delay': 200
} );
// Add tiptip to parent element for widefat tables
$( '.parent-tips' ).each( function() {
$( this ).closest( 'a, th' ).attr( 'data-tip', $( this ).data( 'tip' ) ).tipTip( {
$( '.tips, .help_tip, .woocommerce-help-tip' ).tipTip( {
'attribute': 'data-tip',
'fadeIn': 50,
'fadeOut': 50,
'delay': 200
} ).css( 'cursor', 'help' );
} );
$( '.column-wc_actions .wc-action-button' ).tipTip( {
'fadeIn': 50,
'fadeOut': 50,
'delay': 200
} );
// Add tiptip to parent element for widefat tables
$( '.parent-tips' ).each( function() {
$( this ).closest( 'a, th' ).attr( 'data-tip', $( this ).data( 'tip' ) ).tipTip( {
'attribute': 'data-tip',
'fadeIn': 50,
'fadeOut': 50,
'delay': 200
} ).css( 'cursor', 'help' );
});
});
// Tooltips
$( document.body ).trigger( 'init_tooltips' );
// wc_input_table tables
$( '.wc_input_table.sortable tbody' ).sortable({
items: 'tr',
cursor: 'move',
axis: 'y',
scrollSensitivity: 40,
forcePlaceholderSize: true,
helper: 'clone',
opacity: 0.65,
placeholder: 'wc-metabox-sortable-placeholder',
start: function( event, ui ) {
ui.item.css( 'background-color', '#f6f6f6' );
},
stop: function( event, ui ) {
ui.item.removeAttr( 'style' );
}
});
// Focus on inputs within the table if clicked instead of trying to sort.
$( '.wc_input_table.sortable tbody input' ).on( 'click', function() {
$( this ).focus();
} );
$( '.wc_input_table .remove_rows' ).click( function() {
var $tbody = $( this ).closest( '.wc_input_table' ).find( 'tbody' );
if ( $tbody.find( 'tr.current' ).length > 0 ) {
var $current = $tbody.find( 'tr.current' );
$current.each( function() {
$( this ).remove();
});
}
return false;
});
// Tooltips
$( document.body ).trigger( 'init_tooltips' );
var controlled = false;
var shifted = false;
var hasFocus = false;
// wc_input_table tables
$( '.wc_input_table.sortable tbody' ).sortable({
items: 'tr',
cursor: 'move',
axis: 'y',
scrollSensitivity: 40,
forcePlaceholderSize: true,
helper: 'clone',
opacity: 0.65,
placeholder: 'wc-metabox-sortable-placeholder',
start: function( event, ui ) {
ui.item.css( 'background-color', '#f6f6f6' );
},
stop: function( event, ui ) {
ui.item.removeAttr( 'style' );
}
});
// Focus on inputs within the table if clicked instead of trying to sort.
$( '.wc_input_table.sortable tbody input' ).on( 'click', function() {
$( this ).focus();
} );
$( document.body ).bind( 'keyup keydown', function( e ) {
shifted = e.shiftKey;
controlled = e.ctrlKey || e.metaKey;
});
$( '.wc_input_table .remove_rows' ).click( function() {
var $tbody = $( this ).closest( '.wc_input_table' ).find( 'tbody' );
if ( $tbody.find( 'tr.current' ).length > 0 ) {
var $current = $tbody.find( 'tr.current' );
$current.each( function() {
$( this ).remove();
});
}
return false;
});
$( '.wc_input_table' ).on( 'focus click', 'input', function( e ) {
var $this_table = $( this ).closest( 'table, tbody' );
var $this_row = $( this ).closest( 'tr' );
var controlled = false;
var shifted = false;
var hasFocus = false;
if ( ( e.type === 'focus' && hasFocus !== $this_row.index() ) || ( e.type === 'click' && $( this ).is( ':focus' ) ) ) {
hasFocus = $this_row.index();
$( document.body ).bind( 'keyup keydown', function( e ) {
shifted = e.shiftKey;
controlled = e.ctrlKey || e.metaKey;
});
if ( ! shifted && ! controlled ) {
$( 'tr', $this_table ).removeClass( 'current' ).removeClass( 'last_selected' );
$this_row.addClass( 'current' ).addClass( 'last_selected' );
} else if ( shifted ) {
$( 'tr', $this_table ).removeClass( 'current' );
$this_row.addClass( 'selected_now' ).addClass( 'current' );
$( '.wc_input_table' ).on( 'focus click', 'input', function( e ) {
var $this_table = $( this ).closest( 'table, tbody' );
var $this_row = $( this ).closest( 'tr' );
if ( $( 'tr.last_selected', $this_table ).length > 0 ) {
if ( $this_row.index() > $( 'tr.last_selected', $this_table ).index() ) {
$( 'tr', $this_table ).slice( $( 'tr.last_selected', $this_table ).index(), $this_row.index() ).addClass( 'current' );
} else {
$( 'tr', $this_table ).slice( $this_row.index(), $( 'tr.last_selected', $this_table ).index() + 1 ).addClass( 'current' );
}
}
if ( ( e.type === 'focus' && hasFocus !== $this_row.index() ) || ( e.type === 'click' && $( this ).is( ':focus' ) ) ) {
hasFocus = $this_row.index();
if ( ! shifted && ! controlled ) {
$( 'tr', $this_table ).removeClass( 'current' ).removeClass( 'last_selected' );
$this_row.addClass( 'current' ).addClass( 'last_selected' );
} else if ( shifted ) {
$( 'tr', $this_table ).removeClass( 'current' );
$this_row.addClass( 'selected_now' ).addClass( 'current' );
if ( $( 'tr.last_selected', $this_table ).length > 0 ) {
if ( $this_row.index() > $( 'tr.last_selected', $this_table ).index() ) {
$( 'tr', $this_table ).slice( $( 'tr.last_selected', $this_table ).index(), $this_row.index() ).addClass( 'current' );
$( 'tr', $this_table ).removeClass( 'last_selected' );
$this_row.addClass( 'last_selected' );
} else {
$( 'tr', $this_table ).removeClass( 'last_selected' );
if ( controlled && $( this ).closest( 'tr' ).is( '.current' ) ) {
$this_row.removeClass( 'current' );
} else {
$( 'tr', $this_table ).slice( $this_row.index(), $( 'tr.last_selected', $this_table ).index() + 1 ).addClass( 'current' );
$this_row.addClass( 'current' ).addClass( 'last_selected' );
}
}
$( 'tr', $this_table ).removeClass( 'last_selected' );
$this_row.addClass( 'last_selected' );
$( 'tr', $this_table ).removeClass( 'selected_now' );
}
}).on( 'blur', 'input', function() {
hasFocus = false;
});
// Additional cost and Attribute term tables
$( '.woocommerce_page_wc-settings .shippingrows tbody tr:even, table.attributes-table tbody tr:nth-child(odd)' ).addClass( 'alternate' );
// Show order items on orders page
$( document.body ).on( 'click', '.show_order_items', function() {
$( this ).closest( 'td' ).find( 'table' ).toggle();
return false;
});
// Select availability
$( 'select.availability' ).change( function() {
if ( $( this ).val() === 'all' ) {
$( this ).closest( 'tr' ).next( 'tr' ).hide();
} else {
$( 'tr', $this_table ).removeClass( 'last_selected' );
if ( controlled && $( this ).closest( 'tr' ).is( '.current' ) ) {
$this_row.removeClass( 'current' );
$( this ).closest( 'tr' ).next( 'tr' ).show();
}
}).change();
// Hidden options
$( '.hide_options_if_checked' ).each( function() {
$( this ).find( 'input:eq(0)' ).change( function() {
if ( $( this ).is( ':checked' ) ) {
$( this ).closest( 'fieldset, tr' ).nextUntil( '.hide_options_if_checked, .show_options_if_checked', '.hidden_option' ).hide();
} else {
$this_row.addClass( 'current' ).addClass( 'last_selected' );
$( this ).closest( 'fieldset, tr' ).nextUntil( '.hide_options_if_checked, .show_options_if_checked', '.hidden_option' ).show();
}
}
}).change();
});
$( 'tr', $this_table ).removeClass( 'selected_now' );
}
}).on( 'blur', 'input', function() {
hasFocus = false;
});
$( '.show_options_if_checked' ).each( function() {
$( this ).find( 'input:eq(0)' ).change( function() {
if ( $( this ).is( ':checked' ) ) {
$( this ).closest( 'fieldset, tr' ).nextUntil( '.hide_options_if_checked, .show_options_if_checked', '.hidden_option' ).show();
} else {
$( this ).closest( 'fieldset, tr' ).nextUntil( '.hide_options_if_checked, .show_options_if_checked', '.hidden_option' ).hide();
}
}).change();
});
// Additional cost and Attribute term tables
$( '.woocommerce_page_wc-settings .shippingrows tbody tr:even, table.attributes-table tbody tr:nth-child(odd)' ).addClass( 'alternate' );
// Show order items on orders page
$( document.body ).on( 'click', '.show_order_items', function() {
$( this ).closest( 'td' ).find( 'table' ).toggle();
return false;
});
// Select availability
$( 'select.availability' ).change( function() {
if ( $( this ).val() === 'all' ) {
$( this ).closest( 'tr' ).next( 'tr' ).hide();
} else {
$( this ).closest( 'tr' ).next( 'tr' ).show();
}
}).change();
// Hidden options
$( '.hide_options_if_checked' ).each( function() {
$( this ).find( 'input:eq(0)' ).change( function() {
// Reviews.
$( 'input#woocommerce_enable_reviews' ).change(function() {
if ( $( this ).is( ':checked' ) ) {
$( this ).closest( 'fieldset, tr' ).nextUntil( '.hide_options_if_checked, .show_options_if_checked', '.hidden_option' ).hide();
$( '#woocommerce_enable_review_rating' ).closest( 'tr' ).show();
} else {
$( this ).closest( 'fieldset, tr' ).nextUntil( '.hide_options_if_checked, .show_options_if_checked', '.hidden_option' ).show();
$( '#woocommerce_enable_review_rating' ).closest( 'tr' ).hide();
}
}).change();
});
$( '.show_options_if_checked' ).each( function() {
$( this ).find( 'input:eq(0)' ).change( function() {
if ( $( this ).is( ':checked' ) ) {
$( this ).closest( 'fieldset, tr' ).nextUntil( '.hide_options_if_checked, .show_options_if_checked', '.hidden_option' ).show();
} else {
$( this ).closest( 'fieldset, tr' ).nextUntil( '.hide_options_if_checked, .show_options_if_checked', '.hidden_option' ).hide();
}
}).change();
});
// Attribute term table
$( 'table.attributes-table tbody tr:nth-child(odd)' ).addClass( 'alternate' );
// Reviews.
$( 'input#woocommerce_enable_reviews' ).change(function() {
if ( $( this ).is( ':checked' ) ) {
$( '#woocommerce_enable_review_rating' ).closest( 'tr' ).show();
} else {
$( '#woocommerce_enable_review_rating' ).closest( 'tr' ).hide();
}
}).change();
// Toggle gateway on/off.
$( '.wc_gateways' ).on( 'click', '.wc-payment-gateway-method-toggle-enabled', function() {
var $link = $( this ),
$row = $link.closest( 'tr' ),
$toggle = $link.find( '.woocommerce-input-toggle' );
// Attribute term table
$( 'table.attributes-table tbody tr:nth-child(odd)' ).addClass( 'alternate' );
var data = {
action: 'woocommerce_toggle_gateway_enabled',
security: woocommerce_admin.nonces.gateway_toggle,
gateway_id: $row.data( 'gateway_id' )
};
$toggle.addClass( 'woocommerce-input-toggle--loading' );
// Toggle gateway on/off.
$( '.wc_gateways' ).on( 'click', '.wc-payment-gateway-method-toggle-enabled', function() {
var $link = $( this ),
$row = $link.closest( 'tr' ),
$toggle = $link.find( '.woocommerce-input-toggle' );
var data = {
action: 'woocommerce_toggle_gateway_enabled',
security: woocommerce_admin.nonces.gateway_toggle,
gateway_id: $row.data( 'gateway_id' )
};
$toggle.addClass( 'woocommerce-input-toggle--loading' );
$.ajax( {
url: woocommerce_admin.ajax_url,
data: data,
dataType : 'json',
type : 'POST',
success: function( response ) {
if ( true === response.data ) {
$toggle.removeClass( 'woocommerce-input-toggle--enabled, woocommerce-input-toggle--disabled' );
$toggle.addClass( 'woocommerce-input-toggle--enabled' );
$toggle.removeClass( 'woocommerce-input-toggle--loading' );
} else if ( false === response.data ) {
$toggle.removeClass( 'woocommerce-input-toggle--enabled, woocommerce-input-toggle--disabled' );
$toggle.addClass( 'woocommerce-input-toggle--disabled' );
$toggle.removeClass( 'woocommerce-input-toggle--loading' );
} else if ( 'needs_setup' === response.data ) {
window.location.href = $link.attr( 'href' );
$.ajax( {
url: woocommerce_admin.ajax_url,
data: data,
dataType : 'json',
type : 'POST',
success: function( response ) {
if ( true === response.data ) {
$toggle.removeClass( 'woocommerce-input-toggle--enabled, woocommerce-input-toggle--disabled' );
$toggle.addClass( 'woocommerce-input-toggle--enabled' );
$toggle.removeClass( 'woocommerce-input-toggle--loading' );
} else if ( false === response.data ) {
$toggle.removeClass( 'woocommerce-input-toggle--enabled, woocommerce-input-toggle--disabled' );
$toggle.addClass( 'woocommerce-input-toggle--disabled' );
$toggle.removeClass( 'woocommerce-input-toggle--loading' );
} else if ( 'needs_setup' === response.data ) {
window.location.href = $link.attr( 'href' );
}
}
}
} );
} );
return false;
return false;
});
$( '#wpbody' ).on( 'click', '#doaction, #doaction2', function() {
var action = $( this ).is( '#doaction' ) ? $( '#bulk-action-selector-top' ).val() : $( '#bulk-action-selector-bottom' ).val();
if ( 'remove_personal_data' === action ) {
return window.confirm( woocommerce_admin.i18n_remove_personal_data_notice );
}
});
});
});
})( jQuery, woocommerce_admin );

File diff suppressed because one or more lines are too long

33
assets/js/flexslider/jquery.flexslider.js Normal file → Executable file
View File

@ -1,5 +1,5 @@
/*
* jQuery FlexSlider v2.7.0
* jQuery FlexSlider v2.7.1
* Copyright 2012 WooThemes
* Contributing Author: Tyler Smith
*/
@ -15,8 +15,8 @@
// making variables public
//if rtl value was not passed and html is in rtl..enable it by default.
if(typeof options.rtl=='undefined' && $('html').attr('dir')=='rtl'){
options.rtl=true;
if(typeof options.rtl=='undefined' && $('html').attr('dir')=='rtl'){
options.rtl=true;
}
slider.vars = $.extend({}, $.flexslider.defaults, options);
@ -75,6 +75,7 @@
}
return false;
}());
slider.isFirefox = navigator.userAgent.toLowerCase().indexOf('firefox') > -1;
slider.ensureAnimationEnd = '';
// CONTROLSCONTAINER:
if (slider.vars.controlsContainer !== "") slider.controlsContainer = $(slider.vars.controlsContainer).length > 0 && $(slider.vars.controlsContainer);
@ -176,14 +177,14 @@
e.preventDefault();
var $slide = $(this),
target = $slide.index();
var posFromX;
var posFromX;
if(slider.vars.rtl){
posFromX = -1*($slide.offset().right - $(slider).scrollLeft()); // Find position of slide relative to right of slider container
}
else
{
posFromX = $slide.offset().left - $(slider).scrollLeft(); // Find position of slide relative to left of slider container
}
posFromX = -1*($slide.offset().right - $(slider).scrollLeft()); // Find position of slide relative to right of slider container
}
else
{
posFromX = $slide.offset().left - $(slider).scrollLeft(); // Find position of slide relative to left of slider container
}
if( posFromX <= 0 && $slide.hasClass( namespace + 'active-slide' ) ) {
slider.flexAnimate(slider.getTarget("prev"), true);
} else if (!$(slider.vars.asNavFor).data('flexslider').animating && !$slide.hasClass(namespace + "active-slide")) {
@ -894,7 +895,7 @@
}());
if (slider.transitions) {
target = (vertical) ? "translate3d(0," + target + ",0)" : "translate3d(" + ((slider.vars.rtl?-1:1)*parseInt(target)+'px') + ",0,0)";
target = (vertical) ? "translate3d(0," + target + ",0)" : "translate3d(" + (parseInt(target)+'px') + ",0,0)";
dur = (dur !== undefined) ? (dur/1000) + "s" : "0s";
slider.container.css("-" + slider.pfx + "-transition-duration", dur);
slider.container.css("transition-duration", dur);
@ -950,7 +951,7 @@
setTimeout(function(){
slider.doMath();
if(slider.vars.rtl){
slider.newSlides.css({"width": slider.computedW, "marginRight" : slider.computedM, "float": "left", "display": "block"});
slider.newSlides.css({"width": slider.computedW, "marginRight" : slider.computedM, "float": "right", "display": "block"});
}
else{
slider.newSlides.css({"width": slider.computedW, "marginRight" : slider.computedM, "float": "left", "display": "block"});
@ -996,6 +997,7 @@
maxItems = slider.vars.maxItems;
slider.w = (slider.viewport===undefined) ? slider.width() : slider.viewport.width();
if (slider.isFirefox) { slider.w = slider.width(); }
slider.h = slide.height();
slider.boxPadding = slide.outerWidth() - slide.width();
@ -1139,7 +1141,7 @@
// Usability features
pauseOnAction: true, //Boolean: Pause the slideshow when interacting with control elements, highly recommended.
pauseOnHover: false, //Boolean: Pause the slideshow when hovering over slider, then resume when no longer hovering
pauseInvisible: true, //{NEW} Boolean: Pause the slideshow when tab is invisible, resume when visible. Provides better UX, lower CPU usage.
pauseInvisible: true, //{NEW} Boolean: Pause the slideshow when tab is invisible, resume when visible. Provides better UX, lower CPU usage.
useCSS: true, //{NEW} Boolean: Slider will use CSS3 transitions if available
touch: true, //{NEW} Boolean: Allow touch swipe navigation of the slider on touch-enabled devices
video: false, //{NEW} Boolean: If using video in the slider, will prevent CSS3 3D Transforms to avoid graphical glitches
@ -1173,6 +1175,9 @@
move: 0, //{NEW} Integer: Number of carousel items that should move on animation. If 0, slider will move all visible items.
allowOneSlide: true, //{NEW} Boolean: Whether or not to allow a slider comprised of a single slide
// Browser Specific
isFirefox: false, // {NEW} Boolean: Set to true when Firefox is the browser used.
// Callback API
start: function(){}, //Callback: function(slider) - Fires when the slider loads the first slide
before: function(){}, //Callback: function(slider) - Fires asynchronously with each slider animation
@ -1181,7 +1186,7 @@
added: function(){}, //{NEW} Callback: function(slider) - Fires after a slide is added
removed: function(){}, //{NEW} Callback: function(slider) - Fires after a slide is removed
init: function() {}, //{NEW} Callback: function(slider) - Fires after the slider is initially setup
rtl: false //{NEW} Boolean: Whether or not to enable RTL mode
rtl: false //{NEW} Boolean: Whether or not to enable RTL mode
};
//FlexSlider: Plugin Function

File diff suppressed because one or more lines are too long

View File

@ -538,7 +538,7 @@
$product = $form.closest( '.product' ),
$product_gallery = $product.find( '.images' ),
reset_slide_position = false,
new_image_id = ( variation && variation.image_id ) ? variation.image_id : '';
new_image_id = ( variation && variation.image_id ) ? variation.image_id : '';
if ( $form.attr( 'current-image' ) !== new_image_id ) {
reset_slide_position = true;
@ -565,28 +565,41 @@
$product_link = $product_img_wrap.find( 'a' ).eq( 0 );
if ( variation && variation.image && variation.image.src && variation.image.src.length > 1 ) {
$form.wc_variations_image_reset();
// See if the gallery has an image with the same original src as the image we want to switch to.
var galleryHasImage = $gallery_nav.find( 'li img[data-o_src="' + variation.image.gallery_thumbnail_src + '"]' ).length > 0;
if ( $gallery_nav.find( 'li img[src="' + variation.image.gallery_thumbnail_src + '"]' ).length > 0 ) {
$gallery_nav.find( 'li img[src="' + variation.image.gallery_thumbnail_src + '"]' ).trigger( 'click' );
$form.attr( 'current-image', variation.image_id );
return;
} else {
$product_img.wc_set_variation_attr( 'src', variation.image.src );
$product_img.wc_set_variation_attr( 'height', variation.image.src_h );
$product_img.wc_set_variation_attr( 'width', variation.image.src_w );
$product_img.wc_set_variation_attr( 'srcset', variation.image.srcset );
$product_img.wc_set_variation_attr( 'sizes', variation.image.sizes );
$product_img.wc_set_variation_attr( 'title', variation.image.title );
$product_img.wc_set_variation_attr( 'alt', variation.image.alt );
$product_img.wc_set_variation_attr( 'data-src', variation.image.full_src );
$product_img.wc_set_variation_attr( 'data-large_image', variation.image.full_src );
$product_img.wc_set_variation_attr( 'data-large_image_width', variation.image.full_src_w );
$product_img.wc_set_variation_attr( 'data-large_image_height', variation.image.full_src_h );
$product_img_wrap.wc_set_variation_attr( 'data-thumb', variation.image.src );
$gallery_img.wc_set_variation_attr( 'src', variation.image.gallery_thumbnail_src );
$product_link.wc_set_variation_attr( 'href', variation.image.full_src );
// If the gallery has the image, reset the images. We'll scroll to the correct one.
if ( galleryHasImage ) {
$form.wc_variations_image_reset();
}
// See if gallery has a matching image we can slide to.
var slideToImage = $gallery_nav.find( 'li img[src="' + variation.image.gallery_thumbnail_src + '"]' );
if ( slideToImage.length > 0 ) {
slideToImage.trigger( 'click' );
$form.attr( 'current-image', variation.image_id );
window.setTimeout( function() {
$( window ).trigger( 'resize' );
$product_gallery.trigger( 'woocommerce_gallery_init_zoom' );
}, 20 );
return;
}
$product_img.wc_set_variation_attr( 'src', variation.image.src );
$product_img.wc_set_variation_attr( 'height', variation.image.src_h );
$product_img.wc_set_variation_attr( 'width', variation.image.src_w );
$product_img.wc_set_variation_attr( 'srcset', variation.image.srcset );
$product_img.wc_set_variation_attr( 'sizes', variation.image.sizes );
$product_img.wc_set_variation_attr( 'title', variation.image.title );
$product_img.wc_set_variation_attr( 'alt', variation.image.alt );
$product_img.wc_set_variation_attr( 'data-src', variation.image.full_src );
$product_img.wc_set_variation_attr( 'data-large_image', variation.image.full_src );
$product_img.wc_set_variation_attr( 'data-large_image_width', variation.image.full_src_w );
$product_img.wc_set_variation_attr( 'data-large_image_height', variation.image.full_src_h );
$product_img_wrap.wc_set_variation_attr( 'data-thumb', variation.image.src );
$gallery_img.wc_set_variation_attr( 'src', variation.image.gallery_thumbnail_src );
$product_link.wc_set_variation_attr( 'href', variation.image.full_src );
} else {
$form.wc_variations_image_reset();
}

File diff suppressed because one or more lines are too long

View File

@ -1 +1 @@
jQuery(function(e){function a(e,a){a?(e.find("label .optional").remove(),e.addClass("validate-required"),0===e.find("label .required").length&&e.find("label").append('&nbsp;<abbr class="required" title="'+wc_address_i18n_params.i18n_required_text+'">*</abbr>')):(e.find("label .required").remove(),e.removeClass("validate-required"),0===e.find("label .required").length&&e.find("label").append('&nbsp;<span class="optional">('+wc_address_i18n_params.i18n_optional_text+")</span>"))}if("undefined"==typeof wc_address_i18n_params)return!1;var i=wc_address_i18n_params.locale.replace(/&quot;/g,'"'),d=e.parseJSON(i);e(document.body).bind("country_to_state_changing",function(i,t,r){var l,n=r;l="undefined"!=typeof d[t]?d[t]:d["default"];var o=n.find("#billing_postcode_field, #shipping_postcode_field"),s=n.find("#billing_city_field, #shipping_city_field"),p=n.find("#billing_state_field, #shipping_state_field");o.attr("data-o_class")||(o.attr("data-o_class",o.attr("class")),s.attr("data-o_class",s.attr("class")),p.attr("data-o_class",p.attr("class")));var f=e.parseJSON(wc_address_i18n_params.locale_fields);e.each(f,function(i,t){var r=n.find(t),o=e.extend(!0,{},d["default"][i],l[i]);"undefined"!=typeof o.label&&r.find("label").html(o.label),"undefined"!=typeof o.placeholder&&(r.find("input").attr("placeholder",o.placeholder),r.find(".select2-selection__placeholder").text(o.placeholder)),"undefined"!=typeof o.placeholder||"undefined"==typeof o.label||r.find("label").length||(r.find("input").attr("placeholder",o.label),r.find(".select2-selection__placeholder").text(o.label)),"undefined"!=typeof o.required?a(r,o.required):a(r,!1),"undefined"!=typeof o.priority&&r.data("priority",o.priority),"state"!==i&&("undefined"!=typeof o.hidden&&!0===o.hidden?r.hide().find("input").val(""):r.show())}),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 d=e(i).find(".form-row"),t=d.first().parent(),r=0;d.each(function(){e(this).data("priority")||e(this).data("priority",r+1),r=e(this).data("priority")}),d.sort(function(a,i){var d=e(a).data("priority"),t=e(i).data("priority");return d>t?1:d<t?-1:0}),d.detach().appendTo(t)})})});
jQuery(function(e){function a(e,a){a?(e.find("label .optional").remove(),e.addClass("validate-required"),0===e.find("label .required").length&&e.find("label").append('&nbsp;<abbr class="required" title="'+wc_address_i18n_params.i18n_required_text+'">*</abbr>')):(e.find("label .required").remove(),e.removeClass("validate-required"),0===e.find("label .optional").length&&e.find("label").append('&nbsp;<span class="optional">('+wc_address_i18n_params.i18n_optional_text+")</span>"))}if("undefined"==typeof wc_address_i18n_params)return!1;var i=wc_address_i18n_params.locale.replace(/&quot;/g,'"'),d=e.parseJSON(i);e(document.body).bind("country_to_state_changing",function(i,t,l){var r,n=l;r="undefined"!=typeof d[t]?d[t]:d["default"];var o=n.find("#billing_postcode_field, #shipping_postcode_field"),s=n.find("#billing_city_field, #shipping_city_field"),p=n.find("#billing_state_field, #shipping_state_field");o.attr("data-o_class")||(o.attr("data-o_class",o.attr("class")),s.attr("data-o_class",s.attr("class")),p.attr("data-o_class",p.attr("class")));var f=e.parseJSON(wc_address_i18n_params.locale_fields);e.each(f,function(i,t){var l=n.find(t),o=e.extend(!0,{},d["default"][i],r[i]);"undefined"!=typeof o.label&&l.find("label").html(o.label),"undefined"!=typeof o.placeholder&&(l.find("input").attr("placeholder",o.placeholder),l.find(".select2-selection__placeholder").text(o.placeholder)),"undefined"!=typeof o.placeholder||"undefined"==typeof o.label||l.find("label").length||(l.find("input").attr("placeholder",o.label),l.find(".select2-selection__placeholder").text(o.label)),"undefined"!=typeof o.required?a(l,o.required):a(l,!1),"undefined"!=typeof o.priority&&l.data("priority",o.priority),"state"!==i&&("undefined"!=typeof o.hidden&&!0===o.hidden?l.hide().find("input").val(""):l.show())}),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 d=e(i).find(".form-row"),t=d.first().parent(),l=0;d.each(function(){e(this).data("priority")||e(this).data("priority",l+1),l=e(this).data("priority")}),d.sort(function(a,i){var d=e(a).data("priority"),t=e(i).data("priority");return d>t?1:d<t?-1:0}),d.detach().appendTo(t)})})});

View File

@ -93,7 +93,7 @@ jQuery( function( $ ) {
// Display errors
if ( $notices.length > 0 ) {
show_notice( $notices, $( '.cart-empty' ).closest( '.woocommerce' ) );
show_notice( $notices );
}
} else {
// If the checkout is also displayed on this page, trigger update event.
@ -125,15 +125,15 @@ jQuery( function( $ ) {
};
/**
* Clear previous notices and shows new one above form.
* Shows new notices on the page.
*
* @param {Object} The Notice HTML Element in string or object form.
*/
var show_notice = function( html_element, $target ) {
if ( ! $target ) {
$target = $( '.woocommerce-cart-form' );
$target = $( '.woocommerce-notices-wrapper:first' ) || $( '.cart-empty' ).closest( '.woocommerce' ) || $( '.woocommerce-cart-form' );
}
$target.before( html_element );
$target.prepend( html_element );
};

View File

@ -89,7 +89,9 @@ jQuery( function( $ ) {
get_payment_method: function() {
return wc_checkout_form.$checkout_form.find( 'input[name="payment_method"]:checked' ).val();
},
payment_method_selected: function() {
payment_method_selected: function( e ) {
e.stopPropagation();
if ( $( '.payment_methods input.input-radio' ).length > 1 ) {
var target_payment_box = $( 'div.payment_box.' + $( this ).attr( 'ID' ) ),
is_checked = $( this ).is( ':checked' );

View File

@ -1 +1 @@
jQuery(function(a){var o=window.location.toString(),t=function(){wc_geolocation_params.hash&&a('a[href^="'+wc_geolocation_params.home_url+'"]:not(a[href*="v="]), a[href^="/"]:not(a[href*="v="])').each(function(){var o=a(this),t=o.attr("href"),e=t.split("#");t=(t=e[0]).indexOf("?")>0?t+"&v="+wc_geolocation_params.hash:t+"?v="+wc_geolocation_params.hash,"undefined"!=typeof e[1]&&null!==e[1]&&(t=t+"#"+e[1]),o.attr("href",t)})},e=function(a){o=o.indexOf("?v=")>0||o.indexOf("&v=")>0?o.replace(/v=[^&]+/,"v="+a):o.indexOf("?")>0?o+"&v="+a:o+"?v="+a,window.location=o},n={url:wc_geolocation_params.wc_ajax_url.toString().replace("%%endpoint%%","get_customer_location"),type:"GET",success:function(a){a.success&&a.data.hash&&a.data.hash!==wc_geolocation_params.hash&&e(a.data.hash)}};"1"===wc_geolocation_params.is_available&&(a.ajax(n),a("form").each(function(){var o=a(this),t=o.attr("method");if(t&&"get"===t.toLowerCase())o.append('<input type="hidden" name="v" value="'+wc_geolocation_params.hash+'" />');else{var e=o.attr("action");e&&(e.indexOf("?")>0?o.attr("action",e+"&v="+wc_geolocation_params.hash):o.attr("action",e+"?v="+wc_geolocation_params.hash))}}),t()),a(document.body).on("added_to_cart",function(){t()})});
jQuery(function(a){var o=window.location.toString(),t=function(){wc_geolocation_params.hash&&a('a[href^="'+wc_geolocation_params.home_url+'"]:not(a[href*="v="]), a[href^="/"]:not(a[href*="v="])').each(function(){var o=a(this),t=o.attr("href"),n=t.split("#");t=(t=n[0]).indexOf("?")>0?t+"&v="+wc_geolocation_params.hash:t+"?v="+wc_geolocation_params.hash,"undefined"!=typeof n[1]&&null!==n[1]&&(t=t+"#"+n[1]),o.attr("href",t)})},n=function(a){o=o.indexOf("?v=")>0||o.indexOf("&v=")>0?o.replace(/v=[^&]+/,"v="+a):o.indexOf("?")>0?o+"&v="+a:o+"?v="+a,window.location=o},e={url:wc_geolocation_params.wc_ajax_url.toString().replace("%%endpoint%%","get_customer_location"),type:"GET",success:function(a){a.success&&a.data.hash&&a.data.hash!==wc_geolocation_params.hash&&n(a.data.hash)}};"1"===wc_geolocation_params.is_available&&(a.ajax(e),a("form").each(function(){var o=a(this),t=o.attr("method"),n=o.find('input[name="v"]').length>0;if(t&&"get"===t.toLowerCase()&&!n)o.append('<input type="hidden" name="v" value="'+wc_geolocation_params.hash+'" />');else{var e=o.attr("action");e&&(e.indexOf("?")>0?o.attr("action",e+"&v="+wc_geolocation_params.hash):o.attr("action",e+"?v="+wc_geolocation_params.hash))}}),t()),a(document.body).on("added_to_cart",function(){t()})});

View File

@ -29,7 +29,7 @@
strength = wc_password_strength_meter.checkPasswordStrength( wrapper, field );
if ( fieldValue.length > 0 && strength < wc_password_strength_meter_params.min_password_strength && ! wrapper.is( 'form.checkout' ) ) {
if ( fieldValue.length > 0 && strength < wc_password_strength_meter_params.min_password_strength && ! wrapper.is( 'form.checkout' ) && -1 !== strength ) {
submit.attr( 'disabled', 'disabled' ).addClass( 'disabled' );
} else {
submit.removeAttr( 'disabled', 'disabled' ).removeClass( 'disabled' );

View File

@ -1 +1 @@
!function(s){"use strict";var r={init:function(){s(document.body).on("keyup change","form.register #reg_password, form.checkout #account_password, form.edit-account #password_1, form.lost_reset_password #password_1",this.strengthMeter),s("form.checkout #createaccount").change()},strengthMeter:function(){var e=s("form.register, form.checkout, form.edit-account, form.lost_reset_password"),t=s('button[type="submit"]',e),o=s("#reg_password, #account_password, #password_1",e),a=1,d=o.val();r.includeMeter(e,o),a=r.checkPasswordStrength(e,o),d.length>0&&a<wc_password_strength_meter_params.min_password_strength&&!e.is("form.checkout")?t.attr("disabled","disabled").addClass("disabled"):t.removeAttr("disabled","disabled").removeClass("disabled")},includeMeter:function(r,e){var t=r.find(".woocommerce-password-strength");""===e.val()?(t.hide(),s(document.body).trigger("wc-password-strength-hide")):0===t.length?(e.after('<div class="woocommerce-password-strength" aria-live="polite"></div>'),s(document.body).trigger("wc-password-strength-added")):(t.show(),s(document.body).trigger("wc-password-strength-show"))},checkPasswordStrength:function(s,r){var e=s.find(".woocommerce-password-strength"),t=s.find(".woocommerce-password-hint"),o='<small class="woocommerce-password-hint">'+wc_password_strength_meter_params.i18n_password_hint+"</small>",a=wp.passwordStrength.meter(r.val(),wp.passwordStrength.userInputBlacklist()),d="";if(e.removeClass("short bad good strong"),t.remove(),e.is(":hidden"))return a;switch(a<wc_password_strength_meter_params.min_password_strength&&(d=" - "+wc_password_strength_meter_params.i18n_password_error),a){case 0:e.addClass("short").html(pwsL10n["short"]+d),e.after(o);break;case 1:case 2:e.addClass("bad").html(pwsL10n.bad+d),e.after(o);break;case 3:e.addClass("good").html(pwsL10n.good+d);break;case 4:e.addClass("strong").html(pwsL10n.strong+d);break;case 5:e.addClass("short").html(pwsL10n.mismatch)}return a}};r.init()}(jQuery);
!function(s){"use strict";var r={init:function(){s(document.body).on("keyup change","form.register #reg_password, form.checkout #account_password, form.edit-account #password_1, form.lost_reset_password #password_1",this.strengthMeter),s("form.checkout #createaccount").change()},strengthMeter:function(){var e=s("form.register, form.checkout, form.edit-account, form.lost_reset_password"),t=s('button[type="submit"]',e),o=s("#reg_password, #account_password, #password_1",e),a=1,d=o.val();r.includeMeter(e,o),a=r.checkPasswordStrength(e,o),d.length>0&&a<wc_password_strength_meter_params.min_password_strength&&!e.is("form.checkout")&&-1!==a?t.attr("disabled","disabled").addClass("disabled"):t.removeAttr("disabled","disabled").removeClass("disabled")},includeMeter:function(r,e){var t=r.find(".woocommerce-password-strength");""===e.val()?(t.hide(),s(document.body).trigger("wc-password-strength-hide")):0===t.length?(e.after('<div class="woocommerce-password-strength" aria-live="polite"></div>'),s(document.body).trigger("wc-password-strength-added")):(t.show(),s(document.body).trigger("wc-password-strength-show"))},checkPasswordStrength:function(s,r){var e=s.find(".woocommerce-password-strength"),t=s.find(".woocommerce-password-hint"),o='<small class="woocommerce-password-hint">'+wc_password_strength_meter_params.i18n_password_hint+"</small>",a=wp.passwordStrength.meter(r.val(),wp.passwordStrength.userInputBlacklist()),d="";if(e.removeClass("short bad good strong"),t.remove(),e.is(":hidden"))return a;switch(a<wc_password_strength_meter_params.min_password_strength&&(d=" - "+wc_password_strength_meter_params.i18n_password_error),a){case 0:e.addClass("short").html(pwsL10n["short"]+d),e.after(o);break;case 1:case 2:e.addClass("bad").html(pwsL10n.bad+d),e.after(o);break;case 3:e.addClass("good").html(pwsL10n.good+d);break;case 4:e.addClass("strong").html(pwsL10n.strong+d);break;case 5:e.addClass("short").html(pwsL10n.mismatch)}return a}};r.init()}(jQuery);

View File

@ -223,6 +223,11 @@ jQuery( function( $ ) {
this.$target.on( 'click', '.woocommerce-product-gallery__image a', function( e ) {
e.preventDefault();
});
// If flexslider is disabled, gallery images also need to trigger photoswipe on click.
if ( ! this.flexslider_enabled ) {
this.$target.on( 'click', '.woocommerce-product-gallery__image a', this.openPhotoswipe );
}
} else {
this.$target.on( 'click', '.woocommerce-product-gallery__image a', this.openPhotoswipe );
}

File diff suppressed because one or more lines are too long

View File

@ -48,7 +48,7 @@ jQuery( function( $ ) {
return false;
}
} )
.on( 'focus', function() {
.on( 'click focus', function() {
var input = $( this ),
parent = input.parent(),
description = parent.find( 'span.description' );

177
composer.lock generated
View File

@ -936,25 +936,28 @@
},
{
"name": "myclabs/deep-copy",
"version": "1.7.0",
"version": "1.8.0",
"source": {
"type": "git",
"url": "https://github.com/myclabs/DeepCopy.git",
"reference": "3b8a3a99ba1f6a3952ac2747d989303cbd6b7a3e"
"reference": "478465659fd987669df0bd8a9bf22a8710e5f1b6"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/3b8a3a99ba1f6a3952ac2747d989303cbd6b7a3e",
"reference": "3b8a3a99ba1f6a3952ac2747d989303cbd6b7a3e",
"url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/478465659fd987669df0bd8a9bf22a8710e5f1b6",
"reference": "478465659fd987669df0bd8a9bf22a8710e5f1b6",
"shasum": ""
},
"require": {
"php": "^5.6 || ^7.0"
"php": "^7.1"
},
"replace": {
"myclabs/deep-copy": "self.version"
},
"require-dev": {
"doctrine/collections": "^1.0",
"doctrine/common": "^2.6",
"phpunit/phpunit": "^4.1"
"phpunit/phpunit": "^7.1"
},
"type": "library",
"autoload": {
@ -977,7 +980,7 @@
"object",
"object graph"
],
"time": "2017-10-19T19:58:43+00:00"
"time": "2018-05-29T17:25:09+00:00"
},
{
"name": "nette/application",
@ -2064,23 +2067,23 @@
},
{
"name": "phpspec/prophecy",
"version": "1.7.5",
"version": "1.7.6",
"source": {
"type": "git",
"url": "https://github.com/phpspec/prophecy.git",
"reference": "dfd6be44111a7c41c2e884a336cc4f461b3b2401"
"reference": "33a7e3c4fda54e912ff6338c48823bd5c0f0b712"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpspec/prophecy/zipball/dfd6be44111a7c41c2e884a336cc4f461b3b2401",
"reference": "dfd6be44111a7c41c2e884a336cc4f461b3b2401",
"url": "https://api.github.com/repos/phpspec/prophecy/zipball/33a7e3c4fda54e912ff6338c48823bd5c0f0b712",
"reference": "33a7e3c4fda54e912ff6338c48823bd5c0f0b712",
"shasum": ""
},
"require": {
"doctrine/instantiator": "^1.0.2",
"php": "^5.3|^7.0",
"phpdocumentor/reflection-docblock": "^2.0|^3.0.2|^4.0",
"sebastian/comparator": "^1.1|^2.0",
"sebastian/comparator": "^1.1|^2.0|^3.0",
"sebastian/recursion-context": "^1.0|^2.0|^3.0"
},
"require-dev": {
@ -2123,20 +2126,20 @@
"spy",
"stub"
],
"time": "2018-02-19T10:16:54+00:00"
"time": "2018-04-18T13:57:24+00:00"
},
{
"name": "phpunit/php-code-coverage",
"version": "5.3.0",
"version": "5.3.2",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/php-code-coverage.git",
"reference": "661f34d0bd3f1a7225ef491a70a020ad23a057a1"
"reference": "c89677919c5dd6d3b3852f230a663118762218ac"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/661f34d0bd3f1a7225ef491a70a020ad23a057a1",
"reference": "661f34d0bd3f1a7225ef491a70a020ad23a057a1",
"url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/c89677919c5dd6d3b3852f230a663118762218ac",
"reference": "c89677919c5dd6d3b3852f230a663118762218ac",
"shasum": ""
},
"require": {
@ -2186,7 +2189,7 @@
"testing",
"xunit"
],
"time": "2017-12-06T09:29:45+00:00"
"time": "2018-04-06T15:36:58+00:00"
},
{
"name": "phpunit/php-file-iterator",
@ -2376,16 +2379,16 @@
},
{
"name": "phpunit/phpunit",
"version": "6.5.7",
"version": "6.5.8",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/phpunit.git",
"reference": "6bd77b57707c236833d2b57b968e403df060c9d9"
"reference": "4f21a3c6b97c42952fd5c2837bb354ec0199b97b"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/6bd77b57707c236833d2b57b968e403df060c9d9",
"reference": "6bd77b57707c236833d2b57b968e403df060c9d9",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/4f21a3c6b97c42952fd5c2837bb354ec0199b97b",
"reference": "4f21a3c6b97c42952fd5c2837bb354ec0199b97b",
"shasum": ""
},
"require": {
@ -2456,20 +2459,20 @@
"testing",
"xunit"
],
"time": "2018-02-26T07:01:09+00:00"
"time": "2018-04-10T11:38:34+00:00"
},
{
"name": "phpunit/phpunit-mock-objects",
"version": "5.0.6",
"version": "5.0.7",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git",
"reference": "33fd41a76e746b8fa96d00b49a23dadfa8334cdf"
"reference": "3eaf040f20154d27d6da59ca2c6e28ac8fd56dce"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/33fd41a76e746b8fa96d00b49a23dadfa8334cdf",
"reference": "33fd41a76e746b8fa96d00b49a23dadfa8334cdf",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/3eaf040f20154d27d6da59ca2c6e28ac8fd56dce",
"reference": "3eaf040f20154d27d6da59ca2c6e28ac8fd56dce",
"shasum": ""
},
"require": {
@ -2515,7 +2518,7 @@
"mock",
"xunit"
],
"time": "2018-01-06T05:45:45+00:00"
"time": "2018-05-29T13:50:43+00:00"
},
{
"name": "psr/log",
@ -3225,16 +3228,16 @@
},
{
"name": "symfony/console",
"version": "v2.8.35",
"version": "v2.8.41",
"source": {
"type": "git",
"url": "https://github.com/symfony/console.git",
"reference": "a6ff8b2ffa4eb43046828b303af2e3fedadacc27"
"reference": "e8e59b74ad1274714dad2748349b55e3e6e630c7"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/console/zipball/a6ff8b2ffa4eb43046828b303af2e3fedadacc27",
"reference": "a6ff8b2ffa4eb43046828b303af2e3fedadacc27",
"url": "https://api.github.com/repos/symfony/console/zipball/e8e59b74ad1274714dad2748349b55e3e6e630c7",
"reference": "e8e59b74ad1274714dad2748349b55e3e6e630c7",
"shasum": ""
},
"require": {
@ -3248,7 +3251,7 @@
"symfony/process": "~2.1|~3.0.0"
},
"suggest": {
"psr/log": "For using the console logger",
"psr/log-implementation": "For using the console logger",
"symfony/event-dispatcher": "",
"symfony/process": ""
},
@ -3282,7 +3285,7 @@
],
"description": "Symfony Console Component",
"homepage": "https://symfony.com",
"time": "2018-02-26T15:33:21+00:00"
"time": "2018-05-15T21:17:45+00:00"
},
{
"name": "symfony/debug",
@ -3397,17 +3400,72 @@
"time": "2015-05-13T11:33:56+00:00"
},
{
"name": "symfony/polyfill-mbstring",
"version": "v1.7.0",
"name": "symfony/polyfill-ctype",
"version": "v1.8.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-mbstring.git",
"reference": "78be803ce01e55d3491c1397cf1c64beb9c1b63b"
"url": "https://github.com/symfony/polyfill-ctype.git",
"reference": "7cc359f1b7b80fc25ed7796be7d96adc9b354bae"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/78be803ce01e55d3491c1397cf1c64beb9c1b63b",
"reference": "78be803ce01e55d3491c1397cf1c64beb9c1b63b",
"url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/7cc359f1b7b80fc25ed7796be7d96adc9b354bae",
"reference": "7cc359f1b7b80fc25ed7796be7d96adc9b354bae",
"shasum": ""
},
"require": {
"php": ">=5.3.3"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.8-dev"
}
},
"autoload": {
"psr-4": {
"Symfony\\Polyfill\\Ctype\\": ""
},
"files": [
"bootstrap.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
},
{
"name": "Gert de Pagter",
"email": "BackEndTea@gmail.com"
}
],
"description": "Symfony polyfill for ctype functions",
"homepage": "https://symfony.com",
"keywords": [
"compatibility",
"ctype",
"polyfill",
"portable"
],
"time": "2018-04-30T19:57:29+00:00"
},
{
"name": "symfony/polyfill-mbstring",
"version": "v1.8.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-mbstring.git",
"reference": "3296adf6a6454a050679cde90f95350ad604b171"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/3296adf6a6454a050679cde90f95350ad604b171",
"reference": "3296adf6a6454a050679cde90f95350ad604b171",
"shasum": ""
},
"require": {
@ -3419,7 +3477,7 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.7-dev"
"dev-master": "1.8-dev"
}
},
"autoload": {
@ -3453,24 +3511,25 @@
"portable",
"shim"
],
"time": "2018-01-30T19:27:44+00:00"
"time": "2018-04-26T10:06:28+00:00"
},
{
"name": "symfony/yaml",
"version": "v2.8.35",
"version": "v2.8.41",
"source": {
"type": "git",
"url": "https://github.com/symfony/yaml.git",
"reference": "be720fcfae4614df204190d57795351059946a77"
"reference": "51356b7a2ff7c9fd06b2f1681cc463bb62b5c1ff"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/yaml/zipball/be720fcfae4614df204190d57795351059946a77",
"reference": "be720fcfae4614df204190d57795351059946a77",
"url": "https://api.github.com/repos/symfony/yaml/zipball/51356b7a2ff7c9fd06b2f1681cc463bb62b5c1ff",
"reference": "51356b7a2ff7c9fd06b2f1681cc463bb62b5c1ff",
"shasum": ""
},
"require": {
"php": ">=5.3.9"
"php": ">=5.3.9",
"symfony/polyfill-ctype": "~1.8"
},
"type": "library",
"extra": {
@ -3502,7 +3561,7 @@
],
"description": "Symfony Yaml Component",
"homepage": "https://symfony.com",
"time": "2018-01-03T07:36:31+00:00"
"time": "2018-05-01T22:52:40+00:00"
},
{
"name": "theseer/tokenizer",
@ -3546,16 +3605,16 @@
},
{
"name": "tracy/tracy",
"version": "v2.4.12",
"version": "v2.5.0",
"source": {
"type": "git",
"url": "https://github.com/nette/tracy.git",
"reference": "4182ce7b92f67002509b7fa2fc34bd84deea0b24"
"reference": "534d4e4f0f31da494026a3761fad020c20b8debf"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/nette/tracy/zipball/4182ce7b92f67002509b7fa2fc34bd84deea0b24",
"reference": "4182ce7b92f67002509b7fa2fc34bd84deea0b24",
"url": "https://api.github.com/repos/nette/tracy/zipball/534d4e4f0f31da494026a3761fad020c20b8debf",
"reference": "534d4e4f0f31da494026a3761fad020c20b8debf",
"shasum": ""
},
"require": {
@ -3573,7 +3632,7 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.4-dev"
"dev-master": "2.5-dev"
}
},
"autoload": {
@ -3607,7 +3666,7 @@
"nette",
"profiler"
],
"time": "2018-02-28T00:49:47+00:00"
"time": "2018-05-25T09:33:08+00:00"
},
{
"name": "webmozart/assert",
@ -3746,16 +3805,16 @@
},
{
"name": "woocommerce/woocommerce-sniffs",
"version": "0.0.1",
"version": "0.0.2",
"source": {
"type": "git",
"url": "https://github.com/woocommerce/woocommerce-sniffs.git",
"reference": "383d5b361c1d7532ae1ca6156fd7619fd37bbc05"
"reference": "2890fd5d98b318f62acb42f2b5cd6d02627cfd82"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/woocommerce/woocommerce-sniffs/zipball/383d5b361c1d7532ae1ca6156fd7619fd37bbc05",
"reference": "383d5b361c1d7532ae1ca6156fd7619fd37bbc05",
"url": "https://api.github.com/repos/woocommerce/woocommerce-sniffs/zipball/2890fd5d98b318f62acb42f2b5cd6d02627cfd82",
"reference": "2890fd5d98b318f62acb42f2b5cd6d02627cfd82",
"shasum": ""
},
"require": {
@ -3783,7 +3842,7 @@
"woocommerce",
"wordpress"
],
"time": "2017-12-21T22:52:52+00:00"
"time": "2018-03-22T18:39:19+00:00"
},
{
"name": "wp-coding-standards/wpcs",

File diff suppressed because it is too large Load Diff

View File

@ -32,7 +32,6 @@ $states['IT'] = array(
'CA' => __( 'Cagliari', 'woocommerce' ),
'CL' => __( 'Caltanissetta', 'woocommerce' ),
'CB' => __( 'Campobasso', 'woocommerce' ),
'CI' => __( 'Carbonia-Iglesias', 'woocommerce' ),
'CE' => __( 'Caserta', 'woocommerce' ),
'CT' => __( 'Catania', 'woocommerce' ),
'CZ' => __( 'Catanzaro', 'woocommerce' ),
@ -73,7 +72,6 @@ $states['IT'] = array(
'NA' => __( 'Napoli', 'woocommerce' ),
'NO' => __( 'Novara', 'woocommerce' ),
'NU' => __( 'Nuoro', 'woocommerce' ),
'OT' => __( 'Olbia-Tempio', 'woocommerce' ),
'OR' => __( 'Oristano', 'woocommerce' ),
'PD' => __( 'Padova', 'woocommerce' ),
'PA' => __( 'Palermo', 'woocommerce' ),
@ -97,17 +95,16 @@ $states['IT'] = array(
'RM' => __( 'Roma', 'woocommerce' ),
'RO' => __( 'Rovigo', 'woocommerce' ),
'SA' => __( 'Salerno', 'woocommerce' ),
'VS' => __( 'Medio Campidano', 'woocommerce' ),
'SS' => __( 'Sassari', 'woocommerce' ),
'SV' => __( 'Savona', 'woocommerce' ),
'SI' => __( 'Siena', 'woocommerce' ),
'SR' => __( 'Siracusa', 'woocommerce' ),
'SO' => __( 'Sondrio', 'woocommerce' ),
'SU' => __( 'Sud Sardegna', 'woocommerce' ),
'TA' => __( 'Taranto', 'woocommerce' ),
'TE' => __( 'Teramo', 'woocommerce' ),
'TR' => __( 'Terni', 'woocommerce' ),
'TO' => __( 'Torino', 'woocommerce' ),
'OG' => __( 'Ogliastra', 'woocommerce' ),
'TP' => __( 'Trapani', 'woocommerce' ),
'TN' => __( 'Trento', 'woocommerce' ),
'TV' => __( 'Treviso', 'woocommerce' ),

View File

@ -420,11 +420,34 @@ abstract class WC_Data {
$this->maybe_read_meta_data();
$array_key = $meta_id ? array_keys( wp_list_pluck( $this->meta_data, 'id' ), $meta_id ) : '';
$array_key = false;
if ( $meta_id ) {
$array_keys = array_keys( wp_list_pluck( $this->meta_data, 'id' ), $meta_id, true );
$array_key = $array_keys ? current( $array_keys ) : false;
} else {
// Find matches by key.
$matches = array();
$ids_to_keys = wp_list_pluck( $this->meta_data, 'key', 'id' );
foreach ( $this->meta_data as $meta_data_array_key => $meta ) {
if ( $meta->key === $key ) {
$matches[] = $meta_data_array_key;
}
}
if ( ! empty( $matches ) ) {
// Set matches to null so only one key gets the new value.
foreach ( $matches as $meta_data_array_key ) {
$this->meta_data[ $meta_data_array_key ]->value = null;
}
$array_key = current( $matches );
}
}
if ( $array_key ) {
$meta = $this->meta_data[ current( $array_key ) ];
$meta->key = $key;
$meta = $this->meta_data[ $array_key ];
$meta->key = $key;
$meta->value = $value;
} else {
$this->add_meta_data( $key, $value, true );

View File

@ -1182,6 +1182,7 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
$item->save();
$this->add_item( $item );
wc_do_deprecated_action( 'woocommerce_order_add_product', array( $this->get_id(), $item->get_id(), $product, $qty, $args ), '3.0', 'woocommerce_new_order_item action instead' );
delete_transient( 'wc_order_' . $this->get_id() . '_needs_processing' );
return $item->get_id();
}
@ -1324,7 +1325,7 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
$shipping_tax_class = count( $found_classes ) ? current( $found_classes ) : false;
}
$is_vat_exempt = apply_filters( 'woocommerce_order_is_vat_exempt', 'yes' === $this->get_meta( 'is_vat_exempt' ) );
$is_vat_exempt = apply_filters( 'woocommerce_order_is_vat_exempt', 'yes' === $this->get_meta( 'is_vat_exempt' ), $this );
// Trigger tax recalculation for all items.
foreach ( $this->get_items( array( 'line_item', 'fee' ) ) as $item_id => $item ) {

View File

@ -54,9 +54,11 @@ abstract class WC_Abstract_Privacy {
protected $erase_priority;
/**
* Constructor
* WC_Abstract_Privacy Constructor.
*
* @param string $name Plugin identifier.
* @param string $name Plugin identifier.
* @param int $export_priority Export priority.
* @param int $erase_priority Erase priority.
*/
public function __construct( $name = '', $export_priority = 5, $erase_priority = 10 ) {
$this->name = $name;
@ -127,9 +129,11 @@ abstract class WC_Abstract_Privacy {
/**
* Add exporter to list of exporters.
*
* @param string $id ID of the Exporter.
* @param string $name Exporter name.
* @param string $callback Exporter callback.
* @param string $id ID of the Exporter.
* @param string $name Exporter name.
* @param string|array $callback Exporter callback.
*
* @return array
*/
public function add_exporter( $id, $name, $callback ) {
$this->exporters[ $id ] = array(
@ -142,9 +146,11 @@ abstract class WC_Abstract_Privacy {
/**
* Add eraser to list of erasers.
*
* @param string $id ID of the Eraser.
* @param string $name Exporter name.
* @param string $callback Exporter callback.
* @param string $id ID of the Eraser.
* @param string $name Exporter name.
* @param string|array $callback Exporter callback.
*
* @return array
*/
public function add_eraser( $id, $name, $callback ) {
$this->erasers[ $id ] = array(

View File

@ -524,31 +524,37 @@ abstract class WC_Shipping_Method extends WC_Settings_API {
}
/**
* Processes and saves options.
* If there is an error thrown, will continue to save and validate fields, but will leave the erroring field out.
* Processes and saves global shipping method options in the admin area.
*
* This method is usually attached to woocommerce_update_options_x hooks.
*
* @since 2.6.0
* @return bool was anything saved?
*/
public function process_admin_options() {
if ( $this->instance_id ) {
$this->init_instance_settings();
$post_data = $this->get_post_data();
foreach ( $this->get_instance_form_fields() as $key => $field ) {
if ( 'title' !== $this->get_field_type( $field ) ) {
try {
$this->instance_settings[ $key ] = $this->get_field_value( $key, $field, $post_data );
} catch ( Exception $e ) {
$this->add_error( $e->getMessage() );
}
}
}
return update_option( $this->get_instance_option_key(), apply_filters( 'woocommerce_shipping_' . $this->id . '_instance_settings_values', $this->instance_settings, $this ) );
} else {
if ( ! $this->instance_id ) {
return parent::process_admin_options();
}
// Check we are processing the correct form for this instance.
if ( ! isset( $_REQUEST['instance_id'] ) || absint( $_REQUEST['instance_id'] ) !== $this->instance_id ) { // WPCS: input var ok, CSRF ok.
return false;
}
$this->init_instance_settings();
$post_data = $this->get_post_data();
foreach ( $this->get_instance_form_fields() as $key => $field ) {
if ( 'title' !== $this->get_field_type( $field ) ) {
try {
$this->instance_settings[ $key ] = $this->get_field_value( $key, $field, $post_data );
} catch ( Exception $e ) {
$this->add_error( $e->getMessage() );
}
}
}
return update_option( $this->get_instance_option_key(), apply_filters( 'woocommerce_shipping_' . $this->id . '_instance_settings_values', $this->instance_settings, $this ), 'yes' );
}
}

View File

@ -32,7 +32,7 @@ if ( ! class_exists( 'WC_Admin_Assets', false ) ) :
global $wp_scripts;
$screen = get_current_screen();
$screen_id = $screen ? $screen->id: '';
$screen_id = $screen ? $screen->id : '';
// Register admin styles.
wp_register_style( 'woocommerce_admin_menu_styles', WC()->plugin_url() . '/assets/css/menu.css', array(), WC_VERSION );
@ -161,23 +161,24 @@ if ( ! class_exists( 'WC_Admin_Assets', false ) ) :
$params = array(
/* translators: %s: decimal */
'i18n_decimal_error' => sprintf( __( 'Please enter in decimal (%s) format without thousand separators.', 'woocommerce' ), $decimal ),
'i18n_decimal_error' => sprintf( __( 'Please enter in decimal (%s) format without thousand separators.', 'woocommerce' ), $decimal ),
/* translators: %s: price decimal separator */
'i18n_mon_decimal_error' => sprintf( __( 'Please enter in monetary decimal (%s) format without thousand separators and currency symbols.', 'woocommerce' ), wc_get_price_decimal_separator() ),
'i18n_country_iso_error' => __( 'Please enter in country code with two capital letters.', 'woocommerce' ),
'i18_sale_less_than_regular_error' => __( 'Please enter in a value less than the regular price.', 'woocommerce' ),
'i18_delete_product_notice' => __( 'This product has produced sales and may be linked to existing orders. Are you sure you want to delete it?', 'woocommerce' ),
'decimal_point' => $decimal,
'mon_decimal_point' => wc_get_price_decimal_separator(),
'ajax_url' => admin_url( 'admin-ajax.php' ),
'strings' => array(
'i18n_mon_decimal_error' => sprintf( __( 'Please enter in monetary decimal (%s) format without thousand separators and currency symbols.', 'woocommerce' ), wc_get_price_decimal_separator() ),
'i18n_country_iso_error' => __( 'Please enter in country code with two capital letters.', 'woocommerce' ),
'i18n_sale_less_than_regular_error' => __( 'Please enter in a value less than the regular price.', 'woocommerce' ),
'i18n_delete_product_notice' => __( 'This product has produced sales and may be linked to existing orders. Are you sure you want to delete it?', 'woocommerce' ),
'i18n_remove_personal_data_notice' => __( 'This action cannot be reversed. Are you sure you wish to erase personal data from the selected orders?', 'woocommerce' ),
'decimal_point' => $decimal,
'mon_decimal_point' => wc_get_price_decimal_separator(),
'ajax_url' => admin_url( 'admin-ajax.php' ),
'strings' => array(
'import_products' => __( 'Import', 'woocommerce' ),
'export_products' => __( 'Export', 'woocommerce' ),
),
'nonces' => array(
'nonces' => array(
'gateway_toggle' => wp_create_nonce( 'woocommerce-toggle-payment-gateway-enabled' ),
),
'urls' => array(
'urls' => array(
'import_products' => current_user_can( 'import' ) ? esc_url_raw( admin_url( 'edit.php?post_type=product&page=product_importer' ) ) : null,
'export_products' => current_user_can( 'export' ) ? esc_url_raw( admin_url( 'edit.php?post_type=product&page=product_exporter' ) ) : null,
),

View File

@ -360,7 +360,7 @@ if ( ! class_exists( 'WC_Admin_Dashboard', false ) ) :
<script type="text/template" id="network-orders-row-template">
<tr>
<td>
<a href="<%- edit_url %>" class="order-view"><strong>#<%- id %> <%- customer %></strong></a>
<a href="<%- edit_url %>" class="order-view"><strong>#<%- number %> <%- customer %></strong></a>
<br>
<em>
<%- blog.blogname %>

View File

@ -132,11 +132,13 @@ if ( ! class_exists( 'WC_Admin_Settings', false ) ) :
do_action( 'woocommerce_settings_start' );
wp_enqueue_script( 'woocommerce_settings', WC()->plugin_url() . '/assets/js/admin/settings' . $suffix . '.js', array( 'jquery', 'jquery-ui-datepicker', 'jquery-ui-sortable', 'iris', 'selectWoo' ), WC()->version, true );
wp_enqueue_script( 'woocommerce_settings', WC()->plugin_url() . '/assets/js/admin/settings' . $suffix . '.js', array( 'jquery', 'wp-util', 'jquery-ui-datepicker', 'jquery-ui-sortable', 'iris', 'selectWoo' ), WC()->version, true );
wp_localize_script(
'woocommerce_settings', 'woocommerce_settings_params', array(
'i18n_nav_warning' => __( 'The changes you made will be lost if you navigate away from this page.', 'woocommerce' ),
'i18n_moved_up' => __( 'Item moved up', 'woocommerce' ),
'i18n_moved_down' => __( 'Item moved down', 'woocommerce' ),
)
);
@ -249,7 +251,9 @@ if ( ! class_exists( 'WC_Admin_Settings', false ) ) :
echo '<h2>' . esc_html( $value['title'] ) . '</h2>';
}
if ( ! empty( $value['desc'] ) ) {
echo '<div id="' . esc_attr( sanitize_title( $value['id'] ) ) . '-description">';
echo wp_kses_post( wpautop( wptexturize( $value['desc'] ) ) );
echo '</div>';
}
echo '<table class="form-table">' . "\n\n";
if ( ! empty( $value['id'] ) ) {

View File

@ -803,7 +803,7 @@ class WC_Admin_Setup_Wizard {
id="<?php echo esc_attr( "{$input_prefix}[method]" ); ?>"
name="<?php echo esc_attr( "{$input_prefix}[method]" ); ?>"
class="method wc-enhanced-select"
data-plugins="<?php echo esc_attr( json_encode( $this->get_wcs_requisite_plugins() ) ); ?>"
data-plugins="<?php echo esc_attr( wp_json_encode( $this->get_wcs_requisite_plugins() ) ); ?>"
>
<?php foreach ( $shipping_methods as $method_id => $method ) : ?>
<option value="<?php echo esc_attr( $method_id ); ?>" <?php selected( $selected, $method_id ); ?>><?php echo esc_html( $method['name'] ); ?></option>
@ -1116,7 +1116,46 @@ class WC_Admin_Setup_Wizard {
}
/**
* Is Klarna Checkout country supported
* Is PayPal currency supported.
*
* @param string $currency Currency code.
* @return boolean
*/
protected function is_paypal_supported_currency( $currency ) {
$supported_currencies = array(
'AUD',
'BRL',
'CAD',
'MXN',
'NZD',
'HKD',
'SGD',
'USD',
'EUR',
'JPY',
'TRY',
'NOK',
'CZK',
'DKK',
'HUF',
'ILS',
'MYR',
'PHP',
'PLN',
'SEK',
'CHF',
'TWD',
'THB',
'GBP',
'RMB',
'RUB',
'INR',
);
return in_array( $currency, $supported_currencies, true );
}
/**
* Is Klarna Checkout country supported.
*
* @param string $country_code Country code.
*/
@ -1131,7 +1170,7 @@ class WC_Admin_Setup_Wizard {
}
/**
* Is Klarna Payments country supported
* Is Klarna Payments country supported.
*
* @param string $country_code Country code.
*/
@ -1336,15 +1375,19 @@ class WC_Admin_Setup_Wizard {
*/
public function get_wizard_in_cart_payment_gateways() {
$gateways = $this->get_wizard_available_in_cart_payment_gateways();
$country = WC()->countries->get_base_country();
$currency = get_woocommerce_currency();
if ( ! current_user_can( 'install_plugins' ) ) {
return array( 'paypal' => $gateways['paypal'] );
}
$country = WC()->countries->get_base_country();
$can_stripe = $this->is_stripe_supported_country( $country );
$can_eway = $this->is_eway_payments_supported_country( $country );
$can_payfast = ( 'ZA' === $country ); // South Africa.
$can_paypal = $this->is_paypal_supported_currency( $currency );
if ( ! current_user_can( 'install_plugins' ) ) {
return $can_paypal ? array( 'paypal' => $gateways['paypal'] ) : array();
}
$spotlight = '';
if ( $this->is_klarna_checkout_supported_country( $country ) ) {
$spotlight = 'klarna_checkout';
@ -1354,12 +1397,15 @@ class WC_Admin_Setup_Wizard {
$spotlight = 'square';
}
if ( isset( $spotlight ) ) {
if ( $spotlight ) {
$offered_gateways = array(
$spotlight => $gateways[ $spotlight ],
'ppec_paypal' => $gateways['ppec_paypal'],
$spotlight => $gateways[ $spotlight ],
);
if ( $can_paypal ) {
$offered_gateways += array( 'ppec_paypal' => $gateways['ppec_paypal'] );
}
if ( $can_stripe ) {
$offered_gateways += array( 'stripe' => $gateways['stripe'] );
}
@ -1383,7 +1429,9 @@ class WC_Admin_Setup_Wizard {
$offered_gateways += array( 'stripe' => $gateways['stripe'] );
}
$offered_gateways += array( 'ppec_paypal' => $gateways['ppec_paypal'] );
if ( $can_paypal ) {
$offered_gateways += array( 'ppec_paypal' => $gateways['ppec_paypal'] );
}
if ( $can_eway ) {
$offered_gateways += array( 'eway' => $gateways['eway'] );
@ -1450,7 +1498,7 @@ class WC_Admin_Setup_Wizard {
$plugins = null;
if ( isset( $item_info['repo-slug'] ) ) {
$plugin = array(
$plugin = array(
'slug' => $item_info['repo-slug'],
'name' => $item_info['name'],
);
@ -1503,7 +1551,7 @@ class WC_Admin_Setup_Wizard {
placeholder="<?php echo esc_attr( $setting['placeholder'] ); ?>"
<?php echo ( $setting['required'] ) ? 'required' : ''; ?>
<?php echo $is_checkbox ? checked( isset( $checked ) && $checked, true, false ) : ''; ?>
data-plugins="<?php echo esc_attr( json_encode( isset( $setting['plugins'] ) ? $setting['plugins'] : null ) ); ?>"
data-plugins="<?php echo esc_attr( wp_json_encode( isset( $setting['plugins'] ) ? $setting['plugins'] : null ) ); ?>"
/>
<?php if ( ! empty( $setting['description'] ) ) : ?>
<span class="wc-wizard-service-settings-description"><?php echo esc_html( $setting['description'] ); ?></span>
@ -1520,7 +1568,7 @@ class WC_Admin_Setup_Wizard {
type="checkbox"
name="wc-wizard-service-<?php echo esc_attr( $item_id ); ?>-enabled"
value="yes" <?php checked( $should_enable_toggle ); ?>
data-plugins="<?php echo esc_attr( json_encode( $plugins ) ); ?>"
data-plugins="<?php echo esc_attr( wp_json_encode( $plugins ) ); ?>"
/>
<label for="wc-wizard-service-<?php echo esc_attr( $item_id ); ?>">
</span>
@ -1689,7 +1737,7 @@ class WC_Admin_Setup_Wizard {
name="<?php echo esc_attr( 'setup_' . $type ); ?>"
value="yes"
checked
data-plugins="<?php echo esc_attr( json_encode( isset( $item_info['plugins'] ) ? $item_info['plugins'] : null ) ); ?>"
data-plugins="<?php echo esc_attr( wp_json_encode( isset( $item_info['plugins'] ) ? $item_info['plugins'] : null ) ); ?>"
/>
<label for="<?php echo esc_attr( 'wc_recommended_' . $type ); ?>">
<img

View File

@ -69,7 +69,7 @@ class WC_Admin_Webhooks_Table_List extends WP_List_Table {
* @return string
*/
public function column_title( $webhook ) {
$edit_link = admin_url( 'admin.php?page=wc-settings&amp;tab=api&amp;section=webhooks&amp;edit-webhook=' . $webhook->get_id() );
$edit_link = admin_url( 'admin.php?page=wc-settings&amp;tab=advanced&amp;section=webhooks&amp;edit-webhook=' . $webhook->get_id() );
$output = '';
// Title.
@ -175,7 +175,7 @@ class WC_Admin_Webhooks_Table_List extends WP_List_Table {
$class = empty( $_REQUEST['status'] ) ? ' class="current"' : ''; // WPCS: input var okay. CSRF ok.
/* translators: %s: count */
$status_links['all'] = "<a href='admin.php?page=wc-settings&amp;tab=api&amp;section=webhooks'$class>" . sprintf( _nx( 'All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $total_webhooks, 'posts', 'woocommerce' ), number_format_i18n( $total_webhooks ) ) . '</a>';
$status_links['all'] = "<a href='admin.php?page=wc-settings&amp;tab=advanced&amp;section=webhooks'$class>" . sprintf( _nx( 'All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $total_webhooks, 'posts', 'woocommerce' ), number_format_i18n( $total_webhooks ) ) . '</a>';
foreach ( $statuses as $status_name ) {
$class = '';
@ -190,7 +190,7 @@ class WC_Admin_Webhooks_Table_List extends WP_List_Table {
$label = $this->get_status_label( $status_name, $num_webhooks[ $status_name ] );
$status_links[ $status_name ] = "<a href='admin.php?page=wc-settings&amp;tab=api&amp;section=webhooks&amp;status=$status_name'$class>" . sprintf( translate_nooped_plural( $label, $num_webhooks[ $status_name ] ), number_format_i18n( $num_webhooks[ $status_name ] ) ) . '</a>';
$status_links[ $status_name ] = "<a href='admin.php?page=wc-settings&amp;tab=advanced&amp;section=webhooks&amp;status=$status_name'$class>" . sprintf( translate_nooped_plural( $label, $num_webhooks[ $status_name ] ), number_format_i18n( $num_webhooks[ $status_name ] ) ) . '</a>';
}
return $status_links;

View File

@ -279,7 +279,7 @@ class WC_Product_CSV_Importer_Controller {
);
// phpcs:disable WordPress.CSRF.NonceVerification.NoNonceVerification -- Nonce already verified in WC_Product_CSV_Importer_Controller::upload_form_handler()
$file_url = isset( $_POST['file_url'] ) ? esc_url_raw( wp_unslash( $_POST['file_url'] ) ) : '';
$file_url = isset( $_POST['file_url'] ) ? wc_clean( wp_unslash( $_POST['file_url'] ) ) : '';
if ( empty( $file_url ) ) {
if ( ! isset( $_FILES['import'] ) ) {
@ -295,7 +295,7 @@ class WC_Product_CSV_Importer_Controller {
'test_form' => false,
'mimes' => $valid_filetypes,
);
$import = wp_unslash( $_FILES['import'] ); // WPCS: sanitization ok.
$import = $_FILES['import']; // WPCS: sanitization ok, input var ok.
$upload = wp_handle_upload( $import, $overrides );
if ( isset( $upload['error'] ) ) {
@ -575,7 +575,7 @@ class WC_Product_CSV_Importer_Controller {
* @return string
*/
protected function sanitize_special_column_name_regex( $value ) {
return '/' . str_replace( array( '%d', '%s' ), '(.*)', quotemeta( $value ) ) . '/';
return '/' . str_replace( array( '%d', '%s' ), '(.*)', trim( quotemeta( $value ) ) ) . '/';
}
/**

View File

@ -162,6 +162,8 @@ class WC_Tax_Rate_Importer extends WP_Importer {
$tax_rate_id = WC_Tax::_insert_tax_rate( $tax_rate );
WC_Tax::_update_tax_rate_postcodes( $tax_rate_id, wc_clean( $postcode ) );
WC_Tax::_update_tax_rate_cities( $tax_rate_id, wc_clean( $city ) );
$row = fgetcsv( $handle, 0, $this->delimiter );
}
} else {
$this->import_error( __( 'The CSV is invalid.', 'woocommerce' ) );
@ -242,8 +244,8 @@ class WC_Tax_Rate_Importer extends WP_Importer {
echo '<div class="narrow">';
echo '<p>' . esc_html__( 'Hi there! Upload a CSV file containing tax rates to import the contents into your shop. Choose a .csv file to upload, then click "Upload file and import".', 'woocommerce' ) . '</p>';
/* translators: 1: Link to tax rates sample file */
echo '<p>' . sprintf( esc_html__( 'Tax rates need to be defined with columns in a specific order (10 columns). <a href="%s">Click here to download a sample</a>.', 'woocommerce' ), esc_url( WC()->plugin_url() ) . '/sample-data/sample_tax_rates.csv' ) . '</p>';
/* translators: 1: Link to tax rates sample file 2: Closing link. */
echo '<p>' . sprintf( esc_html__( 'Your CSV needs to include columns in a specific order. %1$sClick here to download a sample%2$s.', 'woocommerce' ), '<a href="' . esc_url( WC()->plugin_url() ) . '/sample-data/sample_tax_rates.csv">', '</a>' ) . '</p>';
$action = 'admin.php?import=woocommerce_tax_rate_csv&step=1';

View File

@ -623,7 +623,7 @@ class WC_Admin_List_Table_Orders extends WC_Admin_List_Table {
* @return string
*/
public function handle_bulk_actions( $redirect_to, $action, $ids ) {
$ids = array_map( 'absint', $ids );
$ids = apply_filters( 'woocommerce_bulk_action_ids', array_reverse( array_map( 'absint', $ids ) ), $action, 'order' );
$changed = 0;
if ( 'remove_personal_data' === $action ) {
@ -644,6 +644,9 @@ class WC_Admin_List_Table_Orders extends WC_Admin_List_Table {
// Sanity check: bail out if this is actually not a status, or is not a registered status.
if ( isset( $order_statuses[ 'wc-' . $new_status ] ) ) {
// Initialize payment gateways in case order has hooked status transition actions.
wc()->payment_gateways();
foreach ( $ids as $id ) {
$order = wc_get_order( $id );
$order->update_status( $new_status, __( 'Order status changed by bulk edit:', 'woocommerce' ), true );

View File

@ -293,6 +293,7 @@ class WC_Admin_List_Table_Products extends WC_Admin_List_Table {
wc_product_dropdown_categories(
array(
'option_select_text' => __( 'Filter by category', 'woocommerce' ),
'hide_empty' => 0,
)
);
} else {

View File

@ -332,7 +332,9 @@ class WC_Meta_Box_Order_Data {
$field_name = 'billing_' . $key;
if ( is_callable( array( $order, 'get_' . $field_name ) ) ) {
if ( isset( $field['value'] ) ) {
$field_value = $field['value'];
} elseif ( is_callable( array( $order, 'get_' . $field_name ) ) ) {
$field_value = $order->{"get_$field_name"}( 'edit' );
} else {
$field_value = $order->get_meta( '_' . $field_name );
@ -365,10 +367,12 @@ class WC_Meta_Box_Order_Data {
$field_name = 'billing_' . $key;
if ( is_callable( array( $order, 'get_' . $field_name ) ) ) {
$field['value'] = $order->{"get_$field_name"}( 'edit' );
} else {
$field['value'] = $order->get_meta( '_' . $field_name );
if ( ! isset( $field['value'] ) ) {
if ( is_callable( array( $order, 'get_' . $field_name ) ) ) {
$field['value'] = $order->{"get_$field_name"}( 'edit' );
} else {
$field['value'] = $order->get_meta( '_' . $field_name );
}
}
switch ( $field['type'] ) {

View File

@ -335,45 +335,45 @@ class WC_Meta_Box_Product_Data {
/* translators: 1: product ID 2: quantity in stock */
WC_Admin_Meta_Boxes::add_error( sprintf( __( 'The stock has not been updated because the value has changed since editing. Product %1$d has %2$d units in stock.', 'woocommerce' ), $product->get_id(), $product->get_stock_quantity( 'edit' ) ) );
} else {
$stock = wc_stock_amount( $_POST['_stock'] );
$stock = wc_stock_amount( wp_unslash( $_POST['_stock'] ) );
}
}
$errors = $product->set_props(
array(
'sku' => isset( $_POST['_sku'] ) ? wc_clean( $_POST['_sku'] ) : null,
'purchase_note' => wp_kses_post( stripslashes( $_POST['_purchase_note'] ) ),
'sku' => isset( $_POST['_sku'] ) ? wc_clean( wp_unslash( $_POST['_sku'] ) ) : null,
'purchase_note' => wp_kses_post( wp_unslash( $_POST['_purchase_note'] ) ),
'downloadable' => isset( $_POST['_downloadable'] ),
'virtual' => isset( $_POST['_virtual'] ),
'featured' => isset( $_POST['_featured'] ),
'catalog_visibility' => wc_clean( $_POST['_visibility'] ),
'tax_status' => isset( $_POST['_tax_status'] ) ? wc_clean( $_POST['_tax_status'] ) : null,
'tax_class' => isset( $_POST['_tax_class'] ) ? wc_clean( $_POST['_tax_class'] ) : null,
'weight' => wc_clean( $_POST['_weight'] ),
'length' => wc_clean( $_POST['_length'] ),
'width' => wc_clean( $_POST['_width'] ),
'height' => wc_clean( $_POST['_height'] ),
'shipping_class_id' => absint( $_POST['product_shipping_class'] ),
'catalog_visibility' => wc_clean( wp_unslash( $_POST['_visibility'] ) ),
'tax_status' => isset( $_POST['_tax_status'] ) ? wc_clean( wp_unslash( $_POST['_tax_status'] ) ) : null,
'tax_class' => isset( $_POST['_tax_class'] ) ? wc_clean( wp_unslash( $_POST['_tax_class'] ) ) : null,
'weight' => wc_clean( wp_unslash( $_POST['_weight'] ) ),
'length' => wc_clean( wp_unslash( $_POST['_length'] ) ),
'width' => wc_clean( wp_unslash( $_POST['_width'] ) ),
'height' => wc_clean( wp_unslash( $_POST['_height'] ) ),
'shipping_class_id' => absint( wp_unslash( $_POST['product_shipping_class'] ) ),
'sold_individually' => ! empty( $_POST['_sold_individually'] ),
'upsell_ids' => isset( $_POST['upsell_ids'] ) ? array_map( 'intval', (array) $_POST['upsell_ids'] ) : array(),
'cross_sell_ids' => isset( $_POST['crosssell_ids'] ) ? array_map( 'intval', (array) $_POST['crosssell_ids'] ) : array(),
'regular_price' => wc_clean( $_POST['_regular_price'] ),
'sale_price' => wc_clean( $_POST['_sale_price'] ),
'date_on_sale_from' => wc_clean( $_POST['_sale_price_dates_from'] ),
'date_on_sale_to' => wc_clean( $_POST['_sale_price_dates_to'] ),
'upsell_ids' => isset( $_POST['upsell_ids'] ) ? array_map( 'intval', (array) wp_unslash( $_POST['upsell_ids'] ) ) : array(),
'cross_sell_ids' => isset( $_POST['crosssell_ids'] ) ? array_map( 'intval', (array) wp_unslash( $_POST['crosssell_ids'] ) ) : array(),
'regular_price' => wc_clean( wp_unslash( $_POST['_regular_price'] ) ),
'sale_price' => wc_clean( wp_unslash( $_POST['_sale_price'] ) ),
'date_on_sale_from' => wc_clean( wp_unslash( $_POST['_sale_price_dates_from'] ) ),
'date_on_sale_to' => wc_clean( wp_unslash( $_POST['_sale_price_dates_to'] ) ),
'manage_stock' => ! empty( $_POST['_manage_stock'] ),
'backorders' => isset( $_POST['_backorders'] ) ? wc_clean( $_POST['_backorders'] ) : null,
'stock_status' => wc_clean( $_POST['_stock_status'] ),
'backorders' => isset( $_POST['_backorders'] ) ? wc_clean( wp_unslash( $_POST['_backorders'] ) ) : null,
'stock_status' => wc_clean( wp_unslash( $_POST['_stock_status'] ) ),
'stock_quantity' => $stock,
'download_limit' => '' === $_POST['_download_limit'] ? '' : absint( $_POST['_download_limit'] ),
'download_expiry' => '' === $_POST['_download_expiry'] ? '' : absint( $_POST['_download_expiry'] ),
'download_limit' => '' === $_POST['_download_limit'] ? '' : absint( wp_unslash( $_POST['_download_limit'] ) ),
'download_expiry' => '' === $_POST['_download_expiry'] ? '' : absint( wp_unslash( $_POST['_download_expiry'] ) ),
'downloads' => self::prepare_downloads(
isset( $_POST['_wc_file_names'] ) ? $_POST['_wc_file_names'] : array(),
isset( $_POST['_wc_file_urls'] ) ? $_POST['_wc_file_urls'] : array(),
isset( $_POST['_wc_file_hashes'] ) ? $_POST['_wc_file_hashes'] : array()
isset( $_POST['_wc_file_names'] ) ? wp_unslash( $_POST['_wc_file_names'] ) : array(),
isset( $_POST['_wc_file_urls'] ) ? wp_unslash( $_POST['_wc_file_urls'] ) : array(),
isset( $_POST['_wc_file_hashes'] ) ? wp_unslash( $_POST['_wc_file_hashes'] ) : array()
),
'product_url' => esc_url_raw( $_POST['_product_url'] ),
'button_text' => wc_clean( $_POST['_button_text'] ),
'product_url' => esc_url_raw( wp_unslash( $_POST['_product_url'] ) ),
'button_text' => wc_clean( wp_unslash( $_POST['_button_text'] ) ),
'children' => 'grouped' === $product_type ? self::prepare_children() : null,
'reviews_allowed' => ! empty( $_POST['comment_status'] ) && 'open' === $_POST['comment_status'],
'attributes' => $attributes,

View File

@ -30,7 +30,7 @@ if ( ! defined( 'ABSPATH' ) ) {
?>
<select name="default_attribute_<?php echo esc_attr( sanitize_title( $attribute->get_name() ) ); ?>" data-current="<?php echo esc_attr( $selected_value ); ?>">
<?php /* translators: WooCommerce attribute label */ ?>
<option value=""><?php esc_html( sprintf( __( 'No default %s&hellip;', 'woocommerce' ), wc_attribute_label( $attribute->get_name() ) ) ); ?></option>
<option value=""><?php echo esc_html( sprintf( __( 'No default %s&hellip;', 'woocommerce' ), wc_attribute_label( $attribute->get_name() ) ) ); ?></option>
<?php if ( $attribute->is_taxonomy() ) : ?>
<?php foreach ( $attribute->get_terms() as $option ) : ?>
<option <?php selected( $selected_value, $option->slug ); ?> value="<?php echo esc_attr( $option->slug ); ?>"><?php echo esc_html( apply_filters( 'woocommerce_variation_option_name', $option->name ) ); ?></option>

View File

@ -53,7 +53,7 @@ class WC_Settings_Payment_Gateways extends WC_Settings_Page {
'woocommerce_payment_gateways_settings', array(
array(
'title' => __( 'Payment methods', 'woocommerce' ),
'desc' => __( 'Installed payment methods are listed below. Drag and drop gateways to control their display order on the frontend.', 'woocommerce' ),
'desc' => __( 'Installed payment methods are listed below and can be sorted to control their display order on the frontend.', 'woocommerce' ),
'type' => 'title',
'id' => 'payment_gateways_options',
),
@ -107,7 +107,7 @@ class WC_Settings_Payment_Gateways extends WC_Settings_Page {
?>
<tr valign="top">
<td class="wc_payment_gateways_wrapper" colspan="2">
<table class="wc_gateways widefat" cellspacing="0">
<table class="wc_gateways widefat" cellspacing="0" aria-describedby="payment_gateways_options-description">
<thead>
<tr>
<?php
@ -145,17 +145,26 @@ class WC_Settings_Payment_Gateways extends WC_Settings_Page {
$width = '1%';
}
$method_title = $gateway->get_method_title() ? $gateway->get_method_title() : $gateway->get_title();
$custom_title = $gateway->get_title();
echo '<td class="' . esc_attr( $key ) . '" width="' . esc_attr( $width ) . '">';
switch ( $key ) {
case 'sort':
echo '<input type="hidden" name="gateway_order[]" value="' . esc_attr( $gateway->id ) . '" />';
?>
<div class="wc-item-reorder-nav">
<button type="button" class="wc-move-up" tabindex="0" aria-hidden="false" aria-label="<?php /* Translators: %s Payment gateway name. */ echo esc_attr( sprintf( __( 'Move the "%s" payment method up', 'woocommerce' ), $method_title ) ); ?>"><?php esc_html_e( 'Move up', 'woocommerce' ); ?></button>
<button type="button" class="wc-move-down" tabindex="0" aria-hidden="false" aria-label="<?php /* Translators: %s Payment gateway name. */ echo esc_attr( sprintf( __( 'Move the "%s" payment method down', 'woocommerce' ), $method_title ) ); ?>"><?php esc_html_e( 'Move down', 'woocommerce' ); ?></button>
<input type="hidden" name="gateway_order[]" value="<?php echo esc_attr( $gateway->id ); ?>" />
</div>
<?php
break;
case 'name':
$method_title = $gateway->get_title() ? $gateway->get_title() : __( '(no title)', 'woocommerce' );
echo '<a href="' . esc_url( admin_url( 'admin.php?page=wc-settings&tab=checkout&section=' . strtolower( $gateway->id ) ) ) . '" class="wc-payment-gateway-method-title">' . wp_kses_post( $gateway->get_method_title() ) . '</a>';
if ( $method_title !== $gateway->get_method_title() ) {
echo '<span class="wc-payment-gateway-method-name">&nbsp;&ndash;&nbsp;' . esc_html( $method_title ) . '</span>';
echo '<a href="' . esc_url( admin_url( 'admin.php?page=wc-settings&tab=checkout&section=' . strtolower( $gateway->id ) ) ) . '" class="wc-payment-gateway-method-title">' . wp_kses_post( $method_title ) . '</a>';
if ( $method_title !== $custom_title ) {
echo '<span class="wc-payment-gateway-method-name">&nbsp;&ndash;&nbsp;' . wp_kses_post( $custom_title ) . '</span>';
}
break;
case 'description':
@ -163,17 +172,21 @@ class WC_Settings_Payment_Gateways extends WC_Settings_Page {
break;
case 'action':
if ( wc_string_to_bool( $gateway->enabled ) ) {
echo '<a class="button alignright" href="' . esc_url( admin_url( 'admin.php?page=wc-settings&tab=checkout&section=' . strtolower( $gateway->id ) ) ) . '">' . esc_html__( 'Manage', 'woocommerce' ) . '</a>';
/* Translators: %s Payment gateway name. */
echo '<a class="button alignright" aria-label="' . esc_attr( sprintf( __( 'Manage the "%s" payment method', 'woocommerce' ), $method_title ) ) . '" href="' . esc_url( admin_url( 'admin.php?page=wc-settings&tab=checkout&section=' . strtolower( $gateway->id ) ) ) . '">' . esc_html__( 'Manage', 'woocommerce' ) . '</a>';
} else {
echo '<a class="button alignright" href="' . esc_url( admin_url( 'admin.php?page=wc-settings&tab=checkout&section=' . strtolower( $gateway->id ) ) ) . '">' . esc_html__( 'Set up', 'woocommerce' ) . '</a>';
/* Translators: %s Payment gateway name. */
echo '<a class="button alignright" aria-label="' . esc_attr( sprintf( __( 'Set up the "%s" payment method', 'woocommerce' ), $method_title ) ) . '" href="' . esc_url( admin_url( 'admin.php?page=wc-settings&tab=checkout&section=' . strtolower( $gateway->id ) ) ) . '">' . esc_html__( 'Set up', 'woocommerce' ) . '</a>';
}
break;
case 'status':
echo '<a class="wc-payment-gateway-method-toggle-enabled" href="' . esc_url( admin_url( 'admin.php?page=wc-settings&tab=checkout&section=' . strtolower( $gateway->id ) ) ) . '">';
if ( wc_string_to_bool( $gateway->enabled ) ) {
echo '<span class="woocommerce-input-toggle woocommerce-input-toggle--enabled">' . esc_attr__( 'Yes', 'woocommerce' ) . '</span>';
/* Translators: %s Payment gateway name. */
echo '<span class="woocommerce-input-toggle woocommerce-input-toggle--enabled" aria-label="' . esc_attr( sprintf( __( 'The "%s" payment method is currently enabled', 'woocommerce' ), $method_title ) ) . '">' . esc_attr__( 'Yes', 'woocommerce' ) . '</span>';
} else {
echo '<span class="woocommerce-input-toggle woocommerce-input-toggle--disabled">' . esc_attr__( 'No', 'woocommerce' ) . '</span>';
/* Translators: %s Payment gateway name. */
echo '<span class="woocommerce-input-toggle woocommerce-input-toggle--disabled" aria-label="' . esc_attr( sprintf( __( 'The "%s" payment method is currently disabled', 'woocommerce' ), $method_title ) ) . '">' . esc_attr__( 'No', 'woocommerce' ) . '</span>';
}
echo '</a>';
break;

View File

@ -99,6 +99,9 @@ if ( ! defined( 'ABSPATH' ) ) {
</tr>
</tbody>
</table>
<?php do_action( 'woocommerce_shipping_zone_after_methods_table' ); ?>
<p class="submit">
<button type="submit" name="submit" id="submit" class="button button-primary button-large wc-shipping-zone-method-save" value="<?php esc_attr_e( 'Save changes', 'woocommerce' ); ?>" disabled><?php esc_html_e( 'Save changes', 'woocommerce' ); ?></button>
</p>

View File

@ -85,8 +85,11 @@ if ( ! defined( 'ABSPATH' ) ) {
);
foreach ( $topics as $topic_slug => $topic_name ) :
$selected = $topic_slug === $topic_data['topic'] || $topic_slug === $topic_data['resource'] . '.' . $topic_data['event'];
?>
<option value="<?php echo esc_attr( $topic_slug ); ?>" <?php selected( $topic_data['topic'], $topic_slug, true ); ?>><?php echo esc_html( $topic_name ); ?></option>
<option value="<?php echo esc_attr( $topic_slug ); ?>" <?php selected( $selected, true, true ); ?>><?php echo esc_html( $topic_name ); ?></option>
<?php endforeach; ?>
</select>
</td>

View File

@ -191,16 +191,18 @@ $untested_plugins = $plugin_updates->get_untested_plugins( WC()->version, 'minor
echo '<mark class="yes">' . esc_html( $environment['php_version'] ) . '</mark>';
} else {
$update_link = ' <a href="https://docs.woocommerce.com/document/how-to-update-your-php-version/" target="_blank">' . esc_html__( 'How to update your PHP version', 'woocommerce' ) . '</a>';
$class = 'error';
if ( version_compare( $environment['php_version'], '5.4', '<' ) ) {
$notice = __( 'WooCommerce will run under this version of PHP, however, some features such as geolocation are not compatible. Support for this version will be dropped in the next major release. We recommend using PHP version 7.2 or above for greater performance and security.', 'woocommerce' ) . $update_link;
$notice = '<span class="dashicons dashicons-warning"></span> ' . __( 'WooCommerce will run under this version of PHP, however, some features such as geolocation are not compatible. Support for this version will be dropped in the next major release. We recommend using PHP version 7.2 or above for greater performance and security.', 'woocommerce' ) . $update_link;
} elseif ( version_compare( $environment['php_version'], '5.6', '<' ) ) {
$notice = __( 'WooCommerce will run under this version of PHP, however, it has reached end of life. We recommend using PHP version 7.2 or above for greater performance and security.', 'woocommerce' ) . $update_link;
$notice = '<span class="dashicons dashicons-warning"></span> ' . __( 'WooCommerce will run under this version of PHP, however, it has reached end of life. We recommend using PHP version 7.2 or above for greater performance and security.', 'woocommerce' ) . $update_link;
} elseif ( version_compare( $environment['php_version'], '7.2', '<' ) ) {
$notice = __( 'We recommend using PHP version 7.2 or above for greater performance and security.', 'woocommerce' ) . $update_link;
$class = 'recommendation';
}
echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . esc_html( $environment['php_version'] ) . ' - ' . wp_kses_post( $notice ) . '</mark>';
echo '<mark class="' . esc_attr( $class ) . '">' . esc_html( $environment['php_version'] ) . ' - ' . wp_kses_post( $notice ) . '</mark>';
}
?>
</td>
@ -235,18 +237,18 @@ $untested_plugins = $plugin_updates->get_untested_plugins( WC()->version, 'minor
<?php
if ( ! empty( $wpdb->is_mysql ) ) :
if ( $environment['mysql_version'] ) :
?>
<tr>
<td data-export-label="MySQL Version"><?php esc_html_e( 'MySQL version', 'woocommerce' ); ?>:</td>
<td class="help"><?php echo wc_help_tip( esc_html__( 'The version of MySQL installed on your hosting server.', 'woocommerce' ) ); /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></td>
<td>
<?php
if ( version_compare( $environment['mysql_version'], '5.6', '<' ) ) {
if ( version_compare( $environment['mysql_version'], '5.6', '<' ) && ! strstr( $environment['mysql_version_string'], 'MariaDB' ) ) {
/* Translators: %1$s: MySQL version, %2$s: Recommended MySQL version. */
echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( esc_html__( '%1$s - We recommend a minimum MySQL version of 5.6. See: %2$s', 'woocommerce' ), esc_html( $environment['mysql_version'] ), '<a href="https://wordpress.org/about/requirements/" target="_blank">' . esc_html__( 'WordPress requirements', 'woocommerce' ) . '</a>' ) . '</mark>';
echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( esc_html__( '%1$s - We recommend a minimum MySQL version of 5.6. See: %2$s', 'woocommerce' ), esc_html( $environment['mysql_version_string'] ), '<a href="https://wordpress.org/about/requirements/" target="_blank">' . esc_html__( 'WordPress requirements', 'woocommerce' ) . '</a>' ) . '</mark>';
} else {
echo '<mark class="yes">' . esc_html( $environment['mysql_version'] ) . '</mark>';
echo '<mark class="yes">' . esc_html( $environment['mysql_version_string'] ) . '</mark>';
}
?>
</td>

View File

@ -11,6 +11,8 @@ if ( ! defined( 'ABSPATH' ) ) {
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed aliquet diam a facilisis eleifend. Cras ac justo felis. Mauris faucibus, orci eu blandit fermentum, lorem nibh sollicitudin mi, sit amet interdum metus urna ut lacus.</p>
<p><a class="link" href="#">Sed sit amet sapien odio</a></p>
<p>Phasellus quis varius augue. Fusce eu euismod leo, a accumsan tellus. Quisque vitae dolor eu justo cursus egestas. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Sed sit amet sapien odio. Sed pellentesque arcu mi, quis malesuada lectus lacinia et. Cras a tempor leo.</p>
<h2>Lorem ipsum dolor</h2>

View File

@ -1,16 +1,30 @@
<?php
/**
* Admin View: Notice - Update
*
* @package WooCommerce\Admin
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
$update_url = wp_nonce_url(
add_query_arg( 'do_update_woocommerce', 'true', admin_url( 'admin.php?page=wc-settings' ) ),
'wc_db_update',
'wc_db_update_nonce'
);
?>
<div id="message" class="updated woocommerce-message wc-connect">
<p><strong><?php _e( 'WooCommerce data update', 'woocommerce' ); ?></strong> &#8211; <?php _e( 'We need to update your store database to the latest version.', 'woocommerce' ); ?></p>
<p class="submit"><a href="<?php echo esc_url( add_query_arg( 'do_update_woocommerce', 'true', admin_url( 'admin.php?page=wc-settings' ) ) ); ?>" class="wc-update-now button-primary"><?php _e( 'Run the updater', 'woocommerce' ); ?></a></p>
<p>
<strong><?php esc_html_e( 'WooCommerce data update', 'woocommerce' ); ?></strong> &#8211; <?php esc_html_e( 'We need to update your store database to the latest version.', 'woocommerce' ); ?>
</p>
<p class="submit">
<a href="<?php echo esc_url( $update_url ); ?>" class="wc-update-now button-primary">
<?php esc_html_e( 'Run the updater', 'woocommerce' ); ?>
</a>
</p>
</div>
<script type="text/javascript">
jQuery( '.wc-update-now' ).click( 'click', function() {

View File

@ -1,13 +1,26 @@
<?php
/**
* Admin View: Notice - Updating
*
* @package WooCommerce\Admin
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
$force_update_url = wp_nonce_url(
add_query_arg( 'force_update_woocommerce', 'true', admin_url( 'admin.php?page=wc-settings' ) ),
'wc_force_db_update',
'wc_force_db_update_nonce'
);
?>
<div id="message" class="updated woocommerce-message wc-connect">
<p><strong><?php _e( 'WooCommerce data update', 'woocommerce' ); ?></strong> &#8211; <?php _e( 'Your database is being updated in the background.', 'woocommerce' ); ?> <a href="<?php echo esc_url( add_query_arg( 'force_update_woocommerce', 'true', admin_url( 'admin.php?page=wc-settings' ) ) ); ?>"><?php _e( 'Taking a while? Click here to run it now.', 'woocommerce' ); ?></a></p>
<p>
<strong><?php esc_html_e( 'WooCommerce data update', 'woocommerce' ); ?></strong> &#8211; <?php esc_html_e( 'Your database is being updated in the background.', 'woocommerce' ); ?>
<a href="<?php echo esc_url( $force_update_url ); ?>">
<?php esc_html_e( 'Taking a while? Click here to run it now.', 'woocommerce' ); ?>
</a>
</p>
</div>

View File

@ -78,7 +78,11 @@ class WC_REST_Authentication {
}
if ( is_ssl() ) {
return $this->perform_basic_authentication();
$user_id = $this->perform_basic_authentication();
}
if ( $user_id ) {
return $user_id;
}
return $this->perform_oauth_authentication();

View File

@ -127,14 +127,20 @@ class WC_REST_Orders_Controller extends WC_REST_Legacy_Orders_Controller {
}
/**
* Get object.
* Get object. Return false if object is not of required type.
*
* @since 3.0.0
* @param int $id Object ID.
* @return WC_Data
* @return WC_Data|bool
*/
protected function get_object( $id ) {
return wc_get_order( $id );
$order = wc_get_order( $id );
// In case id is a refund's id (or it's not an order at all), don't expose it via /orders/ path.
if ( ! $order || 'shop_order_refund' === $order->get_type() ) {
return false;
}
return $order;
}
/**

View File

@ -1064,9 +1064,9 @@ class WC_REST_Products_Controller extends WC_REST_Legacy_Products_Controller {
$images = is_array( $images ) ? array_filter( $images ) : array();
if ( ! empty( $images ) ) {
$gallery = array();
$gallery_positions = array();
foreach ( $images as $image ) {
foreach ( $images as $index => $image ) {
$attachment_id = isset( $image['id'] ) ? absint( $image['id'] ) : 0;
if ( 0 === $attachment_id && isset( $image['src'] ) ) {
@ -1088,11 +1088,7 @@ class WC_REST_Products_Controller extends WC_REST_Legacy_Products_Controller {
throw new WC_REST_Exception( 'woocommerce_product_invalid_image_id', sprintf( __( '#%s is an invalid image ID.', 'woocommerce' ), $attachment_id ), 400 );
}
if ( isset( $image['position'] ) && 0 === absint( $image['position'] ) ) {
$product->set_image_id( $attachment_id );
} else {
$gallery[] = $attachment_id;
}
$gallery_positions[ $attachment_id ] = absint( isset( $image['position'] ) ? $image['position'] : $index );
// Set the image alt if present.
if ( ! empty( $image['alt'] ) ) {
@ -1115,6 +1111,17 @@ class WC_REST_Products_Controller extends WC_REST_Legacy_Products_Controller {
}
}
// Sort images and get IDs in correct order.
asort( $gallery_positions );
// Get gallery in correct order.
$gallery = array_keys( $gallery_positions );
// Featured image is in position 0.
$image_id = array_shift( $gallery );
// Set images.
$product->set_image_id( $image_id );
$product->set_gallery_image_ids( $gallery );
} else {
$product->set_image_id( '' );

View File

@ -228,6 +228,12 @@ class WC_REST_System_Status_Controller extends WC_REST_Controller {
'context' => array( 'view' ),
'readonly' => true,
),
'mysql_version_string' => array(
'description' => __( 'MySQL version string.', 'woocommerce' ),
'type' => 'string',
'context' => array( 'view' ),
'readonly' => true,
),
'default_timezone' => array(
'description' => __( 'Default timezone.', 'woocommerce' ),
'type' => 'string',
@ -597,6 +603,8 @@ class WC_REST_System_Status_Controller extends WC_REST_Controller {
$get_response_successful = true;
}
$database_version = wc_get_server_database_version();
// Return all environment info. Described by JSON Schema.
return array(
'home_url' => get_option( 'home' ),
@ -619,7 +627,8 @@ class WC_REST_System_Status_Controller extends WC_REST_Controller {
'curl_version' => $curl_version,
'suhosin_installed' => extension_loaded( 'suhosin' ),
'max_upload_size' => wp_max_upload_size(),
'mysql_version' => ( ! empty( $wpdb->is_mysql ) ? $wpdb->db_version() : '' ),
'mysql_version' => $database_version['number'],
'mysql_version_string' => $database_version['string'],
'default_timezone' => date_default_timezone_get(),
'fsockopen_or_curl_enabled' => ( function_exists( 'fsockopen' ) || function_exists( 'curl_init' ) ),
'soapclient_enabled' => class_exists( 'SoapClient' ),

View File

@ -409,6 +409,15 @@ class WC_REST_System_Status_Tools_Controller extends WC_REST_Controller {
case 'clear_transients':
wc_delete_product_transients();
wc_delete_shop_order_transients();
$attribute_taxonomies = wc_get_attribute_taxonomies();
if ( $attribute_taxonomies ) {
foreach ( $attribute_taxonomies as $attribute ) {
delete_transient( 'wc_layered_nav_counts_pa_' . $attribute->attribute_name );
}
}
WC_Cache_Helper::get_transient_version( 'shipping', true );
$message = __( 'Product transients cleared', 'woocommerce' );
break;

View File

@ -274,7 +274,7 @@ class WC_AJAX {
wc_maybe_define_constant( 'WOOCOMMERCE_CHECKOUT', true );
if ( WC()->cart->is_empty() && ! is_customize_preview() ) {
if ( WC()->cart->is_empty() && ! is_customize_preview() && apply_filters( 'woocommerce_checkout_update_order_review_expired', true ) ) {
self::update_order_review_expired();
}
@ -345,11 +345,10 @@ class WC_AJAX {
$woocommerce_checkout_payment = ob_get_clean();
// Get messages if reload checkout is not true
$messages = '';
if ( ! isset( WC()->session->reload_checkout ) ) {
ob_start();
wc_print_notices();
$messages = ob_get_clean();
$messages = wc_print_notices( true );
} else {
$messages = '';
}
unset( WC()->session->refresh_totals, WC()->session->reload_checkout );

View File

@ -287,6 +287,7 @@ class WC_Auth {
* Handle auth requests.
*
* @since 2.4.0
* @throws Exception When auth_endpoint validation fails.
*/
public function handle_auth_requests() {
global $wp;
@ -295,7 +296,7 @@ class WC_Auth {
$wp->query_vars['wc-auth-version'] = wc_clean( wp_unslash( $_GET['wc-auth-version'] ) ); // WPCS: input var ok, CSRF ok.
}
if ( ! empty( $_GET['wc-auth-route'] ) ) {
if ( ! empty( $_GET['wc-auth-route'] ) ) { // WPCS: input var ok, CSRF ok.
$wp->query_vars['wc-auth-route'] = wc_clean( wp_unslash( $_GET['wc-auth-route'] ) ); // WPCS: input var ok, CSRF ok.
}
@ -318,10 +319,6 @@ class WC_Auth {
$consumer_data = array();
try {
if ( 'yes' !== get_option( 'woocommerce_api_enabled' ) ) {
throw new Exception( __( 'API disabled!', 'woocommerce' ) );
}
$route = strtolower( wc_clean( $route ) );
$this->make_validation();

View File

@ -93,7 +93,7 @@ class WC_Background_Updater extends WC_Background_Process {
* item from the queue.
*
* @param string $callback Update callback function.
* @return mixed
* @return string|bool
*/
protected function task( $callback ) {
wc_maybe_define_constant( 'WC_UPDATING', true );
@ -102,15 +102,22 @@ class WC_Background_Updater extends WC_Background_Process {
include_once dirname( __FILE__ ) . '/wc-update-functions.php';
$result = false;
if ( is_callable( $callback ) ) {
$logger->info( sprintf( 'Running %s callback', $callback ), array( 'source' => 'wc_db_updates' ) );
call_user_func( $callback );
$logger->info( sprintf( 'Finished %s callback', $callback ), array( 'source' => 'wc_db_updates' ) );
$result = (bool) call_user_func( $callback );
if ( $result ) {
$logger->info( sprintf( '%s callback needs to run again', $callback ), array( 'source' => 'wc_db_updates' ) );
} else {
$logger->info( sprintf( 'Finished running %s callback', $callback ), array( 'source' => 'wc_db_updates' ) );
}
} else {
$logger->notice( sprintf( 'Could not find %s callback', $callback ), array( 'source' => 'wc_db_updates' ) );
}
return false;
return $result ? $callback : false;
}
/**

View File

@ -222,7 +222,7 @@ class WC_Cache_Helper {
if ( 'product_cat' === $taxonomy ) {
$ids = is_array( $ids ) ? $ids : array( $ids );
$clear_ids = array();
$clear_ids = array( 0 );
foreach ( $ids as $id ) {
$clear_ids[] = $id;

View File

@ -1402,6 +1402,11 @@ class WC_Cart extends WC_Legacy_Cart {
}
}
// If we're on the cart page, the user has not calculated shipping, and there is no calculator available, hide the area.
if ( is_cart() && ! $this->get_customer()->has_calculated_shipping() && 'no' === get_option( 'woocommerce_enable_shipping_calc' ) ) {
return false;
}
return apply_filters( 'woocommerce_cart_ready_to_calc_shipping', true );
}
@ -1452,12 +1457,13 @@ class WC_Cart extends WC_Legacy_Cart {
// Get user and posted emails to compare.
$current_user = wp_get_current_user();
$check_emails = array_unique(
$billing_email = isset( $posted['billing_email'] ) ? $posted['billing_email'] : '';
$check_emails = array_unique(
array_filter(
array_map(
'strtolower', array_map(
'sanitize_email', array(
$posted['billing_email'],
$billing_email,
$current_user->user_email,
)
)

View File

@ -645,8 +645,9 @@ class WC_Checkout {
*/
protected function validate_posted_data( &$data, &$errors ) {
foreach ( $this->get_checkout_fields() as $fieldset_key => $fieldset ) {
$validate_fieldset = true;
if ( $this->maybe_skip_fieldset( $fieldset_key, $data ) ) {
continue;
$validate_fieldset = false;
}
foreach ( $fieldset as $key => $field ) {
@ -672,16 +673,24 @@ class WC_Checkout {
$country = isset( $data[ $fieldset_key . '_country' ] ) ? $data[ $fieldset_key . '_country' ] : WC()->customer->{"get_{$fieldset_key}_country"}();
$data[ $key ] = wc_format_postcode( $data[ $key ], $country );
if ( '' !== $data[ $key ] && ! WC_Validation::is_postcode( $data[ $key ], $country ) ) {
/* translators: %s: field name */
$errors->add( 'validation', sprintf( __( '%s is not a valid postcode / ZIP.', 'woocommerce' ), '<strong>' . esc_html( $field_label ) . '</strong>' ) );
if ( $validate_fieldset && '' !== $data[ $key ] && ! WC_Validation::is_postcode( $data[ $key ], $country ) ) {
switch ( $country ) {
case 'IE':
/* translators: %1$s: field name, %2$s finder.eircode.ie URL */
$postcode_validation_notice = sprintf( __( '%1$s is not valid. You can look up the correct Eircode <a target="_blank" href="%2$s">here</a>.', 'woocommerce' ), '<strong>' . esc_html( $field_label ) . '</strong>', 'https://finder.eircode.ie' );
break;
default:
/* translators: %s: field name */
$postcode_validation_notice = sprintf( __( '%s is not a valid postcode / ZIP.', 'woocommerce' ), '<strong>' . esc_html( $field_label ) . '</strong>' );
}
$errors->add( 'validation', apply_filters( 'woocommerce_checkout_postcode_validation_notice', $postcode_validation_notice, $country, $data[ $key ] ) );
}
}
if ( in_array( 'phone', $format, true ) ) {
$data[ $key ] = wc_format_phone_number( $data[ $key ] );
if ( '' !== $data[ $key ] && ! WC_Validation::is_phone( $data[ $key ] ) ) {
if ( $validate_fieldset && '' !== $data[ $key ] && ! WC_Validation::is_phone( $data[ $key ] ) ) {
/* translators: %s: phone number */
$errors->add( 'validation', sprintf( __( '%s is not a valid phone number.', 'woocommerce' ), '<strong>' . esc_html( $field_label ) . '</strong>' ) );
}
@ -690,7 +699,7 @@ class WC_Checkout {
if ( in_array( 'email', $format, true ) && '' !== $data[ $key ] ) {
$data[ $key ] = sanitize_email( $data[ $key ] );
if ( ! is_email( $data[ $key ] ) ) {
if ( $validate_fieldset && ! is_email( $data[ $key ] ) ) {
/* translators: %s: email address */
$errors->add( 'validation', sprintf( __( '%s is not a valid email address.', 'woocommerce' ), '<strong>' . esc_html( $field_label ) . '</strong>' ) );
continue;
@ -710,14 +719,14 @@ class WC_Checkout {
$data[ $key ] = $valid_state_values[ $data[ $key ] ];
}
if ( ! in_array( $data[ $key ], $valid_state_values, true ) ) {
if ( $validate_fieldset && ! in_array( $data[ $key ], $valid_state_values, true ) ) {
/* translators: 1: state field 2: valid states */
$errors->add( 'validation', sprintf( __( '%1$s is not valid. Please enter one of the following: %2$s', 'woocommerce' ), '<strong>' . esc_html( $field_label ) . '</strong>', implode( ', ', $valid_states ) ) );
}
}
}
if ( $required && '' === $data[ $key ] ) {
if ( $validate_fieldset && $required && '' === $data[ $key ] ) {
/* translators: %s: field name */
$errors->add( 'required-field', apply_filters( 'woocommerce_checkout_required_field_notice', sprintf( __( '%s is a required field.', 'woocommerce' ), '<strong>' . esc_html( $field_label ) . '</strong>' ), $field_label ) );
}
@ -968,9 +977,7 @@ class WC_Checkout {
if ( is_ajax() ) {
// Only print notices if not reloading the checkout, otherwise they're lost in the page reload.
if ( ! isset( WC()->session->reload_checkout ) ) {
ob_start();
wc_print_notices();
$messages = ob_get_clean();
$messages = wc_print_notices( true );
}
$response = array(

View File

@ -118,7 +118,9 @@ class WC_Countries {
'KR' => array(),
'KW' => array(),
'LB' => array(),
'LU' => array(),
'MQ' => array(),
'MT' => array(),
'NL' => array(),
'NO' => array(),
'PL' => array(),
@ -515,10 +517,11 @@ class WC_Countries {
/**
* Get country address format.
*
* @param array $args Arguments.
* @param array $args Arguments.
* @param string $separator How to separate address lines. @since 3.5.0.
* @return string
*/
public function get_formatted_address( $args = array() ) {
public function get_formatted_address( $args = array(), $separator = '<br/>' ) {
$default_args = array(
'first_name' => '',
'last_name' => '',
@ -545,7 +548,7 @@ class WC_Countries {
$full_country = ( isset( $this->countries[ $country ] ) ) ? $this->countries[ $country ] : $country;
// Country is not needed if the same as base.
if ( $country === $this->get_base_country() && ! apply_filters( 'woocommerce_formatted_address_force_country_display', false ) ) {
if ( $country === $this->get_base_country() && ! apply_filters( 'woocommerce_formatted_address_force_country_display', true ) ) {
$format = str_replace( '{country}', '', $format );
}
@ -591,7 +594,7 @@ class WC_Countries {
$formatted_address = array_filter( array_map( array( $this, 'trim_formatted_address_line' ), explode( "\n", $formatted_address ) ) );
// Add html breaks.
$formatted_address = implode( '<br/>', $formatted_address );
$formatted_address = implode( $separator, $formatted_address );
// We're done!
return $formatted_address;
@ -788,6 +791,11 @@ class WC_Countries {
'label' => __( 'Province', 'woocommerce' ),
),
),
'BH' => array(
'state' => array(
'required' => false,
),
),
'BI' => array(
'state' => array(
'required' => false,
@ -984,6 +992,11 @@ class WC_Countries {
'required' => false,
),
),
'MT' => array(
'state' => array(
'required' => false,
),
),
'NL' => array(
'postcode' => array(
'priority' => 65,
@ -1091,6 +1104,11 @@ class WC_Countries {
'required' => false,
),
),
'LU' => array(
'state' => array(
'required' => false,
),
),
'MD' => array(
'state' => array(
'label' => __( 'Municipality / District', 'woocommerce' ),

View File

@ -83,19 +83,26 @@ class WC_Coupon extends WC_Legacy_Coupon {
public function __construct( $data = '' ) {
parent::__construct( $data );
// If we already have a coupon object, read it again.
if ( $data instanceof WC_Coupon ) {
$this->set_id( absint( $data->get_id() ) );
$this->read_object_from_database();
return;
}
// This filter allows custom coupon objects to be created on the fly.
$coupon = apply_filters( 'woocommerce_get_shop_coupon_data', false, $data );
if ( $coupon ) {
$this->read_manual_coupon( $data, $coupon );
return;
} elseif ( is_int( $data ) && 'shop_coupon' === get_post_type( $data ) ) {
}
// Try to load coupon using ID or code.
if ( is_int( $data ) && 'shop_coupon' === get_post_type( $data ) ) {
$this->set_id( $data );
} elseif ( ! empty( $data ) ) {
$id = wc_get_coupon_id_by_code( $data );
// Need to support numeric strings for backwards compatibility.
if ( ! $id && 'shop_coupon' === get_post_type( $data ) ) {
$this->set_id( $data );
@ -107,12 +114,21 @@ class WC_Coupon extends WC_Legacy_Coupon {
$this->set_object_read( true );
}
$this->read_object_from_database();
}
/**
* If the object has an ID, read using the data store.
*
* @since 3.4.1
*/
protected function read_object_from_database() {
$this->data_store = WC_Data_Store::load( 'coupon' );
if ( $this->get_id() > 0 ) {
$this->data_store->read( $this );
}
}
/**
* Checks the coupon type.
*

View File

@ -119,6 +119,8 @@ class WC_Data_Store {
/**
* Re-run the constructor with the object type.
*
* @throws Exception When validation fails.
*/
public function __wakeup() {
$this->__construct( $this->object_type );
@ -130,6 +132,7 @@ class WC_Data_Store {
* @param string $object_type Name of object.
*
* @since 3.0.0
* @throws Exception When validation fails.
* @return WC_Data_Store
*/
public static function load( $object_type ) {

View File

@ -45,11 +45,7 @@ class WC_DateTime extends DateTime {
* Get UTC offset if set, or default to the DateTime object's offset.
*/
public function getOffset() {
if ( $this->utc_offset ) {
return $this->utc_offset;
} else {
return parent::getOffset();
}
return $this->utc_offset ? $this->utc_offset : parent::getOffset();
}
/**

View File

@ -17,7 +17,7 @@ class WC_Discounts {
* Reference to cart or order object.
*
* @since 3.2.0
* @var array
* @var WC_Cart|WC_Order
*/
protected $object;
@ -36,11 +36,11 @@ class WC_Discounts {
protected $discounts = array();
/**
* Constructor.
* WC_Discounts Constructor.
*
* @param array $object Cart or order object.
* @param WC_Cart|WC_Order $object Cart or order object.
*/
public function __construct( $object = array() ) {
public function __construct( $object = null ) {
if ( is_a( $object, 'WC_Cart' ) ) {
$this->set_items_from_cart( $object );
} elseif ( is_a( $object, 'WC_Order' ) ) {
@ -93,7 +93,7 @@ class WC_Discounts {
* Normalise order items which will be discounted.
*
* @since 3.2.0
* @param array $order Cart object.
* @param WC_Order $order Order object.
*/
public function set_items_from_order( $order ) {
$this->items = array();
@ -239,6 +239,7 @@ class WC_Discounts {
* @since 3.2.0
* @param WC_Coupon $coupon Coupon object being applied to the items.
* @param bool $validate Set to false to skip coupon validation.
* @throws Exception Error message when coupon isn't valid.
* @return bool|WP_Error True if applied or WP_Error instance in failure.
*/
public function apply_coupon( $coupon, $validate = true ) {
@ -257,7 +258,6 @@ class WC_Discounts {
}
$items_to_apply = $this->get_items_to_apply_coupon( $coupon );
$coupon_type = $coupon->get_discount_type();
// Core discounts are handled here as of 3.2.
switch ( $coupon->get_discount_type() ) {
@ -499,11 +499,28 @@ class WC_Discounts {
* @return int Total discounted.
*/
protected function apply_coupon_custom( $coupon, $items_to_apply ) {
$limit_usage_qty = 0;
$applied_count = 0;
if ( null !== $coupon->get_limit_usage_to_x_items() ) {
$limit_usage_qty = $coupon->get_limit_usage_to_x_items();
}
// Apply the coupon to each item.
foreach ( $items_to_apply as $item ) {
$discounted_price = $this->get_discounted_price_in_cents( $item );
// Find out how much price is available to discount for the item.
$discounted_price = $this->get_discounted_price_in_cents( $item );
// Get the price we actually want to discount, based on settings.
$price_to_discount = wc_remove_number_precision( ( 'yes' === get_option( 'woocommerce_calc_discounts_sequentially', 'no' ) ) ? $discounted_price : $item->price );
$discount = wc_add_number_precision( $coupon->get_discount_amount( $price_to_discount / $item->quantity, $item->object, true ) ) * $item->quantity;
$discount = min( $discounted_price, $discount );
// See how many and what price to apply to.
$apply_quantity = $limit_usage_qty && ( $limit_usage_qty - $applied_count ) < $item->quantity ? $limit_usage_qty - $applied_count : $item->quantity;
$apply_quantity = max( 0, apply_filters( 'woocommerce_coupon_get_apply_quantity', $apply_quantity, $item, $coupon, $this ) );
// Run coupon calculations.
$discount = wc_add_number_precision( $coupon->get_discount_amount( $price_to_discount / $item->quantity, $item->object, true ) ) * $apply_quantity;
$discount = wc_round_discount( min( $discounted_price, $discount ), 0 );
// Store code and discount amount per item.
$this->discounts[ $coupon->get_code() ][ $item->key ] += $discount;

View File

@ -161,8 +161,16 @@ class WC_Emails {
self::instance(); // Init self so emails exist.
do_action_ref_array( current_filter() . '_notification', $args );
} catch ( Exception $e ) {
$error = 'Transactional email triggered fatal error for callback ' . current_filter();
$logger = wc_get_logger();
$logger->critical(
$error . PHP_EOL,
array(
'source' => 'transactional-emails',
)
);
if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
trigger_error( 'Transactional email triggered fatal error for callback ' . current_filter(), E_USER_WARNING ); // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped, WordPress.PHP.DevelopmentFunctions.error_log_trigger_error
trigger_error( $error, E_USER_WARNING ); // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped, WordPress.PHP.DevelopmentFunctions.error_log_trigger_error
}
}
}

View File

@ -167,7 +167,7 @@ class WC_Frontend_Scripts {
'flexslider' => array(
'src' => self::get_asset_url( 'assets/js/flexslider/jquery.flexslider' . $suffix . '.js' ),
'deps' => array( 'jquery' ),
'version' => '2.7.0',
'version' => '2.7.1',
),
'js-cookie' => array(
'src' => self::get_asset_url( 'assets/js/js-cookie/js.cookie' . $suffix . '.js' ),

View File

@ -140,7 +140,7 @@ class WC_Geolocation {
} elseif ( isset( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) { // WPCS: input var ok, CSRF ok.
// Proxy servers can send through this header like this: X-Forwarded-For: client1, proxy1, proxy2
// Make sure we always only send through the first IP in the list which should always be the client IP.
return (string) rest_is_ip_address( trim( current( preg_split( '/[,:]/', sanitize_text_field( wp_unslash( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) ) ) ) ); // WPCS: input var ok, CSRF ok.
return (string) rest_is_ip_address( trim( current( preg_split( '/,/', sanitize_text_field( wp_unslash( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) ) ) ) ); // WPCS: input var ok, CSRF ok.
} elseif ( isset( $_SERVER['REMOTE_ADDR'] ) ) { // @codingStandardsIgnoreLine
return sanitize_text_field( wp_unslash( $_SERVER['REMOTE_ADDR'] ) ); // @codingStandardsIgnoreLine
}

View File

@ -101,6 +101,7 @@ class WC_Install {
),
'3.4.0' => array(
'wc_update_340_states',
'wc_update_340_state',
'wc_update_340_last_active',
'wc_update_340_db_version',
),
@ -154,13 +155,19 @@ class WC_Install {
* This function is hooked into admin_init to affect admin only.
*/
public static function install_actions() {
if ( ! empty( $_GET['do_update_woocommerce'] ) ) { // WPCS: input var ok, CSRF ok.
if ( ! empty( $_GET['do_update_woocommerce'] ) ) { // WPCS: input var ok.
check_admin_referer( 'wc_db_update', 'wc_db_update_nonce' );
self::update();
WC_Admin_Notices::add_notice( 'update' );
}
if ( ! empty( $_GET['force_update_woocommerce'] ) ) { // WPCS: input var ok, CSRF ok.
if ( ! empty( $_GET['force_update_woocommerce'] ) ) { // WPCS: input var ok.
check_admin_referer( 'wc_force_db_update', 'wc_force_db_update_nonce' );
$blog_id = get_current_blog_id();
// Used to fire an action added in WP_Background_Process::_construct() that calls WP_Background_Process::handle_cron_healthcheck().
// This method will make sure the database updates are executed even if cron is disabled. Nothing will happen if the updates are already running.
do_action( 'wp_' . $blog_id . '_wc_updater_cron' );
wp_safe_redirect( admin_url( 'admin.php?page=wc-settings' ) );
exit;
}
@ -543,8 +550,23 @@ class WC_Install {
$wpdb->query( "ALTER TABLE {$wpdb->comments} ADD INDEX woo_idx_comment_type (comment_type)" );
}
// Add constraint to download logs.
$wpdb->query( "ALTER TABLE {$wpdb->prefix}wc_download_log ADD FOREIGN KEY (permission_id) REFERENCES {$wpdb->prefix}woocommerce_downloadable_product_permissions(permission_id) ON DELETE CASCADE" );
// Get tables data types and check it matches before adding constraint.
$download_log_columns = $wpdb->get_results( "SHOW COLUMNS FROM {$wpdb->prefix}wc_download_log WHERE Field = 'permission_id'", ARRAY_A );
$download_log_column_type = '';
if ( isset( $download_log_columns[0]['Type'] ) ) {
$download_log_column_type = $download_log_columns[0]['Type'];
}
$download_permissions_columns = $wpdb->get_results( "SHOW COLUMNS FROM {$wpdb->prefix}woocommerce_downloadable_product_permissions WHERE Field = 'permission_id'", ARRAY_A );
$download_permissions_column_type = '';
if ( isset( $download_permissions_columns[0]['Type'] ) ) {
$download_permissions_column_type = $download_permissions_columns[0]['Type'];
}
// Add constraint to download logs if the columns matches.
if ( ! empty( $download_permissions_column_type ) && ! empty( $download_log_column_type ) && $download_permissions_column_type === $download_log_column_type ) {
$wpdb->query( "ALTER TABLE {$wpdb->prefix}wc_download_log ADD FOREIGN KEY (permission_id) REFERENCES {$wpdb->prefix}woocommerce_downloadable_product_permissions(permission_id) ON DELETE CASCADE" );
}
}
/**

View File

@ -45,7 +45,7 @@ class WC_Meta_Data implements JsonSerializable {
/**
* When converted to JSON.
*
* @return object
* @return object|array
*/
public function jsonSerialize() {
return $this->get_data();
@ -73,6 +73,8 @@ class WC_Meta_Data implements JsonSerializable {
* by `empty` and `isset`.
*
* @param string $key Key to check if set.
*
* @return bool
*/
public function __isset( $key ) {
return array_key_exists( $key, $this->current_data );

View File

@ -78,6 +78,8 @@ class WC_Order_Query extends WC_Object_Query {
* Get orders matching the current query vars.
*
* @return array|object of WC_Order objects
*
* @throws Exception When WC_Data_Store validation fails.
*/
public function get_orders() {
$args = apply_filters( 'woocommerce_order_query_args', $this->get_query_vars() );

View File

@ -179,19 +179,14 @@ class WC_Payment_Gateways {
return;
}
if ( is_user_logged_in() ) {
$default_token = WC_Payment_Tokens::get_customer_default_token( get_current_user_id() );
if ( ! is_null( $default_token ) ) {
$default_token_gateway = $default_token->get_gateway_id();
}
}
$current = ( isset( $default_token_gateway ) ? $default_token_gateway : WC()->session->get( 'chosen_payment_method' ) );
$current_gateway = false;
$current = WC()->session->get( 'chosen_payment_method' );
if ( $current && isset( $gateways[ $current ] ) ) {
$current_gateway = $gateways[ $current ];
}
} else {
if ( ! $current_gateway ) {
$current_gateway = current( $gateways );
}

View File

@ -17,20 +17,22 @@ class WC_Privacy_Exporters {
*
* @since 3.4.0
* @param string $email_address The user email address.
* @param int $page Page.
* @return array An array of personal data in name value pairs
*/
public static function customer_data_exporter( $email_address, $page ) {
public static function customer_data_exporter( $email_address ) {
$user = get_user_by( 'email', $email_address ); // Check if user has an ID in the DB to load stored personal data.
$data_to_export = array();
if ( $user instanceof WP_User ) {
$data_to_export[] = array(
'group_id' => 'woocommerce_customer',
'group_label' => __( 'Customer Data', 'woocommerce' ),
'item_id' => 'user',
'data' => self::get_customer_personal_data( $user ),
);
$customer_personal_data = self::get_customer_personal_data( $user );
if ( ! empty( $customer_personal_data ) ) {
$data_to_export[] = array(
'group_id' => 'woocommerce_customer',
'group_label' => __( 'Customer Data', 'woocommerce' ),
'item_id' => 'user',
'data' => $customer_personal_data,
);
}
}
return array(
@ -50,7 +52,7 @@ class WC_Privacy_Exporters {
* @return array An array of personal data in name value pairs
*/
public static function order_data_exporter( $email_address, $page ) {
$done = false;
$done = true;
$page = (int) $page;
$user = get_user_by( 'email', $email_address ); // Check if user has an ID in the DB to load stored personal data.
$data_to_export = array();
@ -76,8 +78,6 @@ class WC_Privacy_Exporters {
);
}
$done = 10 > count( $orders );
} else {
$done = true;
}
return array(
@ -92,10 +92,11 @@ class WC_Privacy_Exporters {
* @since 3.4.0
* @param string $email_address The user email address.
* @param int $page Page.
* @throws Exception When WC_Data_Store validation fails.
* @return array An array of personal data in name value pairs
*/
public static function download_data_exporter( $email_address, $page ) {
$done = false;
$done = true;
$page = (int) $page;
$user = get_user_by( 'email', $email_address ); // Check if user has an ID in the DB to load stored personal data.
$data_to_export = array();
@ -150,8 +151,6 @@ class WC_Privacy_Exporters {
}
}
$done = 10 > count( $downloads );
} else {
$done = true;
}
return array(
@ -165,6 +164,7 @@ class WC_Privacy_Exporters {
*
* @since 3.4.0
* @param WP_User $user user object.
* @throws Exception If customer cannot be read/found and $data is set to WC_Customer class.
* @return array
*/
protected static function get_customer_personal_data( $user ) {
@ -284,6 +284,27 @@ class WC_Privacy_Exporters {
}
}
// Export meta data.
$meta_to_export = apply_filters( 'woocommerce_privacy_export_order_personal_data_meta', array(
'Payer first name' => __( 'Payer first name', 'woocommerce' ),
'Payer last name' => __( 'Payer last name', 'woocommerce' ),
'Payer PayPal address' => __( 'Payer PayPal address', 'woocommerce' ),
'Transaction ID' => __( 'Transaction ID', 'woocommerce' ),
) );
if ( ! empty( $meta_to_export ) && is_array( $meta_to_export ) ) {
foreach ( $meta_to_export as $meta_key => $name ) {
$value = apply_filters( 'woocommerce_privacy_export_order_personal_data_meta_value', $order->get_meta( $meta_key ), $meta_key, $order );
if ( $value ) {
$personal_data[] = array(
'name' => $name,
'value' => $value,
);
}
}
}
/**
* Allow extensions to register their own personal data for this order for the export.
*
@ -352,7 +373,7 @@ class WC_Privacy_Exporters {
}
/**
* Finds and exports customer tokens by email address.
* Finds and exports payment tokens by email address for a customer.
*
* @since 3.4.0
* @param string $email_address The user email address.

View File

@ -167,7 +167,17 @@ class WC_Product_Variation extends WC_Product_Simple {
$data = $this->get_variation_attributes();
}
return add_query_arg( array_map( 'urlencode', array_filter( $data ) ), $url );
$data = array_filter( $data );
if ( empty( $data ) ) {
return $url;
}
// Filter and encode keys and values so this is not broken by add_query_arg.
$data = array_map( 'urlencode', $data );
$keys = array_map( 'urlencode', array_keys( $data ) );
return add_query_arg( array_combine( $keys, $data ), $url );
}
/**

View File

@ -515,7 +515,11 @@ class WC_Query {
global $wpdb, $wp_query;
if ( isset( $wp_query->queried_object, $wp_query->queried_object->term_taxonomy_id, $wp_query->queried_object->taxonomy ) && is_a( $wp_query->queried_object, 'WP_Term' ) ) {
$search_within_terms = get_term_children( $wp_query->queried_object->term_taxonomy_id, $wp_query->queried_object->taxonomy );
$search_within_terms = get_terms( array(
'taxonomy' => $wp_query->queried_object->taxonomy,
'parent' => $wp_query->queried_object->term_id,
'fields' => 'tt_ids',
) );
$search_within_terms[] = $wp_query->queried_object->term_taxonomy_id;
$args['join'] .= " INNER JOIN (
SELECT post_id, min( meta_value+0 ) price
@ -544,7 +548,11 @@ class WC_Query {
global $wpdb, $wp_query;
if ( isset( $wp_query->queried_object, $wp_query->queried_object->term_taxonomy_id, $wp_query->queried_object->taxonomy ) && is_a( $wp_query->queried_object, 'WP_Term' ) ) {
$search_within_terms = get_term_children( $wp_query->queried_object->term_taxonomy_id, $wp_query->queried_object->taxonomy );
$search_within_terms = get_terms( array(
'taxonomy' => $wp_query->queried_object->taxonomy,
'parent' => $wp_query->queried_object->term_id,
'fields' => 'tt_ids',
) );
$search_within_terms[] = $wp_query->queried_object->term_taxonomy_id;
$args['join'] .= " INNER JOIN (
SELECT post_id, max( meta_value+0 ) price

View File

@ -585,9 +585,7 @@ class WC_Shortcodes {
* @return string
*/
public static function shop_messages() {
ob_start();
wc_print_notices();
return '<div class="woocommerce">' . ob_get_clean() . '</div>';
return '<div class="woocommerce">' . wc_print_notices( true ) . '</div>';
}
/**

View File

@ -200,8 +200,8 @@ class WC_Tracker {
$server_data['php_suhosin'] = extension_loaded( 'suhosin' ) ? 'Yes' : 'No';
}
global $wpdb;
$server_data['mysql_version'] = $wpdb->db_version();
$database_version = wc_get_server_database_version();
$server_data['mysql_version'] = $database_version['number'];
$server_data['php_max_upload_size'] = size_format( wp_max_upload_size() );
$server_data['php_default_timezone'] = date_default_timezone_get();

View File

@ -69,6 +69,9 @@ class WC_Validation {
case 'GB':
$valid = self::is_gb_postcode( $postcode );
break;
case 'IE':
$valid = (bool) preg_match( '/([AC-FHKNPRTV-Y]\d{2}|D6W)[0-9AC-FHKNPRTV-Y]{4}/', wc_normalize_postcode( $postcode ) );
break;
case 'JP':
$valid = (bool) preg_match( '/^([0-9]{3})([-])([0-9]{4})$/', $postcode );
break;

View File

@ -1398,7 +1398,7 @@ class WC_Product_Data_Store_CPT extends WC_Data_Store_WP implements WC_Object_Da
}
}
if ( $search_queries ) {
if ( ! empty( $search_queries ) ) {
$search_where = 'AND (' . implode( ') OR (', $search_queries ) . ')';
}

View File

@ -71,12 +71,13 @@ class WC_Gateway_COD extends WC_Payment_Gateway {
$zones[] = new WC_Shipping_Zone( $raw_zone );
}
$zones[] = new WC_Shipping_Zone(0);
$zones[] = new WC_Shipping_Zone( 0 );
foreach ( WC()->shipping()->load_shipping_methods() as $method ) {
$options[ $method->get_method_title() ] = array();
// Translators: %1$s shipping method name.
$options[ $method->get_method_title() ][ $method->id ] = sprintf( __( 'Any &quot;%1$s&quot; method', 'woocommerce' ), $method->get_method_title() );
foreach ( $zones as $zone ) {
@ -89,9 +90,13 @@ class WC_Gateway_COD extends WC_Payment_Gateway {
continue;
}
$option_id = $shipping_method_instance->get_rate_id();
$option_id = $shipping_method_instance->get_rate_id();
// Translators: %1$s shipping method title, %2$s shipping method id.
$option_instance_title = sprintf( __( '%1$s (#%2$s)', 'woocommerce' ), $shipping_method_instance->get_title(), $shipping_method_instance_id );
$option_title = sprintf( __( '%1$s &ndash; %2$s', 'woocommerce' ), $zone->get_id() ? $zone->get_zone_name() : __( 'Other locations', 'woocommerce' ), $option_instance_title );
// Translators: %1$s zone name, %2$s shipping method instance name.
$option_title = sprintf( __( '%1$s &ndash; %2$s', 'woocommerce' ), $zone->get_id() ? $zone->get_zone_name() : __( 'Other locations', 'woocommerce' ), $option_instance_title );
$options[ $method->get_method_title() ][ $option_id ] = $option_title;
}
@ -175,9 +180,6 @@ class WC_Gateway_COD extends WC_Payment_Gateway {
}
}
}
} elseif ( WC()->cart && WC()->cart->needs_shipping() ) {
$needs_shipping = true;
}
$needs_shipping = apply_filters( 'woocommerce_cart_needs_shipping', $needs_shipping );
@ -189,7 +191,6 @@ class WC_Gateway_COD extends WC_Payment_Gateway {
// Only apply if all packages are being shipped via chosen method, or order is virtual.
if ( ! empty( $this->enable_for_methods ) && $needs_shipping ) {
$canonical_rate_ids = array();
$order_shipping_items = is_object( $order ) ? $order->get_shipping_methods() : false;
$chosen_shipping_methods_session = WC()->session->get( 'chosen_shipping_methods' );
@ -199,7 +200,7 @@ class WC_Gateway_COD extends WC_Payment_Gateway {
$canonical_rate_ids = $this->get_canonical_package_rate_ids( $chosen_shipping_methods_session );
}
if ( ! sizeof( $this->get_matching_rates( $canonical_rate_ids ) ) ) {
if ( ! count( $this->get_matching_rates( $canonical_rate_ids ) ) ) {
return false;
}
}
@ -212,8 +213,8 @@ class WC_Gateway_COD extends WC_Payment_Gateway {
*
* @since 3.4.0
*
* @param array $order_shipping_items Array of WC_Order_Item_Shipping objects.
* @return array $canonical_rate_ids Rate IDs in a canonical format.
* @param array $order_shipping_items Array of WC_Order_Item_Shipping objects.
* @return array $canonical_rate_ids Rate IDs in a canonical format.
*/
private function get_canonical_order_shipping_item_rate_ids( $order_shipping_items ) {
@ -231,18 +232,20 @@ class WC_Gateway_COD extends WC_Payment_Gateway {
*
* @since 3.4.0
*
* @param array $rate_ids Rate IDs as generated by shipping methods. Can be anything if a shipping method doesn't honor WC conventions.
* @return array $canonical_rate_ids Rate IDs in a canonical format.
* @param array $chosen_package_rate_ids Rate IDs as generated by shipping methods. Can be anything if a shipping method doesn't honor WC conventions.
* @return array $canonical_rate_ids Rate IDs in a canonical format.
*/
private function get_canonical_package_rate_ids( $chosen_package_rate_ids ) {
$shipping_packages = WC()->shipping->get_packages();
$canonical_rate_ids = array();
foreach ( $chosen_package_rate_ids as $package_key => $chosen_package_rate_id ) {
if ( ! empty( $shipping_packages[ $package_key ][ 'rates' ][ $chosen_package_rate_id ] ) ) {
$chosen_rate = $shipping_packages[ $package_key ][ 'rates' ][ $chosen_package_rate_id ];
$canonical_rate_ids[] = $chosen_rate->get_method_id() . ':' . $chosen_rate->get_instance_id();
if ( ! empty( $chosen_package_rate_ids ) && is_array( $chosen_package_rate_ids ) ) {
foreach ( $chosen_package_rate_ids as $package_key => $chosen_package_rate_id ) {
if ( ! empty( $shipping_packages[ $package_key ]['rates'][ $chosen_package_rate_id ] ) ) {
$chosen_rate = $shipping_packages[ $package_key ]['rates'][ $chosen_package_rate_id ];
$canonical_rate_ids[] = $chosen_rate->get_method_id() . ':' . $chosen_rate->get_instance_id();
}
}
}
@ -254,7 +257,7 @@ class WC_Gateway_COD extends WC_Payment_Gateway {
*
* @since 3.4.0
*
* @param array $rate_ids
* @param array $rate_ids Rate ids to check.
* @return boolean
*/
private function get_matching_rates( $rate_ids ) {

View File

@ -24,20 +24,24 @@ class WC_Shortcode_Cart {
try {
WC()->shipping->reset_shipping();
$country = isset( $_POST['calc_shipping_country'] ) ? wc_clean( wp_unslash( $_POST['calc_shipping_country'] ) ) : ''; // WPCS: input var ok, CSRF ok, sanitization ok.
$state = isset( $_POST['calc_shipping_state'] ) ? wc_clean( wp_unslash( $_POST['calc_shipping_state'] ) ) : ''; // WPCS: input var ok, CSRF ok, sanitization ok.
$postcode = isset( $_POST['calc_shipping_postcode'] ) ? wc_clean( wp_unslash( $_POST['calc_shipping_postcode'] ) ) : ''; // WPCS: input var ok, CSRF ok, sanitization ok.
$city = isset( $_POST['calc_shipping_city'] ) ? wc_clean( wp_unslash( $_POST['calc_shipping_city'] ) ) : ''; // WPCS: input var ok, CSRF ok, sanitization ok.
$address = array();
if ( $postcode && ! WC_Validation::is_postcode( $postcode, $country ) ) {
$address['country'] = isset( $_POST['calc_shipping_country'] ) ? wc_clean( wp_unslash( $_POST['calc_shipping_country'] ) ) : ''; // WPCS: input var ok, CSRF ok, sanitization ok.
$address['state'] = isset( $_POST['calc_shipping_state'] ) ? wc_clean( wp_unslash( $_POST['calc_shipping_state'] ) ) : ''; // WPCS: input var ok, CSRF ok, sanitization ok.
$address['postcode'] = isset( $_POST['calc_shipping_postcode'] ) ? wc_clean( wp_unslash( $_POST['calc_shipping_postcode'] ) ) : ''; // WPCS: input var ok, CSRF ok, sanitization ok.
$address['city'] = isset( $_POST['calc_shipping_city'] ) ? wc_clean( wp_unslash( $_POST['calc_shipping_city'] ) ) : ''; // WPCS: input var ok, CSRF ok, sanitization ok.
$address = apply_filters( 'woocommerce_cart_calculate_shipping_address', $address );
if ( $address['postcode'] && ! WC_Validation::is_postcode( $address['postcode'], $address['country'] ) ) {
throw new Exception( __( 'Please enter a valid postcode / ZIP.', 'woocommerce' ) );
} elseif ( $postcode ) {
$postcode = wc_format_postcode( $postcode, $country );
} elseif ( $address['postcode'] ) {
$address['postcode'] = wc_format_postcode( $address['postcode'], $address['country'] );
}
if ( $country ) {
WC()->customer->set_location( $country, $state, $postcode, $city );
WC()->customer->set_shipping_location( $country, $state, $postcode, $city );
if ( $address['country'] ) {
WC()->customer->set_location( $address['country'], $address['state'], $address['postcode'], $address['city'] );
WC()->customer->set_shipping_location( $address['country'], $address['state'], $address['postcode'], $address['city'] );
} else {
WC()->customer->set_billing_address_to_base();
WC()->customer->set_shipping_address_to_base();

View File

@ -79,8 +79,6 @@ class WC_Shortcode_Checkout {
do_action( 'before_woocommerce_pay' );
wc_print_notices();
$order_id = absint( $order_id );
// Pay for existing order.
@ -152,7 +150,7 @@ class WC_Shortcode_Checkout {
);
} catch ( Exception $e ) {
wc_add_notice( $e->getMessage(), 'error' );
wc_print_notice( $e->getMessage(), 'error' );
}
} elseif ( $order_id ) {
@ -168,17 +166,15 @@ class WC_Shortcode_Checkout {
} else {
/* translators: %s: order status */
wc_add_notice( sprintf( __( 'This order&rsquo;s status is &ldquo;%s&rdquo;&mdash;it cannot be paid for. Please contact us if you need assistance.', 'woocommerce' ), wc_get_order_status_name( $order->get_status() ) ), 'error' );
wc_print_notice( sprintf( __( 'This order&rsquo;s status is &ldquo;%s&rdquo;&mdash;it cannot be paid for. Please contact us if you need assistance.', 'woocommerce' ), wc_get_order_status_name( $order->get_status() ) ), 'error' );
}
} else {
wc_add_notice( __( 'Sorry, this order is invalid and cannot be paid for.', 'woocommerce' ), 'error' );
wc_print_notice( __( 'Sorry, this order is invalid and cannot be paid for.', 'woocommerce' ), 'error' );
}
} else {
wc_add_notice( __( 'Invalid order.', 'woocommerce' ), 'error' );
wc_print_notice( __( 'Invalid order.', 'woocommerce' ), 'error' );
}
wc_print_notices();
do_action( 'after_woocommerce_pay' );
}
@ -188,9 +184,6 @@ class WC_Shortcode_Checkout {
* @param int $order_id Order ID.
*/
private static function order_received( $order_id = 0 ) {
wc_print_notices();
$order = false;
// Get the order.
@ -217,12 +210,8 @@ class WC_Shortcode_Checkout {
* Show the checkout.
*/
private static function checkout() {
// Show non-cart errors.
wc_print_notices();
// Check cart has contents.
if ( WC()->cart->is_empty() && ! is_customize_preview() ) {
if ( WC()->cart->is_empty() && ! is_customize_preview() && apply_filters( 'woocommerce_checkout_redirect_empty_cart', true ) ) {
return;
}

View File

@ -377,22 +377,15 @@ class WC_Shortcode_My_Account {
* Show the add payment method page.
*/
public static function add_payment_method() {
if ( ! is_user_logged_in() ) {
wp_safe_redirect( wc_get_page_permalink( 'myaccount' ) );
exit();
} else {
do_action( 'before_woocommerce_add_payment_method' );
wc_print_notices();
wc_get_template( 'myaccount/form-add-payment-method.php' );
do_action( 'after_woocommerce_add_payment_method' );
}
}
}

View File

@ -45,9 +45,9 @@ class WC_Shortcode_Order_Tracking {
$order_email = empty( $_REQUEST['order_email'] ) ? '' : sanitize_email( wp_unslash( $_REQUEST['order_email'] ) ); // WPCS: input var ok.
if ( ! $order_id ) {
wc_add_notice( __( 'Please enter a valid order ID', 'woocommerce' ), 'error' );
wc_print_notice( __( 'Please enter a valid order ID', 'woocommerce' ), 'error' );
} elseif ( ! $order_email ) {
wc_add_notice( __( 'Please enter a valid email address', 'woocommerce' ), 'error' );
wc_print_notice( __( 'Please enter a valid email address', 'woocommerce' ), 'error' );
} else {
$order = wc_get_order( apply_filters( 'woocommerce_shortcode_order_tracking_order_id', $order_id ) );
@ -60,13 +60,11 @@ class WC_Shortcode_Order_Tracking {
);
return;
} else {
wc_add_notice( __( 'Sorry, the order could not be found. Please contact us if you are having difficulty finding your order details.', 'woocommerce' ), 'error' );
wc_print_notice( __( 'Sorry, the order could not be found. Please contact us if you are having difficulty finding your order details.', 'woocommerce' ), 'error' );
}
}
}
wc_print_notices();
wc_get_template( 'order/form-tracking.php' );
}
}

View File

@ -48,6 +48,7 @@ class WC_Twenty_Seventeen {
'deps' => '',
'version' => WC_VERSION,
'media' => 'all',
'has_rtl' => true,
);
return apply_filters( 'woocommerce_twenty_seventeen_styles', $styles );

View File

@ -128,7 +128,7 @@ function wc_add_to_cart_message( $products, $show_qty = false, $return = false )
$message = apply_filters( 'wc_add_to_cart_message', $message, $product_id );
}
$message = apply_filters( 'wc_add_to_cart_message_html', $message, $products );
$message = apply_filters( 'wc_add_to_cart_message_html', $message, $products, $show_qty );
if ( $return ) {
return $message;
@ -203,8 +203,8 @@ function wc_cart_totals_subtotal_html() {
* Get shipping methods.
*/
function wc_cart_totals_shipping_html() {
$packages = WC()->shipping->get_packages();
$first = true;
$packages = WC()->shipping->get_packages();
$first = true;
foreach ( $packages as $i => $package ) {
$chosen_method = isset( WC()->session->chosen_shipping_methods[ $i ] ) ? WC()->session->chosen_shipping_methods[ $i ] : '';
@ -228,6 +228,8 @@ function wc_cart_totals_shipping_html() {
'package_name' => apply_filters( 'woocommerce_shipping_package_name', ( ( $i + 1 ) > 1 ) ? sprintf( _x( 'Shipping %d', 'shipping packages', 'woocommerce' ), ( $i + 1 ) ) : _x( 'Shipping', 'shipping package', 'woocommerce' ), $i, $package ),
'index' => $i,
'chosen_method' => $chosen_method,
'formatted_destination' => WC()->countries->get_formatted_address( $package['destination'], ', ' ),
'has_calculated_shipping' => WC()->customer->has_calculated_shipping(),
)
);
@ -280,7 +282,7 @@ function wc_cart_totals_coupon_html( $coupon ) {
$amount = WC()->cart->get_coupon_discount_amount( $coupon->get_code(), WC()->cart->display_cart_ex_tax );
$discount_amount_html = '-' . wc_price( $amount );
if ( $coupon->get_free_shipping() ) {
if ( $coupon->get_free_shipping() && empty( $amount ) ) {
$discount_amount_html = __( 'Free shipping coupon', 'woocommerce' );
}

View File

@ -262,7 +262,7 @@ if ( ! function_exists( 'is_ajax' ) ) {
* @return bool
*/
function is_ajax() {
return defined( 'DOING_AJAX' );
return function_exists( 'wp_doing_ajax' ) ? wp_doing_ajax() : defined( 'DOING_AJAX' );
}
}

View File

@ -59,7 +59,7 @@ add_filter( 'woocommerce_short_description', array( $GLOBALS['wp_embed'], 'run_s
*
* @since 3.0.0
* @param string $name Constant name.
* @param string $value Value.
* @param mixed $value Value.
*/
function wc_maybe_define_constant( $name, $value ) {
if ( ! defined( $name ) ) {
@ -150,7 +150,6 @@ function wc_update_order( $args ) {
*
* WC_TEMPLATE_DEBUG_MODE will prevent overrides in themes from taking priority.
*
* @access public
* @param mixed $slug Template slug.
* @param string $name Template name (default: '').
*/
@ -183,7 +182,6 @@ function wc_get_template_part( $slug, $name = '' ) {
/**
* Get other templates (e.g. product attributes) passing attributes and including the file.
*
* @access public
* @param string $template_name Template name.
* @param array $args Arguments. (default: array).
* @param string $template_path Template path. (default: '').
@ -239,7 +237,6 @@ function wc_get_template_html( $template_name, $args = array(), $template_path =
* yourtheme/$template_name
* $default_path/$template_name
*
* @access public
* @param string $template_name Template name.
* @param string $template_path Template path. (default: '').
* @param string $default_path Default path. (default: '').
@ -1136,11 +1133,11 @@ endif;
* @return string
*/
function wc_rand_hash() {
if ( function_exists( 'openssl_random_pseudo_bytes' ) ) {
return bin2hex( openssl_random_pseudo_bytes( 20 ) ); // @codingStandardsIgnoreLine
} else {
if ( ! function_exists( 'openssl_random_pseudo_bytes' ) ) {
return sha1( wp_rand() );
}
return bin2hex( openssl_random_pseudo_bytes( 20 ) ); // @codingStandardsIgnoreLine
}
/**
@ -1586,16 +1583,17 @@ function wc_remove_number_precision( $value ) {
* @since 3.2.0
* @param array $value Number to add precision to.
* @param bool $round Should we round after adding precision?.
* @return int
* @return int|array
*/
function wc_add_number_precision_deep( $value, $round = true ) {
if ( is_array( $value ) ) {
foreach ( $value as $key => $subvalue ) {
$value[ $key ] = wc_add_number_precision_deep( $subvalue, $round );
}
} else {
$value = wc_add_number_precision( $value, $round );
if ( ! is_array( $value ) ) {
return wc_add_number_precision( $value, $round );
}
foreach ( $value as $key => $sub_value ) {
$value[ $key ] = wc_add_number_precision_deep( $sub_value, $round );
}
return $value;
}
@ -1604,16 +1602,17 @@ function wc_add_number_precision_deep( $value, $round = true ) {
*
* @since 3.2.0
* @param array $value Number to add precision to.
* @return int
* @return int|array
*/
function wc_remove_number_precision_deep( $value ) {
if ( is_array( $value ) ) {
foreach ( $value as $key => $subvalue ) {
$value[ $key ] = wc_remove_number_precision_deep( $subvalue );
}
} else {
$value = wc_remove_number_precision( $value );
if ( ! is_array( $value ) ) {
return wc_remove_number_precision( $value );
}
foreach ( $value as $key => $sub_value ) {
$value[ $key ] = wc_remove_number_precision_deep( $sub_value );
}
return $value;
}
@ -1634,30 +1633,30 @@ function wc_get_logger() {
$class = apply_filters( 'woocommerce_logging_class', 'WC_Logger' );
if ( null === $logger || ! is_a( $logger, $class ) ) {
$implements = class_implements( $class );
if ( is_array( $implements ) && in_array( 'WC_Logger_Interface', $implements, true ) ) {
if ( is_object( $class ) ) {
$logger = $class;
} else {
$logger = new $class();
}
} else {
wc_doing_it_wrong(
__FUNCTION__,
sprintf(
/* translators: 1: class name 2: woocommerce_logging_class 3: WC_Logger_Interface */
__( 'The class %1$s provided by %2$s filter must implement %3$s.', 'woocommerce' ),
'<code>' . esc_html( is_object( $class ) ? get_class( $class ) : $class ) . '</code>',
'<code>woocommerce_logging_class</code>',
'<code>WC_Logger_Interface</code>'
),
'3.0'
);
$logger = is_a( $logger, 'WC_Logger' ) ? $logger : new WC_Logger();
}
if ( null !== $logger && is_a( $logger, $class ) ) {
return $logger;
}
$implements = class_implements( $class );
if ( is_array( $implements ) && in_array( 'WC_Logger_Interface', $implements, true ) ) {
$logger = is_object( $class ) ? $class : new $class();
} else {
wc_doing_it_wrong(
__FUNCTION__,
sprintf(
/* translators: 1: class name 2: woocommerce_logging_class 3: WC_Logger_Interface */
__( 'The class %1$s provided by %2$s filter must implement %3$s.', 'woocommerce' ),
'<code>' . esc_html( is_object( $class ) ? get_class( $class ) : $class ) . '</code>',
'<code>woocommerce_logging_class</code>',
'<code>WC_Logger_Interface</code>'
),
'3.0'
);
$logger = is_a( $logger, 'WC_Logger' ) ? $logger : new WC_Logger();
}
return $logger;
}
@ -1929,6 +1928,10 @@ add_filter( 'extra_plugin_headers', 'wc_enable_wc_plugin_headers' );
* @return bool
*/
function wc_prevent_dangerous_auto_updates( $should_update, $plugin ) {
if ( ! isset( $plugin->plugin, $plugin->new_version ) ) {
return $should_update;
}
if ( 'woocommerce/woocommerce.php' !== $plugin->plugin ) {
return $should_update;
}
@ -2105,3 +2108,31 @@ function wc_selected( $value, $options ) {
return selected( $value, $options, false );
}
/**
* Retrieves the MySQL server version. Based on $wpdb.
*
* @since 3.4.1
* @return array Vesion information.
*/
function wc_get_server_database_version() {
global $wpdb;
if ( empty( $wpdb->is_mysql ) ) {
return array(
'string' => '',
'number' => '',
);
}
if ( $wpdb->use_mysqli ) {
$server_info = mysqli_get_server_info( $wpdb->dbh ); // @codingStandardsIgnoreLine.
} else {
$server_info = mysql_get_server_info( $wpdb->dbh ); // @codingStandardsIgnoreLine.
}
return array(
'string' => $server_info,
'number' => preg_replace( '/([^\d.]+).*/', '', $server_info ),
);
}

View File

@ -900,6 +900,9 @@ function wc_format_postcode( $postcode, $country ) {
case 'GB':
$postcode = trim( substr_replace( $postcode, ' ', -3, 0 ) );
break;
case 'IE':
$postcode = trim( substr_replace( $postcode, ' ', 3, 0 ) );
break;
case 'BR':
case 'PL':
$postcode = substr_replace( $postcode, '-', -3, 0 );

Some files were not shown because too many files have changed in this diff Show More