Merge branch 'master' of github.com:woothemes/woocommerce

This commit is contained in:
Nicola Mustone 2015-04-08 15:35:31 +02:00
commit ae449b1352
42 changed files with 388 additions and 286 deletions

File diff suppressed because one or more lines are too long

View File

@ -3116,16 +3116,17 @@ img.help_tip {
float: left;
margin-right: 20px;
position: relative;
cursor: pointer;
img {
width: 100%;
height: auto;
display: none;
}
&:before {
content: "\f317";
content: "\f128";
font-family: 'Dashicons';
display: none;
position: absolute;
top: 0;
left: 0;
@ -3133,19 +3134,26 @@ img.help_tip {
bottom: 0;
text-align: center;
line-height: 48px;
font-size: 2em;
font-size: 48px;
font-weight: 400;
-webkit-font-smoothing: antialiased;
}
&.remove:before {
content: "\f335";
}
&:hover {
&:before {
&.remove{
img {
display: block;
}
&:before {
content: "\f335";
display: none;
}
&:hover {
&:before {
display: block;
}
}
}
}
@ -3232,7 +3240,7 @@ img.tips {
#tiptip_arrow_inner {
margin-top: -7px;
margin-left: -6px;
border-top-color: #464646;
border-top-color: #333;
}
}
@ -3242,7 +3250,7 @@ img.tips {
#tiptip_arrow_inner {
margin-top: -5px;
margin-left: -6px;
border-bottom-color: #464646;
border-bottom-color: #333;
}
}
@ -3252,7 +3260,7 @@ img.tips {
#tiptip_arrow_inner {
margin-top: -6px;
margin-left: -5px;
border-right-color: #464646;
border-right-color: #333;
}
}
@ -3262,7 +3270,7 @@ img.tips {
#tiptip_arrow_inner {
margin-top: -6px;
margin-left: -7px;
border-left-color: #464646;
border-left-color: #333;
}
}
}
@ -3270,14 +3278,12 @@ img.tips {
#tiptip_content,
.chart-tooltip,
.wc_error_tip {
font-size: 11px;
font-size: .8em;
color: #fff;
padding: .5em .5em;
background: #464646;
@include border-radius(3px);
-webkit-box-shadow: 1px 1px 3px rgba(0,0,0,0.10);
-moz-box-shadow: 1px 1px 3px rgba(0,0,0,0.10);
box-shadow: 1px 1px 3px rgba(0,0,0,0.10);
padding: .618em 1em;
background: #333;
border-radius: 3px;
box-shadow: 0 1px 3px rgba(0,0,0,0.2);
text-align: center;
max-width: 150px;
@ -4036,7 +4042,7 @@ table.bar_chart {
*/
.wc-backbone-modal {
* {
box-sizing: content-box;
box-sizing: border-box;
}
.wc-backbone-modal-content {
@ -4045,7 +4051,7 @@ table.bar_chart {
left: 50%;
width: 500px;
background: #fff;
margin: -150px 0 0 -250px;
margin-left: -250px;
z-index: 160000;
}
}
@ -4063,69 +4069,60 @@ table.bar_chart {
}
.wc-backbone-modal-main {
padding-bottom: 50px;
padding-bottom: 51px;
header,
article {
display: block;
position: relative;
padding: 4px 16px;
}
.wc-backbone-modal-header {
height: 50px;
background: #fcfcfc;
padding: 0 50px 0 16px;
border-bottom: 1px solid #ddd;
h1 {
font-size: 22px;
font-weight: 700;
line-height: 42px;
margin: 0;
}
}
.modal-close-link {
cursor: pointer;
color: #777;
background-color: transparent;
height: 50px;
width: 50px;
padding: 0;
position: absolute;
text-align: center;
border: 0;
border-left: 1px solid #ddd;
-webkit-transition: color .1s ease-in-out,background .1s ease-in-out;
transition: color .1s ease-in-out,background .1s ease-in-out;
top: 0;
right: 0;
text-decoration: none;
&:hover {
background: #ddd;
border-color: #ccc;
color: #000;
outline: 0;
text-decoration: none;
font-size: 18px;
font-weight: 700;
line-height: 50px;
}
.close-icon {
display: block;
height: 15px;
background-image: none;
.modal-close-link {
cursor: pointer;
color: #777;
height: 50px;
width: 50px;
padding: 0;
position: absolute;
top: 0;
right: 0;
text-align: center;
margin: 14px;
width: 22px;
border: 0;
border-left: 1px solid #ddd;
background-color: transparent;
-webkit-transition: color .1s ease-in-out,background .1s ease-in-out;
transition: color .1s ease-in-out,background .1s ease-in-out;
&:before {
content: '\f335';
font-size: 22px;
font: 400 20px/1 dashicons;
speak: none;
vertical-align: middle;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
font: normal 22px/50px 'dashicons' !important;
color: #666;
display: block;
content: '\f335';
font-weight: 300;
}
&:hover,
&:focus {
background: #ddd;
border-color: #ccc;
color: #000;
}
&:focus {
outline: none;
}
}
}
@ -4144,17 +4141,20 @@ table.bar_chart {
left: 0;
right: 0;
bottom: 0;
height: 30px;
z-index: 100;
padding: 10px 0px;
border: 0 solid #dfdfdf;
border-width: 1px 0 0 0;
padding: 10px 16px;
background: #fcfcfc;
border-top: 1px solid #dfdfdf;
box-shadow: 0 -4px 4px -4px rgba(0,0,0,0.1);
}
footer .inner {
padding: 0 10px;
text-align: right;
.inner {
float: right;
line-height: 23px;
.button {
margin-bottom: 0;
}
}
}
}
@ -4162,7 +4162,7 @@ table.bar_chart {
* Select2
*/
.select2-drop {
z-index: 999999;
z-index: 999999 !important;
}
.select2-container-multi .select2-choices .select2-search-field input {
font-family: inherit;

File diff suppressed because one or more lines are too long

View File

@ -14,7 +14,7 @@ jQuery( function ( $ ) {
$( '.js_field-country' ).select2().change( this.change_country );
$( '.js_field-country' ).trigger( 'change', [ true ] );
$( 'body' ).on( 'change', 'select.js_field-state', this.change_state );
$(document.body).on( 'change', 'select.js_field-state', this.change_state );
$( '#woocommerce-order-actions input, #woocommerce-order-actions a' ).click(function() {
window.onbeforeunload = '';
});
@ -70,7 +70,7 @@ jQuery( function ( $ ) {
$state.replaceWith( '<input type="text" class="js_field-state" name="' + input_name + '" id="' + input_id + '" value="' + value + '" placeholder="' + placeholder + '" />' );
}
$( 'body' ).trigger( 'contry-change.woocommerce', [country, $( this ).closest( 'div' )] );
$(document.body).trigger( 'contry-change.woocommerce', [country, $( this ).closest( 'div' )] );
},
change_state: function() {
@ -992,7 +992,7 @@ jQuery( function ( $ ) {
init: function( e, target ) {
if ( '#wc-modal-add-products' === target ) {
$( 'body' ).trigger( 'wc-enhanced-select-init' );
$(document.body).trigger( 'wc-enhanced-select-init' );
}
},
@ -1213,7 +1213,7 @@ jQuery( function ( $ ) {
window.alert( woocommerce_admin_meta_boxes.i18n_download_permission_fail );
}
$('body').trigger( 'wc-init-datepickers' );
$(document.body).trigger( 'wc-init-datepickers' );
$( '#grant_access_id' ).val( '' ).change();
$( '.order_download_permissions' ).unblock();
});

View File

@ -107,12 +107,12 @@ jQuery( function( $ ){
$( 'ul.wc-tabs li:visible' ).eq(0).find( 'a' ).click();
$( 'body' ).trigger( 'woocommerce-product-type-change', select_val, $( this ) );
$(document.body).trigger( 'woocommerce-product-type-change', select_val, $( this ) );
}).change();
$( 'body' ).on( 'woocommerce-product-type-change', function( e, select_val ) {
if ( 'variable' !== select_val && 0 < $( '#variable_product_options input[name^=variable_sku]' ).length && $( 'body' ).triggerHandler( 'woocommerce-display-product-type-alert', select_val ) !== false ) {
$(document.body).on( 'woocommerce-product-type-change', function( e, select_val ) {
if ( 'variable' !== select_val && 0 < $( '#variable_product_options input[name^=variable_sku]' ).length && $(document.body).triggerHandler( 'woocommerce-display-product-type-alert', select_val ) !== false ) {
window.alert( woocommerce_admin_meta_boxes.i18n_product_type_alert );
}
});
@ -293,11 +293,11 @@ jQuery( function( $ ){
$wrapper.find( '.enable_variation' ).hide();
}
$('body').trigger( 'wc-enhanced-select-init' );
$(document.body).trigger( 'wc-enhanced-select-init' );
attribute_row_indexes();
$wrapper.unblock();
$('body').trigger( 'woocommerce_added_attribute' );
$(document.body).trigger( 'woocommerce_added_attribute' );
});
if ( attribute ) {

View File

@ -48,7 +48,7 @@ jQuery( function ( $ ) {
});
$('ul.wc-tabs li:visible').eq(0).find('a').click();
$('body').on( 'wc-init-datepickers', function() {
$(document.body).on( 'wc-init-datepickers', function() {
$( ".date-picker-field, .date-picker" ).datepicker({
dateFormat: "yy-mm-dd",
numberOfMonths: 1,
@ -56,7 +56,7 @@ jQuery( function ( $ ) {
});
});
$('body').trigger( 'wc-init-datepickers' );
$(document.body).trigger( 'wc-init-datepickers' );
// META BOXES - Open/close
$('.wc-metaboxes-wrapper').on('click', '.wc-metabox h3', function(event){

View File

@ -61,12 +61,12 @@
render: function() {
this.$el.attr( 'tabindex' , '0' ).append( $( this._target ).html() );
$( 'body' ).css({
$(document.body).css({
'overflow': 'hidden'
}).append( this.$el );
var $content = $( '.wc-backbone-modal-content' ).find( 'article' );
var content_h = ( 0 === $content.height() ) ? 90 : $content.height();
var content_h = ( $content.height() < 90 ) ? 90 : $content.height();
var max_h = $( window ).height() - 200;
if ( max_h > 400 ) {
@ -81,7 +81,7 @@
} else {
$content.css({
'overflow': 'visible',
height: content_h
height: ( content_h > 90 ) ? 'auto' : content_h + 'px'
});
}
@ -89,21 +89,21 @@
'margin-top': '-' + ( $( '.wc-backbone-modal-content' ).height() / 2 ) + 'px'
});
$( 'body' ).trigger( 'wc_backbone_modal_loaded', this._target );
$(document.body).trigger( 'wc_backbone_modal_loaded', this._target );
},
closeButton: function( e ) {
e.preventDefault();
$( 'body' ).trigger( 'wc_backbone_modal_before_remove', this._target );
$(document.body).trigger( 'wc_backbone_modal_before_remove', this._target );
this.undelegateEvents();
$( document ).off( 'focusin' );
$( 'body' ).css({
$(document.body).css({
'overflow': 'auto'
});
this.remove();
$( 'body' ).trigger( 'wc_backbone_modal_removed', this._target );
$(document.body).trigger( 'wc_backbone_modal_removed', this._target );
},
addButton: function( e ) {
$( 'body' ).trigger( 'wc_backbone_modal_response', [ this._target, this.getFormData() ] );
$(document.body).trigger( 'wc_backbone_modal_response', [ this._target, this.getFormData() ] );
this.closeButton( e );
},
getFormData: function() {
@ -113,8 +113,7 @@
if ( data.hasOwnProperty( item.name ) ) {
data[ item.name ] = $.makeArray( data[ item.name ] );
data[ item.name ].push( item.value );
}
else {
} else {
data[ item.name ] = item.value;
}
});

View File

@ -1 +1 @@
!function(a,b,c){"use strict";a.fn.WCBackboneModal=function(b){return this.each(function(){new a.WCBackboneModal(a(this),b)})},a.WCBackboneModal=function(b,c){var d=a.extend({},a.WCBackboneModal.defaultOptions,c);d.template&&new a.WCBackboneModal.View({target:d.template})},a.WCBackboneModal.defaultOptions={template:""},a.WCBackboneModal.View=b.View.extend({tagName:"div",id:"wc-backbone-modal-dialog",_target:void 0,events:{"click .modal-close":"closeButton","click #btn-ok":"addButton",keydown:"keyboardActions"},initialize:function(a){this._target=a.target,c.bindAll(this,"render"),this.render()},render:function(){this.$el.attr("tabindex","0").append(a(this._target).html()),a("body").css({overflow:"hidden"}).append(this.$el);var b=a(".wc-backbone-modal-content").find("article"),c=0===b.height()?90:b.height(),d=a(window).height()-200;d>400&&(d=400),b.css(c>d?{overflow:"auto",height:d+"px"}:{overflow:"visible",height:c}),a(".wc-backbone-modal-content").css({"margin-top":"-"+a(".wc-backbone-modal-content").height()/2+"px"}),a("body").trigger("wc_backbone_modal_loaded",this._target)},closeButton:function(b){b.preventDefault(),a("body").trigger("wc_backbone_modal_before_remove",this._target),this.undelegateEvents(),a(document).off("focusin"),a("body").css({overflow:"auto"}),this.remove(),a("body").trigger("wc_backbone_modal_removed",this._target)},addButton:function(b){a("body").trigger("wc_backbone_modal_response",[this._target,this.getFormData()]),this.closeButton(b)},getFormData:function(){var b={};return a.each(a("form",this.$el).serializeArray(),function(c,d){b.hasOwnProperty(d.name)?(b[d.name]=a.makeArray(b[d.name]),b[d.name].push(d.value)):b[d.name]=d.value}),b},keyboardActions:function(a){var b=a.keyCode||a.which;13!==b||a.target.tagName&&"input"===a.target.tagName.toLowerCase()||this.addButton(a),27===b&&this.closeButton(a)}})}(jQuery,Backbone,_);
!function(a,b,c){"use strict";a.fn.WCBackboneModal=function(b){return this.each(function(){new a.WCBackboneModal(a(this),b)})},a.WCBackboneModal=function(b,c){var d=a.extend({},a.WCBackboneModal.defaultOptions,c);d.template&&new a.WCBackboneModal.View({target:d.template})},a.WCBackboneModal.defaultOptions={template:""},a.WCBackboneModal.View=b.View.extend({tagName:"div",id:"wc-backbone-modal-dialog",_target:void 0,events:{"click .modal-close":"closeButton","click #btn-ok":"addButton",keydown:"keyboardActions"},initialize:function(a){this._target=a.target,c.bindAll(this,"render"),this.render()},render:function(){this.$el.attr("tabindex","0").append(a(this._target).html()),a("body").css({overflow:"hidden"}).append(this.$el);var b=a(".wc-backbone-modal-content").find("article"),c=b.height()<90?90:b.height(),d=a(window).height()-200;d>400&&(d=400),b.css(c>d?{overflow:"auto",height:d+"px"}:{overflow:"visible",height:c>90?"auto":c+"px"}),a(".wc-backbone-modal-content").css({"margin-top":"-"+a(".wc-backbone-modal-content").height()/2+"px"}),a("body").trigger("wc_backbone_modal_loaded",this._target)},closeButton:function(b){b.preventDefault(),a("body").trigger("wc_backbone_modal_before_remove",this._target),this.undelegateEvents(),a(document).off("focusin"),a("body").css({overflow:"auto"}),this.remove(),a("body").trigger("wc_backbone_modal_removed",this._target)},addButton:function(b){a("body").trigger("wc_backbone_modal_response",[this._target,this.getFormData()]),this.closeButton(b)},getFormData:function(){var b={};return a.each(a("form",this.$el).serializeArray(),function(c,d){b.hasOwnProperty(d.name)?(b[d.name]=a.makeArray(b[d.name]),b[d.name].push(d.value)):b[d.name]=d.value}),b},keyboardActions:function(a){var b=a.keyCode||a.which;13!==b||a.target.tagName&&"input"===a.target.tagName.toLowerCase()||this.addButton(a),27===b&&this.closeButton(a)}})}(jQuery,Backbone,_);

View File

@ -14,7 +14,7 @@ jQuery( function ( $ ) {
$( '.js_field-country' ).select2().change( this.change_country );
$( '.js_field-country' ).trigger( 'change', [ true ] );
$( 'body' ).on( 'change', 'select.js_field-state', this.change_state );
$(document.body).on( 'change', 'select.js_field-state', this.change_state );
},
change_country: function( e, stickValue ) {
@ -63,7 +63,7 @@ jQuery( function ( $ ) {
$state.replaceWith( '<input type="text" class="js_field-state" name="' + input_name + '" id="' + input_id + '" value="' + value + '" placeholder="' + placeholder + '" />' );
}
$( 'body' ).trigger( 'contry-change.woocommerce', [country, $( this ).closest( 'div' )] );
$(document.body).trigger( 'contry-change.woocommerce', [country, $( this ).closest( 'div' )] );
},
change_state: function() {

View File

@ -6,12 +6,12 @@
jQuery( function ( $ ) {
// Price input validation
$('body').on( 'blur', '.wc_input_decimal[type=text], .wc_input_price[type=text], .wc_input_country_iso[type=text]', function() {
$(document.body).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(); } );
return this;
});
$('body').on('keyup change', '.wc_input_price[type=text]', function(){
$(document.body).on('keyup change', '.wc_input_price[type=text]', function(){
var value = $(this).val();
var regex = new RegExp( "[^\-0-9\%.\\" + woocommerce_admin.mon_decimal_point + "]+", "gi" );
var newvalue = value.replace( regex, '' );
@ -30,7 +30,7 @@ jQuery( function ( $ ) {
return this;
});
$('body').on('keyup change', '.wc_input_decimal[type=text]', function(){
$(document.body).on('keyup change', '.wc_input_decimal[type=text]', function(){
var value = $(this).val();
var regex = new RegExp( "[^\-0-9\%.\\" + woocommerce_admin.decimal_point + "]+", "gi" );
var newvalue = value.replace( regex, '' );
@ -49,7 +49,7 @@ jQuery( function ( $ ) {
return this;
});
$('body').on( 'keyup', '#_sale_price.wc_input_price[type=text], .wc_input_price[name^=variable_sale_price]', function(){
$(document.body).on( 'keyup', '#_sale_price.wc_input_price[type=text], .wc_input_price[name^=variable_sale_price]', function(){
var sale_price_field = $(this);
if( sale_price_field.attr('name').indexOf('variable') !== -1 ) {
@ -75,7 +75,7 @@ jQuery( function ( $ ) {
}
return this;
});
$('body').on( 'change', '#_sale_price.wc_input_price[type=text], .wc_input_price[name^=variable_sale_price]', function(){
$(document.body).on( 'change', '#_sale_price.wc_input_price[type=text], .wc_input_price[name^=variable_sale_price]', function(){
var sale_price_field = $(this);
if( sale_price_field.attr('name').indexOf('variable') !== -1 ) {
@ -95,7 +95,7 @@ jQuery( function ( $ ) {
return this;
});
$('body').on('keyup change', '.wc_input_country_iso[type=text]', function(){
$(document.body).on('keyup change', '.wc_input_country_iso[type=text]', function(){
var value = $(this).val();
var regex = new RegExp( '^([A-Z])?([A-Z])$' );
@ -222,7 +222,7 @@ jQuery( function ( $ ) {
}).change();
// Show order items on orders page
$('body').on( 'click', '.show_order_items', function() {
$(document.body).on( 'click', '.show_order_items', function() {
$(this).closest('td').find('table').toggle();
return false;
});

View File

@ -1146,7 +1146,7 @@
'style': style_block
});
div.text(this.search_field.val());
$('body').append(div);
$(document.body).append(div);
w = div.width() + 25;
div.remove();
f_width = this.container.outerWidth();

View File

@ -29,6 +29,6 @@ jQuery( function( $ ) {
$( '#add_payment_method' ).block({ message: null, overlayCSS: { background: '#fff', opacity: 0.6 } });
});
$( 'body' ).trigger( 'init_add_payment_method' );
$(document.body).trigger( 'init_add_payment_method' );
});

View File

@ -25,7 +25,7 @@ jQuery( function( $ ) {
});
// Trigger event
$( 'body' ).trigger( 'adding_to_cart', [ $thisbutton, data ] );
$(document.body).trigger( 'adding_to_cart', [ $thisbutton, data ] );
// Ajax action
$.post( wc_add_to_cart_params.wc_ajax_url + 'add_to_cart', data, function( response ) {
@ -94,7 +94,7 @@ jQuery( function( $ ) {
$( '.shop_table.cart' ).stop( true ).css( 'opacity', '1' ).unblock();
$( 'body' ).trigger( 'cart_page_refreshed' );
$(document.body).trigger( 'cart_page_refreshed' );
});
$( '.cart_totals' ).load( this_page + ' .cart_totals:eq(0) > *', function() {
@ -102,7 +102,7 @@ jQuery( function( $ ) {
});
// Trigger event so themes can refresh other areas
$( 'body' ).trigger( 'added_to_cart', [ fragments, cart_hash, $thisbutton ] );
$(document.body).trigger( 'added_to_cart', [ fragments, cart_hash, $thisbutton ] );
}
});

View File

@ -30,14 +30,14 @@ jQuery( function( $ ) {
sessionStorage.setItem( 'wc_cart_hash', data.cart_hash );
}
$( 'body' ).trigger( 'wc_fragments_refreshed' );
$(document.body).trigger( 'wc_fragments_refreshed' );
}
}
};
if ( $supports_html5_storage ) {
$( 'body' ).bind( 'added_to_cart', function( event, fragments, cart_hash ) {
$(document.body).bind( 'added_to_cart', function( event, fragments, cart_hash ) {
sessionStorage.setItem( wc_cart_fragments_params.fragment_name, JSON.stringify( fragments ) );
sessionStorage.setItem( 'wc_cart_hash', cart_hash );
});
@ -61,7 +61,7 @@ jQuery( function( $ ) {
$( key ).replaceWith(value);
});
$( 'body' ).trigger( 'wc_fragments_loaded' );
$(document.body).trigger( 'wc_fragments_loaded' );
} else {
throw 'No fragment';
@ -82,7 +82,7 @@ jQuery( function( $ ) {
$( '.hide_cart_widget_if_empty' ).closest( '.widget_shopping_cart' ).hide();
}
$( 'body' ).bind( 'adding_to_cart', function() {
$(document.body).bind( 'adding_to_cart', function() {
$( '.hide_cart_widget_if_empty' ).closest( '.widget_shopping_cart' ).show();
} );

View File

@ -34,7 +34,7 @@ jQuery( function( $ ) {
$.post( wc_cart_params.wc_ajax_url + 'update_shipping_method', data, function( response ) {
$( 'div.cart_totals' ).replaceWith( response );
$( 'body' ).trigger( 'updated_shipping_method' );
$(document.body).trigger( 'updated_shipping_method' );
});
});

View File

@ -14,9 +14,9 @@ jQuery( function( $ ) {
$order_review: $( '#order_review' ),
$checkout_form: $( 'form.checkout' ),
init: function() {
$( 'body' ).bind( 'update_checkout', this.reset_update_checkout_timer );
$( 'body' ).bind( 'update_checkout', this.update_checkout );
$( 'body' ).bind( 'init_checkout', this.init_checkout );
$( document.body ).bind( 'update_checkout', this.reset_update_checkout_timer );
$( document.body ).bind( 'update_checkout', this.update_checkout );
$( document.body ).bind( 'init_checkout', this.init_checkout );
// Payment methods
this.$order_review.on( 'click', 'input[name=payment_method]', this.payment_method_selected );
@ -42,7 +42,7 @@ jQuery( function( $ ) {
// Update on page load
if ( wc_checkout_params.is_checkout === '1' ) {
$( 'body' ).trigger( 'init_checkout' );
$(document.body).trigger( 'init_checkout' );
}
if ( wc_checkout_params.option_guest_checkout === 'yes' ) {
$( 'input#createaccount' ).change( this.toggle_create_account ).change();
@ -57,7 +57,7 @@ jQuery( function( $ ) {
},
init_checkout: function( e ) {
$( '#billing_country, #shipping_country, .country_to_state' ).change();
$( 'body' ).trigger( 'update_checkout' );
$(document.body).trigger( 'update_checkout' );
},
maybe_input_changed: function( e ) {
if ( wc_checkout_form.dirtyInput ) {
@ -82,13 +82,13 @@ jQuery( function( $ ) {
trigger_update_checkout: function( e ) {
wc_checkout_form.reset_update_checkout_timer();
wc_checkout_form.dirtyInput = false;
$( 'body' ).trigger( 'update_checkout' );
$(document.body).trigger( 'update_checkout' );
},
maybe_update_checkout: function() {
var update_totals = true;
if ( $( wc_checkout_form.dirtyInput ).size() ) {
$required_inputs = $( wc_checkout_form.dirtyInput ).closest( 'div' ).find( '.address-field.validate-required' );
var $required_inputs = $( wc_checkout_form.dirtyInput ).closest( 'div' ).find( '.address-field.validate-required' );
if ( $required_inputs.size() ) {
$required_inputs.each( function( e ) {
@ -287,7 +287,7 @@ jQuery( function( $ ) {
$( '.woocommerce-checkout' ).find( 'input[name=payment_method]:checked' ).eq(0).trigger( 'click' );
// Fire updated_checkout e
$( 'body' ).trigger( 'updated_checkout' );
$(document.body).trigger( 'updated_checkout' );
}
});
@ -378,10 +378,10 @@ jQuery( function( $ ) {
// Trigger update in case we need a fresh nonce
if ( result.refresh === 'true' ) {
$( 'body' ).trigger( 'update_checkout' );
$(document.body).trigger( 'update_checkout' );
}
$( 'body' ).trigger( 'checkout_error' );
$(document.body).trigger( 'checkout_error' );
}
},
dataType: 'html'
@ -395,8 +395,8 @@ jQuery( function( $ ) {
var wc_checkout_coupons = {
init: function() {
$( 'body' ).on( 'click', 'a.showcoupon', this.show_coupon_form );
$( 'body' ).on( 'click', '.woocommerce-remove-coupon', this.remove_coupon );
$( document.body ).on( 'click', 'a.showcoupon', this.show_coupon_form );
$( document.body ).on( 'click', '.woocommerce-remove-coupon', this.remove_coupon );
$( 'form.checkout_coupon' ).hide().submit( this.submit );
},
show_coupon_form: function( e ) {
@ -435,7 +435,7 @@ jQuery( function( $ ) {
$form.before( code );
$form.slideUp();
$( 'body' ).trigger( 'update_checkout' );
$(document.body).trigger( 'update_checkout' );
}
},
dataType: 'html'
@ -473,7 +473,7 @@ jQuery( function( $ ) {
if ( code ) {
$( 'form.woocommerce-checkout' ).before( code );
$( 'body' ).trigger( 'update_checkout' );
$(document.body).trigger( 'update_checkout' );
// remove coupon code from coupon field
$( 'form.checkout_coupon' ).find( 'input[name="coupon_code"]' ).val( '' );
@ -491,7 +491,7 @@ jQuery( function( $ ) {
var wc_checkout_login_form = {
init: function() {
$( 'body' ).on( 'click', 'a.showlogin', this.show_login_form );
$(document.body).on( 'click', 'a.showlogin', this.show_login_form );
},
show_login_form: function( e ) {
$( 'form.login' ).slideToggle();

View File

@ -74,7 +74,7 @@ jQuery( function( $ ) {
wc_country_select_select2();
$( 'body' ).bind( 'country_to_state_changed', function() {
$(document.body).bind( 'country_to_state_changed', function() {
wc_country_select_select2();
});
}
@ -83,7 +83,7 @@ jQuery( function( $ ) {
var states_json = wc_country_select_params.countries.replace( /&quot;/g, '"' ),
states = $.parseJSON( states_json );
$( 'body' ).on( 'change', 'select.country_to_state, input.country_to_state', function() {
$(document.body).on( 'change', 'select.country_to_state, input.country_to_state', function() {
var country = $( this ).val(),
$statebox = $( this ).closest( 'div' ).find( '#billing_state, #shipping_state, #calc_shipping_state' ),
@ -99,7 +99,7 @@ jQuery( function( $ ) {
$statebox.parent().hide().find( '.select2-container' ).remove();
$statebox.replaceWith( '<input type="hidden" class="hidden" name="' + input_name + '" id="' + input_id + '" value="" placeholder="' + placeholder + '" />' );
$( 'body' ).trigger( 'country_to_state_changed', [country, $( this ).closest( 'div' )] );
$(document.body).trigger( 'country_to_state_changed', [country, $( this ).closest( 'div' )] );
} else {
@ -123,7 +123,7 @@ jQuery( function( $ ) {
$statebox.html( '<option value="">' + wc_country_select_params.i18n_select_state_text + '</option>' + options );
$statebox.val( value ).change();
$( 'body' ).trigger( 'country_to_state_changed', [country, $( this ).closest( 'div' )] );
$(document.body).trigger( 'country_to_state_changed', [country, $( this ).closest( 'div' )] );
}
} else {
@ -132,19 +132,19 @@ jQuery( function( $ ) {
$parent.show().find( '.select2-container' ).remove();
$statebox.replaceWith( '<input type="text" class="input-text" name="' + input_name + '" id="' + input_id + '" placeholder="' + placeholder + '" />' );
$( 'body' ).trigger( 'country_to_state_changed', [country, $( this ).closest( 'div' )] );
$(document.body).trigger( 'country_to_state_changed', [country, $( this ).closest( 'div' )] );
} else if ( $statebox.is( '.hidden' ) ) {
$parent.show().find( '.select2-container' ).remove();
$statebox.replaceWith( '<input type="text" class="input-text" name="' + input_name + '" id="' + input_id + '" placeholder="' + placeholder + '" />' );
$( 'body' ).trigger( 'country_to_state_changed', [country, $( this ).closest( 'div' )] );
$(document.body).trigger( 'country_to_state_changed', [country, $( this ).closest( 'div' )] );
}
}
$( 'body' ).trigger( 'country_to_state_changing', [country, $( this ).closest( 'div' )] );
$(document.body).trigger( 'country_to_state_changing', [country, $( this ).closest( 'div' )] );
});

View File

@ -19,7 +19,7 @@ jQuery( function( $ ) {
if ( woocommerce_price_slider_params.min_price ) current_min_price = parseInt( woocommerce_price_slider_params.min_price, 10 );
if ( woocommerce_price_slider_params.max_price ) current_max_price = parseInt( woocommerce_price_slider_params.max_price, 10 );
$( 'body' ).bind( 'price_slider_create price_slider_slide', function( event, min, max ) {
$(document.body).bind( 'price_slider_create price_slider_slide', function( event, min, max ) {
if ( woocommerce_price_slider_params.currency_pos === 'left' ) {
$( '.price_slider_amount span.from' ).html( woocommerce_price_slider_params.currency_symbol + min );
@ -42,7 +42,7 @@ jQuery( function( $ ) {
}
$( 'body' ).trigger( 'price_slider_updated', min, max );
$(document.body).trigger( 'price_slider_updated', min, max );
});
$( '.price_slider' ).slider({
@ -56,18 +56,18 @@ jQuery( function( $ ) {
$( '.price_slider_amount #min_price' ).val( current_min_price );
$( '.price_slider_amount #max_price' ).val( current_max_price );
$( 'body' ).trigger( 'price_slider_create', [ current_min_price, current_max_price ] );
$(document.body).trigger( 'price_slider_create', [ current_min_price, current_max_price ] );
},
slide: function( event, ui ) {
$( 'input#min_price' ).val( ui.values[0] );
$( 'input#max_price' ).val( ui.values[1] );
$( 'body' ).trigger( 'price_slider_slide', [ ui.values[0], ui.values[1] ] );
$(document.body).trigger( 'price_slider_slide', [ ui.values[0], ui.values[1] ] );
},
change: function( event, ui ) {
$( 'body' ).trigger( 'price_slider_change', [ ui.values[0], ui.values[1] ] );
$(document.body).trigger( 'price_slider_change', [ ui.values[0], ui.values[1] ] );
},
});

View File

@ -473,7 +473,7 @@
var els;
if (full) // crazy selector to handle odd field errors in ie6/7
els = $('body').children().filter('.blockUI').add('body > .blockUI');
els = $(document.body).children().filter('.blockUI').add('body > .blockUI');
else
els = $el.find('>.blockUI');

View File

@ -751,7 +751,7 @@
settings.markup = settings.markup.replace('{pp_social}','');
$('body').append(settings.markup); // Inject the markup
$(document.body).append(settings.markup); // Inject the markup
$pp_pic_holder = $('.pp_pic_holder') , $ppt = $('.ppt'), $pp_overlay = $('div.pp_overlay'); // Set my global selectors

View File

@ -191,6 +191,7 @@ class WC_Admin_Notices {
$outdated = false;
foreach ( $core_templates as $file ) {
$theme_file = false;
if ( file_exists( get_stylesheet_directory() . '/' . $file ) ) {
$theme_file = get_stylesheet_directory() . '/' . $file;
@ -202,7 +203,7 @@ class WC_Admin_Notices {
$theme_file = get_template_directory() . '/woocommerce/' . $file;
}
if ( $theme_file ) {
if ( $theme_file !== false ) {
$core_version = WC_Admin_Status::get_file_version( WC()->plugin_path() . '/templates/' . $file );
$theme_version = WC_Admin_Status::get_file_version( $theme_file );

View File

@ -26,6 +26,9 @@ class WC_Admin_Post_Types {
*/
public function __construct() {
add_filter( 'post_updated_messages', array( $this, 'post_updated_messages' ) );
add_filter( 'bulk_post_updated_messages', array( $this, 'bulk_post_updated_messages' ), 10, 2 );
// Disable Auto Save
add_action( 'admin_print_scripts', array( $this, 'disable_autosave' ) );
// WP List table columns. Defined here so they are always available for events such as inline editing.
@ -85,12 +88,105 @@ class WC_Admin_Post_Types {
include( 'class-wc-admin-duplicate-product.php' );
}
// Meta-Box Class
include_once( 'class-wc-admin-meta-boxes.php' );
// Download permissions
add_action( 'woocommerce_process_product_file_download_paths', array( $this, 'process_product_file_download_paths' ), 10, 3 );
}
/**
* Change messages when a post type is updated.
* @param array $messages
* @return array
*/
public function post_updated_messages( $messages ) {
global $post, $post_ID;
$messages['product'] = array(
0 => '', // Unused. Messages start at index 1.
1 => sprintf( __( 'Product updated. <a href="%s">View Product</a>', 'woocommerce' ), esc_url( get_permalink( $post_ID ) ) ),
2 => __( 'Custom field updated.', 'woocommerce' ),
3 => __( 'Custom field deleted.', 'woocommerce' ),
4 => __( 'Product updated.', 'woocommerce' ),
5 => isset( $_GET['revision'] ) ? sprintf( __( 'Product restored to revision from %s', 'woocommerce' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
6 => sprintf( __( 'Product published. <a href="%s">View Product</a>', 'woocommerce' ), esc_url( get_permalink( $post_ID ) ) ),
7 => __( 'Product saved.', 'woocommerce' ),
8 => sprintf( __( 'Product submitted. <a target="_blank" href="%s">Preview Product</a>', 'woocommerce' ), esc_url( add_query_arg( 'preview', 'true', get_permalink( $post_ID ) ) ) ),
9 => sprintf( __( 'Product scheduled for: <strong>%1$s</strong>. <a target="_blank" href="%2$s">Preview Product</a>', 'woocommerce' ),
date_i18n( __( 'M j, Y @ G:i', 'woocommerce' ), strtotime( $post->post_date ) ), esc_url( get_permalink( $post_ID ) ) ),
10 => sprintf( __( 'Product draft updated. <a target="_blank" href="%s">Preview Product</a>', 'woocommerce' ), esc_url( add_query_arg( 'preview', 'true', get_permalink( $post_ID ) ) ) ),
);
$messages['shop_order'] = array(
0 => '', // Unused. Messages start at index 1.
1 => __( 'Order updated.', 'woocommerce' ),
2 => __( 'Custom field updated.', 'woocommerce' ),
3 => __( 'Custom field deleted.', 'woocommerce' ),
4 => __( 'Order updated.', 'woocommerce' ),
5 => isset( $_GET['revision'] ) ? sprintf( __( 'Order restored to revision from %s', 'woocommerce' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
6 => __( 'Order updated.', 'woocommerce' ),
7 => __( 'Order saved.', 'woocommerce' ),
8 => __( 'Order submitted.', 'woocommerce' ),
9 => sprintf( __( 'Order scheduled for: <strong>%1$s</strong>.', 'woocommerce' ),
date_i18n( __( 'M j, Y @ G:i', 'woocommerce' ), strtotime( $post->post_date ) ) ),
10 => __( 'Order draft updated.', 'woocommerce' ),
11 => __( 'Order updated and email sent.', 'woocommerce' )
);
$messages['shop_coupon'] = array(
0 => '', // Unused. Messages start at index 1.
1 => __( 'Coupon updated.', 'woocommerce' ),
2 => __( 'Custom field updated.', 'woocommerce' ),
3 => __( 'Custom field deleted.', 'woocommerce' ),
4 => __( 'Coupon updated.', 'woocommerce' ),
5 => isset( $_GET['revision'] ) ? sprintf( __( 'Coupon restored to revision from %s', 'woocommerce' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
6 => __( 'Coupon updated.', 'woocommerce' ),
7 => __( 'Coupon saved.', 'woocommerce' ),
8 => __( 'Coupon submitted.', 'woocommerce' ),
9 => sprintf( __( 'Coupon scheduled for: <strong>%1$s</strong>.', 'woocommerce' ),
date_i18n( __( 'M j, Y @ G:i', 'woocommerce' ), strtotime( $post->post_date ) ) ),
10 => __( 'Coupon draft updated.', 'woocommerce' )
);
return $messages;
}
/**
* Specify custom bulk actions messages for different post types.
* @param array $bulk_messages
* @param array $bulk_counts
* @return array
*/
public function bulk_post_updated_messages( $bulk_messages, $bulk_counts ) {
$bulk_messages['product'] = array(
'updated' => _n( '%s product updated.', '%s products updated.', $bulk_counts['updated'] ),
'locked' => _n( '%s product not updated, somebody is editing it.', '%s products not updated, somebody is editing them.', $bulk_counts['locked'] ),
'deleted' => _n( '%s product permanently deleted.', '%s products permanently deleted.', $bulk_counts['deleted'] ),
'trashed' => _n( '%s product moved to the Trash.', '%s products moved to the Trash.', $bulk_counts['trashed'] ),
'untrashed' => _n( '%s product restored from the Trash.', '%s products restored from the Trash.', $bulk_counts['untrashed'] ),
);
$bulk_messages['shop_order'] = array(
'updated' => _n( '%s order updated.', '%s orders updated.', $bulk_counts['updated'] ),
'locked' => _n( '%s order not updated, somebody is editing it.', '%s orders not updated, somebody is editing them.', $bulk_counts['locked'] ),
'deleted' => _n( '%s order permanently deleted.', '%s orders permanently deleted.', $bulk_counts['deleted'] ),
'trashed' => _n( '%s order moved to the Trash.', '%s orders moved to the Trash.', $bulk_counts['trashed'] ),
'untrashed' => _n( '%s order restored from the Trash.', '%s orders restored from the Trash.', $bulk_counts['untrashed'] ),
);
$bulk_messages['shop_coupon'] = array(
'updated' => _n( '%s coupon updated.', '%s coupons updated.', $bulk_counts['updated'] ),
'locked' => _n( '%s coupon not updated, somebody is editing it.', '%s coupons not updated, somebody is editing them.', $bulk_counts['locked'] ),
'deleted' => _n( '%s coupon permanently deleted.', '%s coupons permanently deleted.', $bulk_counts['deleted'] ),
'trashed' => _n( '%s coupon moved to the Trash.', '%s coupons moved to the Trash.', $bulk_counts['trashed'] ),
'untrashed' => _n( '%s coupon restored from the Trash.', '%s coupons restored from the Trash.', $bulk_counts['untrashed'] ),
);
return $bulk_messages;
}
/**
* Define custom columns for products
* @param array $existing_columns
@ -505,7 +601,7 @@ class WC_Admin_Post_Types {
<?php else : ?>
<?php echo apply_filters( 'woocommerce_order_item_name', $item['name'], $item ); ?>
<?php endif; ?>
<?php if ( $item_meta_html ) : ?>
<?php if ( ! empty( $item_meta_html ) ) : ?>
<a class="tips" href="#" data-tip="<?php echo esc_attr( $item_meta_html ); ?>">[?]</a>
<?php endif; ?>
</td>
@ -1669,64 +1765,6 @@ class WC_Admin_Post_Types {
return $where;
}
/**
* Change messages when a post type is updated.
*
* @param array $messages
* @return array
*/
public function post_updated_messages( $messages ) {
global $post, $post_ID;
$messages['product'] = array(
0 => '', // Unused. Messages start at index 1.
1 => sprintf( __( 'Product updated. <a href="%s">View Product</a>', 'woocommerce' ), esc_url( get_permalink( $post_ID ) ) ),
2 => __( 'Custom field updated.', 'woocommerce' ),
3 => __( 'Custom field deleted.', 'woocommerce' ),
4 => __( 'Product updated.', 'woocommerce' ),
5 => isset( $_GET['revision'] ) ? sprintf( __( 'Product restored to revision from %s', 'woocommerce' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
6 => sprintf( __( 'Product published. <a href="%s">View Product</a>', 'woocommerce' ), esc_url( get_permalink( $post_ID ) ) ),
7 => __( 'Product saved.', 'woocommerce' ),
8 => sprintf( __( 'Product submitted. <a target="_blank" href="%s">Preview Product</a>', 'woocommerce' ), esc_url( add_query_arg( 'preview', 'true', get_permalink( $post_ID ) ) ) ),
9 => sprintf( __( 'Product scheduled for: <strong>%1$s</strong>. <a target="_blank" href="%2$s">Preview Product</a>', 'woocommerce' ),
date_i18n( __( 'M j, Y @ G:i', 'woocommerce' ), strtotime( $post->post_date ) ), esc_url( get_permalink( $post_ID ) ) ),
10 => sprintf( __( 'Product draft updated. <a target="_blank" href="%s">Preview Product</a>', 'woocommerce' ), esc_url( add_query_arg( 'preview', 'true', get_permalink( $post_ID ) ) ) ),
);
$messages['shop_order'] = array(
0 => '', // Unused. Messages start at index 1.
1 => __( 'Order updated.', 'woocommerce' ),
2 => __( 'Custom field updated.', 'woocommerce' ),
3 => __( 'Custom field deleted.', 'woocommerce' ),
4 => __( 'Order updated.', 'woocommerce' ),
5 => isset( $_GET['revision'] ) ? sprintf( __( 'Order restored to revision from %s', 'woocommerce' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
6 => __( 'Order updated.', 'woocommerce' ),
7 => __( 'Order saved.', 'woocommerce' ),
8 => __( 'Order submitted.', 'woocommerce' ),
9 => sprintf( __( 'Order scheduled for: <strong>%1$s</strong>.', 'woocommerce' ),
date_i18n( __( 'M j, Y @ G:i', 'woocommerce' ), strtotime( $post->post_date ) ) ),
10 => __( 'Order draft updated.', 'woocommerce' ),
11 => __( 'Order updated and email sent.', 'woocommerce' )
);
$messages['shop_coupon'] = array(
0 => '', // Unused. Messages start at index 1.
1 => __( 'Coupon updated.', 'woocommerce' ),
2 => __( 'Custom field updated.', 'woocommerce' ),
3 => __( 'Custom field deleted.', 'woocommerce' ),
4 => __( 'Coupon updated.', 'woocommerce' ),
5 => isset( $_GET['revision'] ) ? sprintf( __( 'Coupon restored to revision from %s', 'woocommerce' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
6 => __( 'Coupon updated.', 'woocommerce' ),
7 => __( 'Coupon saved.', 'woocommerce' ),
8 => __( 'Coupon submitted.', 'woocommerce' ),
9 => sprintf( __( 'Coupon scheduled for: <strong>%1$s</strong>.', 'woocommerce' ),
date_i18n( __( 'M j, Y @ G:i', 'woocommerce' ), strtotime( $post->post_date ) ) ),
10 => __( 'Coupon draft updated.', 'woocommerce' )
);
return $messages;
}
/**
* Disable the auto-save functionality for Orders.
*/
@ -2048,7 +2086,7 @@ class WC_Admin_Post_Types {
$new_download_ids = array_filter( array_diff( $updated_download_ids, $existing_download_ids ) );
$removed_download_ids = array_filter( array_diff( $existing_download_ids, $updated_download_ids ) );
if ( $new_download_ids || $removed_download_ids ) {
if ( ! empty( $new_download_ids ) || ! empty( $removed_download_ids ) ) {
// determine whether downloadable file access has been granted via the typical order completion, or via the admin ajax method
$existing_permissions = $wpdb->get_results( $wpdb->prepare( "SELECT * from {$wpdb->prefix}woocommerce_downloadable_product_permissions WHERE product_id = %d GROUP BY order_id", $product_id ) );
@ -2057,7 +2095,7 @@ class WC_Admin_Post_Types {
if ( $order->id ) {
// Remove permissions
if ( $removed_download_ids ) {
if ( ! empty( $removed_download_ids ) ) {
foreach ( $removed_download_ids as $download_id ) {
if ( apply_filters( 'woocommerce_process_product_file_download_paths_remove_access_to_old_file', true, $download_id, $product_id, $order ) ) {
$wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}woocommerce_downloadable_product_permissions WHERE order_id = %d AND product_id = %d AND download_id = %s", $order->id, $product_id, $download_id ) );
@ -2065,7 +2103,7 @@ class WC_Admin_Post_Types {
}
}
// Add permissions
if ( $new_download_ids ) {
if ( ! empty( $new_download_ids ) ) {
foreach ( $new_download_ids as $download_id ) {

View File

@ -578,7 +578,7 @@ class WC_Admin_Settings {
<td class="forminp">
<select multiple="multiple" name="<?php echo esc_attr( $value['id'] ); ?>[]" style="width:350px" data-placeholder="<?php _e( 'Choose countries&hellip;', 'woocommerce' ); ?>" title="<?php _e( 'Country', 'woocommerce' ) ?>" class="wc-enhanced-select">
<?php
if ( $countries ) {
if ( ! empty( $countries ) ) {
foreach ( $countries as $key => $val ) {
echo '<option value="' . esc_attr( $key ) . '" ' . selected( in_array( $key, $selections ), true, false ).'>' . $val . '</option>';
}

View File

@ -255,7 +255,7 @@ class WC_Admin_Status {
if ( ! empty( $_REQUEST['log_file'] ) && isset( $logs[ sanitize_title( $_REQUEST['log_file'] ) ] ) ) {
$viewed_log = $logs[ sanitize_title( $_REQUEST['log_file'] ) ];
} elseif ( $logs ) {
} elseif ( ! empty( $logs ) ) {
$viewed_log = current( $logs );
}
@ -301,10 +301,10 @@ class WC_Admin_Status {
*/
public static function scan_template_files( $template_path ) {
$files = scandir( $template_path );
$result = array();
$files = @scandir( $template_path );
$result = array();
if ( $files ) {
if ( ! empty( $files ) ) {
foreach ( $files as $key => $value ) {
@ -329,8 +329,8 @@ class WC_Admin_Status {
* @return array
*/
public static function scan_log_files() {
$files = @scandir( WC_LOG_DIR );
$result = array();
$files = @scandir( WC_LOG_DIR );
$result = array();
if ( $files ) {
@ -342,7 +342,9 @@ class WC_Admin_Status {
}
}
}
}
return $result;
}
}

View File

@ -320,7 +320,7 @@ class WC_Meta_Box_Order_Data {
echo '<p class="none_set"><strong>' . __( 'Address', 'woocommerce' ) . ':</strong> ' . __( 'No shipping address set.', 'woocommerce' ) . '</p>';
}
if ( self::$shipping_fields ) {
if ( ! empty( self::$shipping_fields ) ) {
foreach ( self::$shipping_fields as $key => $field ) {
if ( isset( $field['show'] ) && false === $field['show'] ) {
continue;
@ -343,7 +343,7 @@ class WC_Meta_Box_Order_Data {
// Display form
echo '<div class="edit_address"><p><button class="button load_customer_shipping">' . __( 'Load shipping address', 'woocommerce' ) . '</button> <button class="button billing-same-as-shipping">' . __( 'Copy from billing', 'woocommerce' ) . '</button></p>';
if ( self::$shipping_fields ) {
if ( ! empty( self::$shipping_fields ) ) {
foreach ( self::$shipping_fields as $key => $field ) {
if ( ! isset( $field['type'] ) ) {
$field['type'] = 'text';
@ -396,7 +396,7 @@ class WC_Meta_Box_Order_Data {
// Update meta
update_post_meta( $post_id, '_customer_user', absint( $_POST['customer_user'] ) );
if ( self::$billing_fields ) {
if ( ! empty( self::$billing_fields ) ) {
foreach ( self::$billing_fields as $key => $field ) {
if ( ! isset( $field['id'] ) ){
$field['id'] = '_billing_' . $key;
@ -405,7 +405,7 @@ class WC_Meta_Box_Order_Data {
}
}
if ( self::$shipping_fields ) {
if ( ! empty( self::$shipping_fields ) ) {
foreach ( self::$shipping_fields as $key => $field ) {
if ( ! isset( $field['id'] ) ){
$field['id'] = '_shipping_' . $key;

View File

@ -262,7 +262,7 @@ class WC_Meta_Box_Product_Data {
$classes_options = array();
$classes_options[''] = __( 'Standard', 'woocommerce' );
if ( $tax_classes ) {
if ( ! empty( $tax_classes ) ) {
foreach ( $tax_classes as $class ) {
$classes_options[ sanitize_title( $class ) ] = esc_html( $class );
@ -634,8 +634,7 @@ class WC_Meta_Box_Product_Data {
$tax_class_options = array();
$tax_class_options[''] = __( 'Standard', 'woocommerce' );
if ( $tax_classes ) {
if ( ! empty( $tax_classes ) ) {
foreach ( $tax_classes as $class ) {
$tax_class_options[ sanitize_title( $class ) ] = esc_attr( $class );
}
@ -1018,7 +1017,7 @@ class WC_Meta_Box_Product_Data {
wp_set_object_terms( $post_id, $values, $attribute_names[ $i ] );
}
if ( $values ) {
if ( ! empty( $values ) ) {
// Add attribute to array, but don't set values
$attributes[ sanitize_title( $attribute_names[ $i ] ) ] = array(
'name' => wc_clean( $attribute_names[ $i ] ),
@ -1129,7 +1128,7 @@ class WC_Meta_Box_Product_Data {
$clear_parent_ids[] = absint( $_POST['previous_parent_id'] );
}
if ( $clear_parent_ids ) {
if ( ! empty( $clear_parent_ids ) ) {
foreach ( $clear_parent_ids as $clear_id ) {
$children_by_price = get_posts( array(
'post_parent' => $clear_id,

View File

@ -38,7 +38,7 @@ class WC_Meta_Box_Product_Images {
$attachments = array_filter( explode( ',', $product_image_gallery ) );
if ( $attachments ) {
if ( ! empty( $attachments ) ) {
foreach ( $attachments as $attachment_id ) {
echo '<li class="image" data-attachment_id="' . esc_attr( $attachment_id ) . '">
' . wp_get_attachment_image( $attachment_id, 'thumbnail' ) . '

View File

@ -20,7 +20,7 @@ if ( wc_tax_enabled() ) {
$classes_options = array();
$classes_options[''] = __( 'Standard', 'woocommerce' );
if ( $tax_classes ) {
if ( ! empty( $tax_classes ) ) {
foreach ( $tax_classes as $class ) {
$classes_options[ sanitize_title( $class ) ] = $class;
}
@ -297,8 +297,10 @@ if ( wc_tax_enabled() ) {
<div class="wc-backbone-modal-content">
<section class="wc-backbone-modal-main" role="main">
<header class="wc-backbone-modal-header">
<a class="modal-close modal-close-link" href="#"><span class="close-icon"><span class="screen-reader-text">Close media panel</span></span></a>
<h1><?php _e( 'Add products', 'woocommerce' ); ?></h1>
<button class="modal-close modal-close-link dashicons dashicons-no-alt">
<span class="screen-reader-text">Close modal panel</span>
</button>
</header>
<article>
<form action="" method="post">
@ -313,7 +315,7 @@ if ( wc_tax_enabled() ) {
</section>
</div>
</div>
<div class="wc-backbone-modal-backdrop modal-close">&nbsp;</div>
<div class="wc-backbone-modal-backdrop modal-close"></div>
</script>
<script type="text/template" id="wc-modal-add-tax">
@ -321,8 +323,10 @@ if ( wc_tax_enabled() ) {
<div class="wc-backbone-modal-content">
<section class="wc-backbone-modal-main" role="main">
<header class="wc-backbone-modal-header">
<a class="modal-close modal-close-link" href="#"><span class="close-icon"><span class="screen-reader-text">Close media panel</span></span></a>
<h1><?php _e( 'Add tax', 'woocommerce' ); ?></h1>
<button class="modal-close modal-close-link dashicons dashicons-no-alt">
<span class="screen-reader-text">Close modal panel</span>
</button>
</header>
<article>
<form action="" method="post">
@ -368,5 +372,5 @@ if ( wc_tax_enabled() ) {
</section>
</div>
</div>
<div class="wc-backbone-modal-backdrop modal-close">&nbsp;</div>
<div class="wc-backbone-modal-backdrop modal-close"></div>
</script>

View File

@ -59,7 +59,7 @@ extract( $variation_data );
<div class="woocommerce_variable_attributes wc-metabox-content">
<div class="data">
<p class="form-row form-row-first upload_image">
<a href="#" class="upload_image_button <?php if ( $_thumbnail_id > 0 ) echo 'remove'; ?>" rel="<?php echo esc_attr( $variation_id ); ?>"><img src="<?php if ( ! empty( $image ) ) echo esc_attr( $image ); else echo esc_attr( wc_placeholder_img_src() ); ?>" /><input type="hidden" name="upload_image_id[<?php echo $loop; ?>]" class="upload_image_id" value="<?php echo esc_attr( $_thumbnail_id ); ?>" /></a>
<a href="#" class="upload_image_button tips <?php if ( $_thumbnail_id > 0 ) echo 'remove'; ?>" data-tip="<?php if ( $_thumbnail_id > 0 ) { echo __( 'Remove this image', 'woocommerce' ); } else { echo __( 'Upload an image', 'woocommerce' ); } ?>" rel="<?php echo esc_attr( $variation_id ); ?>"><img src="<?php if ( ! empty( $image ) ) echo esc_attr( $image ); else echo esc_attr( wc_placeholder_img_src() ); ?>" /><input type="hidden" name="upload_image_id[<?php echo $loop; ?>]" class="upload_image_id" value="<?php echo esc_attr( $_thumbnail_id ); ?>" /></a>
</p>
<?php if ( wc_product_sku_enabled() ) : ?>
<p class="sku form-row form-row-last">

View File

@ -35,7 +35,7 @@ class WC_Admin_Report {
* )
*
* @param array $args
* @return array|string depending on query_type
* @return mixed depending on query_type
*/
public function get_order_report_data( $args = array() ) {
global $wpdb;
@ -105,18 +105,24 @@ class WC_Admin_Report {
foreach ( $data as $key => $value ) {
$join_type = isset($value['join_type']) ? $value['join_type'] : 'INNER';
if ( $value['type'] == 'meta' ) {
$joins["meta_{$key}"] = "LEFT JOIN {$wpdb->postmeta} AS meta_{$key} ON posts.ID = meta_{$key}.post_id";
$joins["meta_{$key}"] = "{$join_type} JOIN {$wpdb->postmeta} AS meta_{$key} ON " .
"(posts.ID = meta_{$key}.post_id) " .
"AND (meta_{$key}.meta_key = '{$key}')";
} elseif ( $value['type'] == 'order_item_meta' ) {
$joins["order_items"] = "LEFT JOIN {$wpdb->prefix}woocommerce_order_items AS order_items ON posts.ID = order_items.order_id";
$joins["order_item_meta_{$key}"] = "LEFT JOIN {$wpdb->prefix}woocommerce_order_itemmeta AS order_item_meta_{$key} ON order_items.order_item_id = order_item_meta_{$key}.order_item_id";
$joins["order_items"] = "{$join_type} JOIN {$wpdb->prefix}woocommerce_order_items AS order_items ON (posts.ID = order_items.order_id)";
if ( $value['order_item_type'] ) {
$joins["order_items"] .= " AND (order_items.order_item_type = '{$value['order_item_type']}')";
}
$joins["order_item_meta_{$key}"] = "{$join_type} JOIN {$wpdb->prefix}woocommerce_order_itemmeta AS order_item_meta_{$key} ON " .
"(order_items.order_item_id = order_item_meta_{$key}.order_item_id) " .
" AND (order_item_meta_{$key}.meta_key = '{$key}')";
} elseif ( $value['type'] == 'order_item' ) {
$joins["order_items"] = "LEFT JOIN {$wpdb->prefix}woocommerce_order_items AS order_items ON posts.ID = order_items.order_id";
$joins["order_items"] = "{$join_type} JOIN {$wpdb->prefix}woocommerce_order_items AS order_items ON posts.ID = order_items.order_id";
}
}
@ -128,17 +134,18 @@ class WC_Admin_Report {
if ( ! is_array( $value ) ) {
continue;
}
$join_type = isset($value['join_type']) ? $value['join_type'] : 'INNER';
$key = is_array( $value['meta_key'] ) ? $value['meta_key'][0] . '_array' : $value['meta_key'];
if ( isset( $value['type'] ) && $value['type'] == 'order_item_meta' ) {
$joins["order_items"] = "LEFT JOIN {$wpdb->prefix}woocommerce_order_items AS order_items ON posts.ID = order_items.order_id";
$joins["order_item_meta_{$key}"] = "LEFT JOIN {$wpdb->prefix}woocommerce_order_itemmeta AS order_item_meta_{$key} ON order_items.order_item_id = order_item_meta_{$key}.order_item_id";
$joins["order_items"] = "{$join_type} JOIN {$wpdb->prefix}woocommerce_order_items AS order_items ON posts.ID = order_items.order_id";
$joins["order_item_meta_{$key}"] = "{$join_type} JOIN {$wpdb->prefix}woocommerce_order_itemmeta AS order_item_meta_{$key} ON order_items.order_item_id = order_item_meta_{$key}.order_item_id";
} else {
// If we have a where clause for meta, join the postmeta table
$joins["meta_{$key}"] = "LEFT JOIN {$wpdb->postmeta} AS meta_{$key} ON posts.ID = meta_{$key}.post_id";
$joins["meta_{$key}"] = "{$join_type} JOIN {$wpdb->postmeta} AS meta_{$key} ON posts.ID = meta_{$key}.post_id";
}
}
}
@ -173,21 +180,6 @@ class WC_Admin_Report {
";
}
foreach ( $data as $key => $value ) {
if ( $value['type'] == 'meta' ) {
$query['where'] .= " AND meta_{$key}.meta_key = '{$key}'";
} elseif ( $value['type'] == 'order_item_meta' ) {
if ( $value['order_item_type'] ) {
$query['where'] .= " AND order_items.order_item_type = '{$value['order_item_type']}'";
}
$query['where'] .= " AND order_item_meta_{$key}.meta_key = '{$key}'";
}
}
if ( ! empty( $where_meta ) ) {

View File

@ -9,7 +9,14 @@
*/
class WC_Report_Coupon_Usage extends WC_Admin_Report {
/**
* @var array
*/
public $chart_colours = array();
/**
* @var array
*/
public $coupon_codes = array();
/**
@ -73,13 +80,14 @@ class WC_Report_Coupon_Usage extends WC_Admin_Report {
'order_types' => wc_get_order_types( 'order-count' ),
);
if ( $this->coupon_codes ) {
if ( ! empty( $this->coupon_codes ) ) {
$coupon_code_query = array(
'type' => 'order_item',
'key' => 'order_item_name',
'value' => $this->coupon_codes,
'operator' => 'IN'
);
$total_discount_query['where'][] = $coupon_code_query;
$total_coupons_query['where'][] = $coupon_code_query;
}
@ -94,7 +102,7 @@ class WC_Report_Coupon_Usage extends WC_Admin_Report {
);
$legend[] = array(
'title' => sprintf( __( '%s coupons used in total', 'woocommerce' ), '<strong>' . $total_coupons . '</strong>' ),
'title' => sprintf( __( '%d coupons used in total', 'woocommerce' ), '<strong>' . $total_coupons . '</strong>' ),
'color' => $this->chart_colours['coupon_count' ],
'highlight_series' => 0
);
@ -150,7 +158,6 @@ class WC_Report_Coupon_Usage extends WC_Admin_Report {
* Product selection
*/
public function coupons_widget() {
?>
<h4 class="section_title"><span><?php _e( 'Filter by coupon', 'woocommerce' ); ?></span></h4>
<div class="section">
@ -178,7 +185,7 @@ class WC_Report_Coupon_Usage extends WC_Admin_Report {
'filter_range' => false
) );
if ( $used_coupons ) :
if ( ! is_null( $used_coupons ) ) :
?>
<select id="coupon_codes" name="coupon_codes" class="wc-enhanced-select" data-placeholder="<?php _e( 'Choose coupons&hellip;', 'woocommerce' ); ?>" style="width:100%;">
<option value=""><?php _e( 'All coupons', 'woocommerce' ); ?></option>
@ -235,7 +242,7 @@ class WC_Report_Coupon_Usage extends WC_Admin_Report {
'filter_range' => true
) );
if ( $most_popular ) {
if ( ! is_null( $most_popular ) ) {
foreach ( $most_popular as $coupon ) {
echo '<tr class="' . ( in_array( $coupon->coupon_code, $this->coupon_codes ) ? 'active' : '' ) . '">
<td class="count" width="1%">' . $coupon->coupon_count . '</td>
@ -282,7 +289,7 @@ class WC_Report_Coupon_Usage extends WC_Admin_Report {
'filter_range' => true
) );
if ( $most_discount ) {
if ( ! is_null( $most_discount ) ) {
foreach ( $most_discount as $coupon ) {
echo '<tr class="' . ( in_array( $coupon->coupon_code, $this->coupon_codes ) ? 'active' : '' ) . '">
@ -404,27 +411,28 @@ class WC_Report_Coupon_Usage extends WC_Admin_Report {
'order_types' => wc_get_order_types( 'order-count' )
);
if ( $this->coupon_codes ) {
if ( ! empty( $this->coupon_codes ) ) {
$coupon_code_query = array(
'type' => 'order_item',
'key' => 'order_item_name',
'value' => $this->coupon_codes,
'operator' => 'IN'
);
$order_coupon_counts_query['where'][] = $coupon_code_query;
$order_discount_amounts_query['where'][] = $coupon_code_query;
}
$order_coupon_counts = $this->get_order_report_data( $order_coupon_counts_query );
$order_coupon_counts = $this->get_order_report_data( $order_coupon_counts_query );
$order_discount_amounts = $this->get_order_report_data( $order_discount_amounts_query );
// Prepare data for report
$order_coupon_counts = $this->prepare_chart_data( $order_coupon_counts, 'post_date', 'order_coupon_count' , $this->chart_interval, $this->start_date, $this->chart_groupby );
$order_coupon_counts = $this->prepare_chart_data( $order_coupon_counts, 'post_date', 'order_coupon_count' , $this->chart_interval, $this->start_date, $this->chart_groupby );
$order_discount_amounts = $this->prepare_chart_data( $order_discount_amounts, 'post_date', 'discount_amount', $this->chart_interval, $this->start_date, $this->chart_groupby );
// Encode in json format
$chart_data = json_encode( array(
'order_coupon_counts' => array_values( $order_coupon_counts ),
'order_coupon_counts' => array_values( $order_coupon_counts ),
'order_discount_amounts' => array_values( $order_discount_amounts )
) );
?>

View File

@ -781,7 +781,7 @@ if ( ! defined( 'ABSPATH' ) ) {
'delay': 0
});
$( 'body' ).on( 'copy', '#copy-for-support', function ( e ) {
$(document.body).on( 'copy', '#copy-for-support', function ( e ) {
e.clipboardData.clearData();
e.clipboardData.setData( 'text/plain', $( '#debug-report textarea' ).val() );
e.preventDefault();

View File

@ -1609,7 +1609,7 @@ class WC_API_Products extends WC_API_Resource {
'src' => current( $attachment ),
'title' => get_the_title( $attachment_id ),
'alt' => get_post_meta( $attachment_id, '_wp_attachment_image_alt', true ),
'position' => $position,
'position' => (int) $position,
);
}
@ -1821,7 +1821,7 @@ class WC_API_Products extends WC_API_Resource {
$attributes[] = array(
'name' => wc_attribute_label( $attribute['name'] ),
'slug' => str_replace( 'pa_', '', $attribute['name'] ),
'position' => $attribute['position'],
'position' => (int) $attribute['position'],
'visible' => (bool) $attribute['is_visible'],
'variation' => (bool) $attribute['is_variation'],
'options' => array_map( 'trim', $options ),

View File

@ -961,11 +961,12 @@ class WC_Countries {
);
$address_fields['billing_phone'] = array(
'label' => __( 'Phone', 'woocommerce' ),
'required' => true,
'class' => array( 'form-row-last' ),
'clear' => true,
'validate' => array( 'phone' ),
'label' => __( 'Phone', 'woocommerce' ),
'required' => true,
'type' => 'tel',
'class' => array( 'form-row-last' ),
'clear' => true,
'validate' => array( 'phone' ),
);
}

View File

@ -711,7 +711,7 @@ class WC_Coupon {
$err = __( 'Coupon is not valid.', 'woocommerce' );
break;
case self::E_WC_COUPON_NOT_EXIST:
$err = __( 'Coupon does not exist!', 'woocommerce' );
$err = sprintf( __( 'Coupon "%s" does not exist!', 'woocommerce' ), $this->code );
break;
case self::E_WC_COUPON_INVALID_REMOVED:
$err = sprintf( __( 'Sorry, it seems the coupon "%s" is invalid - it has now been removed from your order.', 'woocommerce' ), $this->code );

View File

@ -35,7 +35,7 @@ class WC_Order_Item_Meta {
* @param bool $return (default: false)
* @param string $hideprefix (default: _)
* @param string $delimiter Delimiter used to separate items when $flat is true
* @return string
* @return string|void
*/
public function display( $flat = false, $return = false, $hideprefix = '_', $delimiter = ", \n" ) {

View File

@ -75,7 +75,7 @@
$( function () {
$( 'body' ).on( 'checkout_error', function () {
$(document.body).on( 'checkout_error', function () {
$( '.simplify-token' ).remove();
});

View File

@ -1787,6 +1787,23 @@ if ( ! function_exists( 'woocommerce_form_field' ) ) {
$field .= '</p>' . $after;
break;
case 'tel' :
$field = '<p class="form-row ' . esc_attr( implode( ' ', $args['class'] ) ) .'" id="' . esc_attr( $args['id'] ) . '_field">';
if ( $args['label'] ) {
$field .= '<label for="' . esc_attr( $args['id'] ) . '" class="' . esc_attr( implode( ' ', $args['label_class'] ) ) .'">' . $args['label'] . $required . '</label>';
}
$field .= '<input type="tel" class="input-text ' . esc_attr( implode( ' ', $args['input_class'] ) ) .'" name="' . esc_attr( $key ) . '" id="' . esc_attr( $args['id'] ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '" '.$args['maxlength'].' value="' . esc_attr( $value ) . '" ' . implode( ' ', $custom_attributes ) . ' />';
if ( $args['description'] ) {
$field .= '<span class="description">' . esc_attr( $args['description'] ) . '</span>';
}
$field .= '</p>' . $after;
break;
case 'select' :

View File

@ -385,7 +385,7 @@ function wc_get_customer_available_downloads( $customer_id ) {
$file_number = 0;
// Get results from valid orders only
$results = $wpdb->get_results( $wpdb->prepare( "
$results = apply_filters( 'woocommerce_permission_list', $wpdb->get_results( $wpdb->prepare( "
SELECT permissions.*
FROM {$wpdb->prefix}woocommerce_downloadable_product_permissions as permissions
WHERE user_id = %d
@ -403,7 +403,7 @@ function wc_get_customer_available_downloads( $customer_id ) {
permissions.access_expires >= %s
)
ORDER BY permissions.order_id, permissions.product_id, permissions.permission_id;
", $customer_id, date( 'Y-m-d', current_time( 'timestamp' ) ) ) );
", $customer_id, date( 'Y-m-d', current_time( 'timestamp' ) ) ) ), $customer_id );
if ( $results ) {

View File

@ -36,11 +36,17 @@ if ( $attachment_ids ) {
if ( ! $image_link )
continue;
$image = wp_get_attachment_image( $attachment_id, apply_filters( 'single_product_small_thumbnail_size', 'shop_thumbnail' ) );
$image_class = esc_attr( implode( ' ', $classes ) );
$image_title = esc_attr( get_the_title( $attachment_id ) );
$image_title = esc_attr( get_the_title( $attachment_id ) );
$image_caption = esc_attr( get_post_field( 'post_excerpt', $attachment_id ) );
echo apply_filters( 'woocommerce_single_product_image_thumbnail_html', sprintf( '<a href="%s" class="%s" title="%s" data-rel="prettyPhoto[product-gallery]">%s</a>', $image_link, $image_class, $image_title, $image ), $attachment_id, $post->ID, $image_class );
$image = wp_get_attachment_image( $attachment_id, apply_filters( 'single_product_small_thumbnail_size', 'shop_thumbnail' ), 0, $attr = array(
'title' => $image_title,
'alt' => $image_title
) );
$image_class = esc_attr( implode( ' ', $classes ) );
echo apply_filters( 'woocommerce_single_product_image_thumbnail_html', sprintf( '<a href="%s" class="%s" title="%s" data-rel="prettyPhoto[product-gallery]">%s</a>', $image_link, $image_class, $image_caption, $image ), $attachment_id, $post->ID, $image_class );
$loop++;
}

View File

@ -34,7 +34,7 @@ A text code coverage summary can be displayed using the `--coverage-text` option
## Writing Tests
* Each test file should roughly correspond to an associated source file, e.g. the `formatting-functions.php` test file covers code in the `wc-formatting-functions.php` file
* Each test file should roughly correspond to an associated source file, e.g. the `formatting/functions.php` test file covers code in the `wc-formatting-functions.php` file
* Each test method should cover a single method or function with one or more assertions
* A single method or function can have multiple associated test methods if it's a large or complex method
* Use the test coverage HTML report (under `tmp/coverage/index.html`) to examine which lines your tests are covering and aim for 100% coverage

View File

@ -0,0 +1,35 @@
<?php
namespace WooCommerce\Tests\Util;
/**
* Class Validation
* @package WooCommerce\Tests\Util
* @since 2.3
*/
class Validation extends \WC_Unit_Test_Case {
/**
* Test is_email()
*
* @since 2.3
*/
public function test_is_email() {
$this->assertEquals( 'email@domain.com', \WC_Validation::is_email( 'email@domain.com' ) );
$this->assertFalse( \WC_Validation::is_email( 'not a mail' ) );
$this->assertFalse( \WC_Validation::is_email( 'http://test.com' ) );
}
/**
* Test is_phone()
*
* @since 2.3
*/
public function test_is_phone() {
$this->assertTrue( \WC_Validation::is_phone( '+00 000 00 00 000' ) );
$this->assertTrue( \WC_Validation::is_phone( '+00-000-00-00-000' ) );
$this->assertTrue( \WC_Validation::is_phone( '(000) 00 00 000' ) );
$this->assertFalse( \WC_Validation::is_phone( '+00.000.00.00.000' ) );
$this->assertFalse( \WC_Validation::is_phone( '+00 aaa dd ee fff' ) );
}
}