Merge pull request #12666 from woocommerce/select2-4

Upgrade Select2 to V4
This commit is contained in:
Mike Jolley 2016-12-24 14:40:09 +00:00 committed by GitHub
commit daea231ab7
29 changed files with 12769 additions and 4530 deletions

File diff suppressed because one or more lines are too long

View File

@ -326,9 +326,6 @@
min-height: 220px;
overflow: hidden;
background: #f5f5f5;
-webkit-box-shadow:
inset 0 1px 0 rgba(255, 255, 255, 0.2),
inset 0 -1px 0 rgba(0, 0, 0, 0.1);
box-shadow:
inset 0 1px 0 rgba(255, 255, 255, 0.2),
inset 0 -1px 0 rgba(0, 0, 0, 0.1);
@ -764,19 +761,6 @@ ul.wc_coupon_list_block {
}
}
.tablenav {
.actions {
overflow: visible;
}
.select2-container {
float: left;
max-width: 200px;
font-size: 14px;
vertical-align: middle;
margin: 1px 6px 1px 1px;
}
}
#woocommerce-order-data {
.hndle,
.handlediv {
@ -1094,32 +1078,6 @@ ul.wc_coupon_list_block {
}
}
.wc-order-add-item {
background: #fff;
vertical-align: top;
border-top: none;
.add_item_id,
.select2-container {
vertical-align: top;
.search-field input {
min-width: 100px;
}
}
.select2-container {
width: 400px !important;
text-align: left;
}
.cancel-action,
.save-action,
.calculate-action {
float: left;
margin-right: 2px;
}
}
.wc-used-coupons {
float: left;
width: 50%;
@ -2583,11 +2541,6 @@ table.wc_shipping {
}
}
}
.select2-container-active {
.select2-choices {
border-color: #777;
}
}
}
.wc-shipping-zone-postcodes-toggle {
margin: 0;
@ -3037,11 +2990,6 @@ img.help_tip {
margin: 0;
position: relative;
.select2-container {
display: block;
max-width: 350px;
}
.forminp-radio ul {
margin: 0;
li {
@ -3056,7 +3004,7 @@ img.help_tip {
}
input.regular-input {
width: 25em;
width: 400px;
}
textarea.wide-input {
@ -3093,7 +3041,7 @@ img.help_tip {
th img.help_tip,
th .woocommerce-help-tip {
margin: 0 -24px 0 0;
margin: 2px -24px 0 0;
float: right;
}
@ -5338,6 +5286,10 @@ table.bar_chart {
min-width: 500px;
}
}
.select2-container {
width: 100% !important;
}
}
.wc-backbone-modal-backdrop {
@ -5453,18 +5405,91 @@ table.bar_chart {
}
/**
* Select2
* Select2 elements.
*/
.select2-drop {
.select2-drop,
.select2-dropdown {
z-index: 999999 !important;
}
.select2-container-multi .select2-choices .select2-search-field input {
font-family: inherit;
font-size: inherit;
font-weight: inherit;
padding: 3px 5px;
.select2-results {
line-height: 1.5em;
.select2-results__option, .select2-results__group {
margin: 0;
padding: 8px;
}
}
.select2-dropdown {
border-color: #ddd;
}
.select2-dropdown--below {
box-shadow: 0 1px 1px rgba(0, 0, 0, 0.1);
}
.select2-dropdown--above {
box-shadow: 0 -1px 1px rgba(0, 0, 0, 0.1);
}
.select2-container {
line-height: 1.85em;
font-size: 14px;
.select2-selection {
border-color: #ddd;
}
.select2-search__field {
min-width: 150px;
}
.select2-selection--single {
height: 32px;
.select2-selection__rendered {
line-height: 32px;
padding-right: 24px;
}
.select2-selection__arrow {
right: 3px;
height: 30px;
}
}
.select2-selection--multiple {
min-height: 28px;
border-radius: 0;
line-height: 1.5;
li {
margin: 0;
}
.select2-selection__choice {
padding: 2px 6px;
}
}
.select2-selection__clear {
color: #999;
margin-top: -1px;
}
.select2-search--inline {
.select2-search__field {
font-family: inherit;
font-size: inherit;
font-weight: inherit;
padding: 3px 0;
}
}
}
.woocommerce table.form-table {
.select2-container {
min-width: 400px !important;
}
}
.post-type-shop_order {
.tablenav {
.actions {
overflow: visible;
}
select,
input {
line-height: 32px;
height: 32px;
}
.select2-container {
float: left;
width: 200px !important;
font-size: 14px;
vertical-align: middle;
margin: 1px 6px 4px 1px;
}
}
}

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

View File

@ -90,9 +90,9 @@ jQuery( function( $ ) {
url: wc_enhanced_select_params.ajax_url,
dataType: 'json',
quietMillis: 250,
data: function( term ) {
data: function( params ) {
return {
term: term,
term: params.term,
action: $( this ).data( 'action' ) || 'woocommerce_json_search_products_and_variations',
security: wc_enhanced_select_params.search_products_nonce,
exclude: $( this ).data( 'exclude' ),
@ -100,7 +100,7 @@ jQuery( function( $ ) {
limit: $( this ).data( 'limit' )
};
},
results: function( data ) {
processResults: function( data ) {
var terms = [];
if ( data ) {
$.each( data, function( id, text ) {
@ -115,50 +115,30 @@ jQuery( function( $ ) {
}
};
if ( $( this ).data( 'multiple' ) === true ) {
select2_args.multiple = true;
select2_args.initSelection = function( element, callback ) {
var data = $.parseJSON( element.attr( 'data-selected' ) );
var selected = [];
$( element.val().split( ',' ) ).each( function( i, val ) {
selected.push({
id: val,
text: data[ val ]
});
});
return callback( selected );
};
select2_args.formatSelection = function( data ) {
return '<div class="selected-option" data-id="' + data.id + '">' + data.text + '</div>';
};
} else {
select2_args.multiple = false;
select2_args.initSelection = function( element, callback ) {
var data = {
id: element.val(),
text: element.attr( 'data-selected' )
};
return callback( data );
};
}
select2_args = $.extend( select2_args, getEnhancedSelectFormatString() );
$( this ).select2( select2_args ).addClass( 'enhanced' );
if ( $( this ).data( 'sortable' ) ) {
$( this ).select2( 'container' ).find( 'ul.select2-choices' ).sortable({
containment: 'parent',
start: function() { $( this ).select2( 'onSortStart' ); },
update: function() { $( this ).select2( 'onSortEnd' ); }
var $select = $(this);
var $list = $( this ).next( '.select2-container' ).find( 'ul.select2-selection__rendered' );
$list.sortable({
placeholder : 'ui-state-highlight select2-selection__choice',
forcePlaceholderSize: true,
items : 'li:not(.select2-search__field)',
tolerance : 'pointer',
stop: function() {
$( $list.find( '.select2-selection__choice' ).get().reverse() ).each( function() {
var id = $( this ).data( 'data' ).id;
var option = $select.find( 'option[value="' + id + '"]' )[0];
$select.prepend( option );
} );
}
});
}
});
// Ajax customer search boxes
$( ':input.wc-customer-search' ).filter( ':not(.enhanced)' ).each( function() {
var select2_args = {
@ -172,15 +152,15 @@ jQuery( function( $ ) {
url: wc_enhanced_select_params.ajax_url,
dataType: 'json',
quietMillis: 250,
data: function( term ) {
data: function( params ) {
return {
term: term,
term: params.term,
action: 'woocommerce_json_search_customers',
security: wc_enhanced_select_params.search_customers_nonce,
exclude: $( this ).data( 'exclude' )
};
},
results: function( data ) {
processResults: function( data ) {
var terms = [];
if ( data ) {
$.each( data, function( id, text ) {
@ -190,59 +170,50 @@ jQuery( function( $ ) {
});
});
}
return { results: terms };
return {
results: terms
};
},
cache: true
}
};
if ( $( this ).data( 'multiple' ) === true ) {
select2_args.multiple = true;
select2_args.initSelection = function( element, callback ) {
var data = $.parseJSON( element.attr( 'data-selected' ) );
var selected = [];
$( element.val().split( ',' ) ).each( function( i, val ) {
selected.push({
id: val,
text: data[ val ]
});
});
return callback( selected );
};
select2_args.formatSelection = function( data ) {
return '<div class="selected-option" data-id="' + data.id + '">' + data.text + '</div>';
};
} else {
select2_args.multiple = false;
select2_args.initSelection = function( element, callback ) {
var data = {
id: element.val(),
text: element.attr( 'data-selected' )
};
return callback( data );
};
}
select2_args = $.extend( select2_args, getEnhancedSelectFormatString() );
$( this ).select2( select2_args ).addClass( 'enhanced' );
if ( $( this ).data( 'sortable' ) ) {
$( this ).select2( 'container' ).find( 'ul.select2-choices' ).sortable({
containment: 'parent',
start: function() { $( this ).select2( 'onSortStart' ); },
update: function() { $( this ).select2( 'onSortEnd' ); }
var $select = $(this);
var $list = $( this ).next( '.select2-container' ).find( 'ul.select2-selection__rendered' );
$list.sortable({
placeholder : 'ui-state-highlight select2-selection__choice',
forcePlaceholderSize: true,
items : 'li:not(.select2-search__field)',
tolerance : 'pointer',
stop: function() {
$( $list.find( '.select2-selection__choice' ).get().reverse() ).each( function() {
var id = $( this ).data( 'data' ).id;
var option = $select.find( 'option[value="' + id + '"]' )[0];
$select.prepend( option );
} );
}
});
}
});
})
// WooCommerce Backbone Modal
.on( 'wc_backbone_modal_before_remove', function() {
$( ':input.wc-enhanced-select, :input.wc-product-search, :input.wc-customer-search' ).select2( 'close' );
$( '.wc-enhanced-select, :input.wc-product-search, :input.wc-customer-search' ).filter( '.select2-hidden-accessible' ).select2( 'close' );
})
.trigger( 'wc-enhanced-select-init' );
$( 'html' ).on( 'click', function( event ) {
if ( this === event.target ) {
$( '.wc-enhanced-select, :input.wc-product-search, :input.wc-customer-search' ).filter( '.select2-hidden-accessible' ).select2( 'close' );
}
} );
});

View File

@ -1 +1 @@
jQuery(function(a){function b(){var a={formatMatches:function(a){return 1===a?wc_enhanced_select_params.i18n_matches_1:wc_enhanced_select_params.i18n_matches_n.replace("%qty%",a)},formatNoMatches:function(){return wc_enhanced_select_params.i18n_no_matches},formatAjaxError:function(){return wc_enhanced_select_params.i18n_ajax_error},formatInputTooShort:function(a,b){var c=b-a.length;return 1===c?wc_enhanced_select_params.i18n_input_too_short_1:wc_enhanced_select_params.i18n_input_too_short_n.replace("%qty%",c)},formatInputTooLong:function(a,b){var c=a.length-b;return 1===c?wc_enhanced_select_params.i18n_input_too_long_1:wc_enhanced_select_params.i18n_input_too_long_n.replace("%qty%",c)},formatSelectionTooBig:function(a){return 1===a?wc_enhanced_select_params.i18n_selection_too_long_1:wc_enhanced_select_params.i18n_selection_too_long_n.replace("%qty%",a)},formatLoadMore:function(){return wc_enhanced_select_params.i18n_load_more},formatSearching:function(){return wc_enhanced_select_params.i18n_searching}};return a}a(document.body).on("wc-enhanced-select-init",function(){a(":input.wc-enhanced-select, :input.chosen_select").filter(":not(.enhanced)").each(function(){var c=a.extend({minimumResultsForSearch:10,allowClear:!!a(this).data("allow_clear"),placeholder:a(this).data("placeholder")},b());a(this).select2(c).addClass("enhanced")}),a(":input.wc-enhanced-select-nostd, :input.chosen_select_nostd").filter(":not(.enhanced)").each(function(){var c=a.extend({minimumResultsForSearch:10,allowClear:!0,placeholder:a(this).data("placeholder")},b());a(this).select2(c).addClass("enhanced")}),a(":input.wc-product-search").filter(":not(.enhanced)").each(function(){var c={allowClear:!!a(this).data("allow_clear"),placeholder:a(this).data("placeholder"),minimumInputLength:a(this).data("minimum_input_length")?a(this).data("minimum_input_length"):"3",escapeMarkup:function(a){return a},ajax:{url:wc_enhanced_select_params.ajax_url,dataType:"json",quietMillis:250,data:function(b){return{term:b,action:a(this).data("action")||"woocommerce_json_search_products_and_variations",security:wc_enhanced_select_params.search_products_nonce,exclude:a(this).data("exclude"),include:a(this).data("include"),limit:a(this).data("limit")}},results:function(b){var c=[];return b&&a.each(b,function(a,b){c.push({id:a,text:b})}),{results:c}},cache:!0}};a(this).data("multiple")===!0?(c.multiple=!0,c.initSelection=function(b,c){var d=a.parseJSON(b.attr("data-selected")),e=[];return a(b.val().split(",")).each(function(a,b){e.push({id:b,text:d[b]})}),c(e)},c.formatSelection=function(a){return'<div class="selected-option" data-id="'+a.id+'">'+a.text+"</div>"}):(c.multiple=!1,c.initSelection=function(a,b){var c={id:a.val(),text:a.attr("data-selected")};return b(c)}),c=a.extend(c,b()),a(this).select2(c).addClass("enhanced"),a(this).data("sortable")&&a(this).select2("container").find("ul.select2-choices").sortable({containment:"parent",start:function(){a(this).select2("onSortStart")},update:function(){a(this).select2("onSortEnd")}})}),a(":input.wc-customer-search").filter(":not(.enhanced)").each(function(){var c={allowClear:!!a(this).data("allow_clear"),placeholder:a(this).data("placeholder"),minimumInputLength:a(this).data("minimum_input_length")?a(this).data("minimum_input_length"):"3",escapeMarkup:function(a){return a},ajax:{url:wc_enhanced_select_params.ajax_url,dataType:"json",quietMillis:250,data:function(b){return{term:b,action:"woocommerce_json_search_customers",security:wc_enhanced_select_params.search_customers_nonce,exclude:a(this).data("exclude")}},results:function(b){var c=[];return b&&a.each(b,function(a,b){c.push({id:a,text:b})}),{results:c}},cache:!0}};a(this).data("multiple")===!0?(c.multiple=!0,c.initSelection=function(b,c){var d=a.parseJSON(b.attr("data-selected")),e=[];return a(b.val().split(",")).each(function(a,b){e.push({id:b,text:d[b]})}),c(e)},c.formatSelection=function(a){return'<div class="selected-option" data-id="'+a.id+'">'+a.text+"</div>"}):(c.multiple=!1,c.initSelection=function(a,b){var c={id:a.val(),text:a.attr("data-selected")};return b(c)}),c=a.extend(c,b()),a(this).select2(c).addClass("enhanced"),a(this).data("sortable")&&a(this).select2("container").find("ul.select2-choices").sortable({containment:"parent",start:function(){a(this).select2("onSortStart")},update:function(){a(this).select2("onSortEnd")}})})}).on("wc_backbone_modal_before_remove",function(){a(":input.wc-enhanced-select, :input.wc-product-search, :input.wc-customer-search").select2("close")}).trigger("wc-enhanced-select-init")});
jQuery(function(a){function b(){var a={formatMatches:function(a){return 1===a?wc_enhanced_select_params.i18n_matches_1:wc_enhanced_select_params.i18n_matches_n.replace("%qty%",a)},formatNoMatches:function(){return wc_enhanced_select_params.i18n_no_matches},formatAjaxError:function(){return wc_enhanced_select_params.i18n_ajax_error},formatInputTooShort:function(a,b){var c=b-a.length;return 1===c?wc_enhanced_select_params.i18n_input_too_short_1:wc_enhanced_select_params.i18n_input_too_short_n.replace("%qty%",c)},formatInputTooLong:function(a,b){var c=a.length-b;return 1===c?wc_enhanced_select_params.i18n_input_too_long_1:wc_enhanced_select_params.i18n_input_too_long_n.replace("%qty%",c)},formatSelectionTooBig:function(a){return 1===a?wc_enhanced_select_params.i18n_selection_too_long_1:wc_enhanced_select_params.i18n_selection_too_long_n.replace("%qty%",a)},formatLoadMore:function(){return wc_enhanced_select_params.i18n_load_more},formatSearching:function(){return wc_enhanced_select_params.i18n_searching}};return a}a(document.body).on("wc-enhanced-select-init",function(){a(":input.wc-enhanced-select, :input.chosen_select").filter(":not(.enhanced)").each(function(){var c=a.extend({minimumResultsForSearch:10,allowClear:!!a(this).data("allow_clear"),placeholder:a(this).data("placeholder")},b());a(this).select2(c).addClass("enhanced")}),a(":input.wc-enhanced-select-nostd, :input.chosen_select_nostd").filter(":not(.enhanced)").each(function(){var c=a.extend({minimumResultsForSearch:10,allowClear:!0,placeholder:a(this).data("placeholder")},b());a(this).select2(c).addClass("enhanced")}),a(":input.wc-product-search").filter(":not(.enhanced)").each(function(){var c={allowClear:!!a(this).data("allow_clear"),placeholder:a(this).data("placeholder"),minimumInputLength:a(this).data("minimum_input_length")?a(this).data("minimum_input_length"):"3",escapeMarkup:function(a){return a},ajax:{url:wc_enhanced_select_params.ajax_url,dataType:"json",quietMillis:250,data:function(b){return{term:b.term,action:a(this).data("action")||"woocommerce_json_search_products_and_variations",security:wc_enhanced_select_params.search_products_nonce,exclude:a(this).data("exclude"),include:a(this).data("include"),limit:a(this).data("limit")}},processResults:function(b){var c=[];return b&&a.each(b,function(a,b){c.push({id:a,text:b})}),{results:c}},cache:!0}};if(c=a.extend(c,b()),a(this).select2(c).addClass("enhanced"),a(this).data("sortable")){var d=a(this),e=a(this).next(".select2-container").find("ul.select2-selection__rendered");e.sortable({placeholder:"ui-state-highlight select2-selection__choice",forcePlaceholderSize:!0,items:"li:not(.select2-search__field)",tolerance:"pointer",stop:function(){a(e.find(".select2-selection__choice").get().reverse()).each(function(){var b=a(this).data("data").id,c=d.find('option[value="'+b+'"]')[0];d.prepend(c)})}})}}),a(":input.wc-customer-search").filter(":not(.enhanced)").each(function(){var c={allowClear:!!a(this).data("allow_clear"),placeholder:a(this).data("placeholder"),minimumInputLength:a(this).data("minimum_input_length")?a(this).data("minimum_input_length"):"3",escapeMarkup:function(a){return a},ajax:{url:wc_enhanced_select_params.ajax_url,dataType:"json",quietMillis:250,data:function(b){return{term:b.term,action:"woocommerce_json_search_customers",security:wc_enhanced_select_params.search_customers_nonce,exclude:a(this).data("exclude")}},processResults:function(b){var c=[];return b&&a.each(b,function(a,b){c.push({id:a,text:b})}),{results:c}},cache:!0}};if(c=a.extend(c,b()),a(this).select2(c).addClass("enhanced"),a(this).data("sortable")){var d=a(this),e=a(this).next(".select2-container").find("ul.select2-selection__rendered");e.sortable({placeholder:"ui-state-highlight select2-selection__choice",forcePlaceholderSize:!0,items:"li:not(.select2-search__field)",tolerance:"pointer",stop:function(){a(e.find(".select2-selection__choice").get().reverse()).each(function(){var b=a(this).data("data").id,c=d.find('option[value="'+b+'"]')[0];d.prepend(c)})}})}})}).on("wc_backbone_modal_before_remove",function(){a(".wc-enhanced-select, :input.wc-product-search, :input.wc-customer-search").filter(".select2-hidden-accessible").select2("close")}).trigger("wc-enhanced-select-init"),a("html").on("click",function(b){this===b.target&&a(".wc-enhanced-select, :input.wc-product-search, :input.wc-customer-search").filter(".select2-hidden-accessible").select2("close")})});

6436
assets/js/select2/select2.full.js vendored Executable file

File diff suppressed because it is too large Load Diff

3
assets/js/select2/select2.full.min.js vendored Executable file

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 one or more lines are too long

View File

@ -1686,7 +1686,7 @@ class WC_Product extends WC_Abstract_Legacy_Product {
} else {
$identifier = '#' . $this->get_id();
}
return sprintf( '%s &ndash; %s', $identifier, $this->get_name() );
return sprintf( '%2$s (%1$s)', $identifier, $this->get_name() );
}
/**

View File

@ -384,8 +384,8 @@ abstract class WC_Settings_API {
?>
<tr valign="top">
<th scope="row" class="titledesc">
<label for="<?php echo esc_attr( $field_key ); ?>"><?php echo wp_kses_post( $data['title'] ); ?></label>
<?php echo $this->get_tooltip_html( $data ); ?>
<label for="<?php echo esc_attr( $field_key ); ?>"><?php echo wp_kses_post( $data['title'] ); ?></label>
</th>
<td class="forminp">
<fieldset>
@ -428,8 +428,8 @@ abstract class WC_Settings_API {
?>
<tr valign="top">
<th scope="row" class="titledesc">
<label for="<?php echo esc_attr( $field_key ); ?>"><?php echo wp_kses_post( $data['title'] ); ?></label>
<?php echo $this->get_tooltip_html( $data ); ?>
<label for="<?php echo esc_attr( $field_key ); ?>"><?php echo wp_kses_post( $data['title'] ); ?></label>
</th>
<td class="forminp">
<fieldset>
@ -472,8 +472,8 @@ abstract class WC_Settings_API {
?>
<tr valign="top">
<th scope="row" class="titledesc">
<label for="<?php echo esc_attr( $field_key ); ?>"><?php echo wp_kses_post( $data['title'] ); ?></label>
<?php echo $this->get_tooltip_html( $data ); ?>
<label for="<?php echo esc_attr( $field_key ); ?>"><?php echo wp_kses_post( $data['title'] ); ?></label>
</th>
<td class="forminp">
<fieldset>
@ -528,8 +528,8 @@ abstract class WC_Settings_API {
?>
<tr valign="top">
<th scope="row" class="titledesc">
<label for="<?php echo esc_attr( $field_key ); ?>"><?php echo wp_kses_post( $data['title'] ); ?></label>
<?php echo $this->get_tooltip_html( $data ); ?>
<label for="<?php echo esc_attr( $field_key ); ?>"><?php echo wp_kses_post( $data['title'] ); ?></label>
</th>
<td class="forminp">
<fieldset>
@ -574,8 +574,8 @@ abstract class WC_Settings_API {
?>
<tr valign="top">
<th scope="row" class="titledesc">
<label for="<?php echo esc_attr( $field_key ); ?>"><?php echo wp_kses_post( $data['title'] ); ?></label>
<?php echo $this->get_tooltip_html( $data ); ?>
<label for="<?php echo esc_attr( $field_key ); ?>"><?php echo wp_kses_post( $data['title'] ); ?></label>
</th>
<td class="forminp">
<fieldset>
@ -622,8 +622,8 @@ abstract class WC_Settings_API {
?>
<tr valign="top">
<th scope="row" class="titledesc">
<label for="<?php echo esc_attr( $field_key ); ?>"><?php echo wp_kses_post( $data['title'] ); ?></label>
<?php echo $this->get_tooltip_html( $data ); ?>
<label for="<?php echo esc_attr( $field_key ); ?>"><?php echo wp_kses_post( $data['title'] ); ?></label>
</th>
<td class="forminp">
<fieldset>
@ -668,8 +668,8 @@ abstract class WC_Settings_API {
?>
<tr valign="top">
<th scope="row" class="titledesc">
<label for="<?php echo esc_attr( $field_key ); ?>"><?php echo wp_kses_post( $data['title'] ); ?></label>
<?php echo $this->get_tooltip_html( $data ); ?>
<label for="<?php echo esc_attr( $field_key ); ?>"><?php echo wp_kses_post( $data['title'] ); ?></label>
</th>
<td class="forminp">
<fieldset>
@ -719,8 +719,8 @@ abstract class WC_Settings_API {
?>
<tr valign="top">
<th scope="row" class="titledesc">
<label for="<?php echo esc_attr( $field_key ); ?>"><?php echo wp_kses_post( $data['title'] ); ?></label>
<?php echo $this->get_tooltip_html( $data ); ?>
<label for="<?php echo esc_attr( $field_key ); ?>"><?php echo wp_kses_post( $data['title'] ); ?></label>
</th>
<td class="forminp">
<fieldset>

View File

@ -106,7 +106,7 @@ class WC_Admin_Assets {
wp_register_script( 'wc-shipping-zones', WC()->plugin_url() . '/assets/js/admin/wc-shipping-zones' . $suffix . '.js', array( 'jquery', 'wp-util', 'underscore', 'backbone', 'jquery-ui-sortable', 'wc-enhanced-select', 'wc-backbone-modal' ), WC_VERSION );
wp_register_script( 'wc-shipping-zone-methods', WC()->plugin_url() . '/assets/js/admin/wc-shipping-zone-methods' . $suffix . '.js', array( 'jquery', 'wp-util', 'underscore', 'backbone', 'jquery-ui-sortable', 'wc-backbone-modal' ), WC_VERSION );
wp_register_script( 'wc-shipping-classes', WC()->plugin_url() . '/assets/js/admin/wc-shipping-classes' . $suffix . '.js', array( 'jquery', 'wp-util', 'underscore', 'backbone' ), WC_VERSION );
wp_register_script( 'select2', WC()->plugin_url() . '/assets/js/select2/select2' . $suffix . '.js', array( 'jquery' ), '3.5.4' );
wp_register_script( 'select2', WC()->plugin_url() . '/assets/js/select2/select2.full' . $suffix . '.js', array( 'jquery' ), '4.0.3' );
wp_register_script( 'wc-enhanced-select', WC()->plugin_url() . '/assets/js/admin/wc-enhanced-select' . $suffix . '.js', array( 'jquery', 'select2' ), WC_VERSION );
wp_localize_script( 'wc-enhanced-select', 'wc_enhanced_select_params', array(
'i18n_matches_1' => _x( 'One result is available, press enter to select it.', 'enhanced select', 'woocommerce' ),

View File

@ -1586,7 +1586,9 @@ class WC_Admin_Post_Types {
);
}
?>
<input type="hidden" class="wc-customer-search" name="_customer_user" data-placeholder="<?php esc_attr_e( 'Search for a customer&hellip;', 'woocommerce' ); ?>" data-selected="<?php echo htmlspecialchars( $user_string ); ?>" value="<?php echo $user_id; ?>" data-allow_clear="true" />
<select class="wc-customer-search" name="_customer_user" data-placeholder="<?php esc_attr_e( 'Search for a customer&hellip;', 'woocommerce' ); ?>" data-allow_clear="true">
<option value="<?php echo esc_attr( $user_id ); ?>" selected="selected"><?php echo htmlspecialchars( $user_string ); ?><option>
</select>
<?php
}

View File

@ -90,7 +90,7 @@ class WC_Admin_Setup_Wizard {
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
wp_register_script( 'jquery-blockui', WC()->plugin_url() . '/assets/js/jquery-blockui/jquery.blockUI' . $suffix . '.js', array( 'jquery' ), '2.70', true );
wp_register_script( 'select2', WC()->plugin_url() . '/assets/js/select2/select2' . $suffix . '.js', array( 'jquery' ), '3.5.2' );
wp_register_script( 'select2', WC()->plugin_url() . '/assets/js/select2/select2.full' . $suffix . '.js', array( 'jquery' ), '4.0.3' );
wp_register_script( 'wc-enhanced-select', WC()->plugin_url() . '/assets/js/admin/wc-enhanced-select' . $suffix . '.js', array( 'jquery', 'select2' ), WC_VERSION );
wp_localize_script( 'wc-enhanced-select', 'wc_enhanced_select_params', array(
'i18n_matches_1' => _x( 'One result is available, press enter to select it.', 'enhanced select', 'woocommerce' ),

View File

@ -102,37 +102,35 @@ class WC_Meta_Box_Coupon_Data {
// Product ids
?>
<p class="form-field"><label><?php _e( 'Products', 'woocommerce' ); ?></label>
<input type="hidden" class="wc-product-search" data-multiple="true" style="width: 50%;" name="product_ids" data-placeholder="<?php esc_attr_e( 'Search for a product&hellip;', 'woocommerce' ); ?>" data-action="woocommerce_json_search_products_and_variations" data-selected="<?php
$product_ids = $coupon->get_product_ids();
$json_ids = array();
<select class="wc-product-search" multiple="multiple" style="width: 50%;" name="product_ids[]" data-placeholder="<?php esc_attr_e( 'Search for a product&hellip;', 'woocommerce' ); ?>" data-action="woocommerce_json_search_products_and_variations">
<?php
$product_ids = $coupon->get_product_ids();
foreach ( $product_ids as $product_id ) {
$product = wc_get_product( $product_id );
if ( is_object( $product ) ) {
$json_ids[ $product_id ] = wp_kses_post( $product->get_formatted_name() );
foreach ( $product_ids as $product_id ) {
$product = wc_get_product( $product_id );
if ( is_object( $product ) ) {
echo '<option value="' . esc_attr( $product_id ) . '"' . selected( true, true, false ) . '>' . wp_kses_post( $product->get_formatted_name() ) . '</option>';
}
}
}
echo esc_attr( json_encode( $json_ids ) );
?>" value="<?php echo implode( ',', array_keys( $json_ids ) ); ?>" /> <?php echo wc_help_tip( __( 'Products which need to be in the cart to use this coupon or, for "Product Discounts", which products are discounted.', 'woocommerce' ) ); ?></p>
?>
</select> <?php echo wc_help_tip( __( 'Products which need to be in the cart to use this coupon or, for "Product Discounts", which products are discounted.', 'woocommerce' ) ); ?></p>
<?php
// Exclude Product ids
?>
<p class="form-field"><label><?php _e( 'Exclude products', 'woocommerce' ); ?></label>
<input type="hidden" class="wc-product-search" data-multiple="true" style="width: 50%;" name="exclude_product_ids" data-placeholder="<?php esc_attr_e( 'Search for a product&hellip;', 'woocommerce' ); ?>" data-action="woocommerce_json_search_products_and_variations" data-selected="<?php
$product_ids = $coupon->get_excluded_product_ids();
$json_ids = array();
<select class="wc-product-search" multiple="multiple" style="width: 50%;" name="exclude_product_ids[]" data-placeholder="<?php esc_attr_e( 'Search for a product&hellip;', 'woocommerce' ); ?>" data-action="woocommerce_json_search_products_and_variations">
<?php
$product_ids = $coupon->get_excluded_product_ids();
foreach ( $product_ids as $product_id ) {
$product = wc_get_product( $product_id );
if ( is_object( $product ) ) {
$json_ids[ $product_id ] = wp_kses_post( $product->get_formatted_name() );
foreach ( $product_ids as $product_id ) {
$product = wc_get_product( $product_id );
if ( is_object( $product ) ) {
echo '<option value="' . esc_attr( $product_id ) . '"' . selected( true, true, false ) . '>' . wp_kses_post( $product->get_formatted_name() ) . '</option>';
}
}
}
echo esc_attr( json_encode( $json_ids ) );
?>" value="<?php echo implode( ',', array_keys( $json_ids ) ); ?>" /> <?php echo wc_help_tip( __( 'Products which must not be in the cart to use this coupon or, for "Product Discounts", which products are not discounted.', 'woocommerce' ) ); ?></p>
?>
</select> <?php echo wc_help_tip( __( 'Products which must not be in the cart to use this coupon or, for "Product Discounts", which products are not discounted.', 'woocommerce' ) ); ?></p>
<?php
echo '</div><div class="options_group">';
@ -279,8 +277,8 @@ class WC_Meta_Box_Coupon_Data {
'amount' => wc_format_decimal( $_POST['coupon_amount'] ),
'date_expires' => wc_clean( $_POST['expiry_date'] ),
'individual_use' => isset( $_POST['individual_use'] ),
'product_ids' => array_filter( array_map( 'intval', explode( ',', $_POST['product_ids'] ) ) ),
'excluded_product_ids' => array_filter( array_map( 'intval', explode( ',', $_POST['exclude_product_ids'] ) ) ),
'product_ids' => array_filter( array_map( 'intval', (array) $_POST['product_ids'] ) ),
'excluded_product_ids' => array_filter( array_map( 'intval', (array) $_POST['exclude_product_ids'] ) ),
'usage_limit' => absint( $_POST['usage_limit'] ),
'usage_limit_per_user' => absint( $_POST['usage_limit_per_user'] ),
'limit_usage_to_x_items' => absint( $_POST['limit_usage_to_x_items'] ),

View File

@ -262,7 +262,9 @@ class WC_Meta_Box_Order_Data {
);
}
?>
<input type="hidden" class="wc-customer-search" id="customer_user" name="customer_user" data-placeholder="<?php esc_attr_e( 'Guest', 'woocommerce' ); ?>" data-selected="<?php echo htmlspecialchars( $user_string ); ?>" value="<?php echo $user_id; ?>" data-allow_clear="true" />
<select class="wc-customer-search" id="customer_user" name="customer_user" data-placeholder="<?php esc_attr_e( 'Guest', 'woocommerce' ); ?>" data-allow_clear="true">
<option value="<?php echo esc_attr( $user_id ); ?>" selected="selected"><?php echo htmlspecialchars( $user_string ); ?><option>
</select>
</p>
<?php do_action( 'woocommerce_admin_order_data_after_order_details', $order ); ?>
</div>

View File

@ -64,7 +64,7 @@ class WC_Meta_Box_Order_Downloads {
<div class="toolbar">
<p class="buttons">
<input type="hidden" id="grant_access_id" name="grant_access_id" data-multiple="true" class="wc-product-search" style="width: 400px;" data-placeholder="<?php esc_attr_e( 'Search for a downloadable product&hellip;', 'woocommerce' ); ?>" data-action="woocommerce_json_search_downloadable_products_and_variations" />
<select id="grant_access_id" class="wc-product-search" name="grant_access_id[]" multiple="multiple" style="width: 400px;" data-placeholder="<?php esc_attr_e( 'Search for a downloadable product&hellip;', 'woocommerce' ); ?>" data-action="woocommerce_json_search_downloadable_products_and_variations"></select>
<button type="button" class="button grant_access"><?php _e( 'Grant access', 'woocommerce' ); ?></button>
</p>
<div class="clear"></div>

View File

@ -166,7 +166,7 @@ class WC_Meta_Box_Product_Data {
* @return array
*/
private static function prepare_children() {
return isset( $_POST['grouped_products'] ) ? array_filter( array_map( 'intval', explode( ',', $_POST['grouped_products'] ) ) ) : array();
return isset( $_POST['grouped_products'] ) ? array_filter( array_map( 'intval', (array) $_POST['grouped_products'] ) ) : array();
}
/**
@ -277,8 +277,8 @@ class WC_Meta_Box_Product_Data {
'height' => wc_clean( $_POST['_height'] ),
'shipping_class_id' => absint( $_POST['product_shipping_class'] ),
'sold_individually' => ! empty( $_POST['_sold_individually'] ),
'upsell_ids' => array_map( 'intval', explode( ',', $_POST['upsell_ids'] ) ),
'cross_sell_ids' => array_map( 'intval', explode( ',', $_POST['crosssell_ids'] ) ),
'upsell_ids' => array_map( 'intval', (array) $_POST['upsell_ids'] ),
'cross_sell_ids' => array_map( 'intval', (array) $_POST['crosssell_ids'] ),
'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'] ),

View File

@ -283,7 +283,7 @@ if ( wc_tax_enabled() ) {
</header>
<article>
<form action="" method="post">
<input type="hidden" id="add_item_id" name="add_order_items" class="wc-product-search" style="width: 100%;" data-placeholder="<?php esc_attr_e( 'Search for a product&hellip;', 'woocommerce' ); ?>" data-multiple="true" />
<select class="wc-product-search" multiple="multiple" style="width: 50%;" id="add_item_id" name="add_order_items" data-placeholder="<?php esc_attr_e( 'Search for a product&hellip;', 'woocommerce' ); ?>"></select>
</form>
</article>
<footer>

View File

@ -3,53 +3,50 @@
<div class="options_group">
<p class="form-field">
<label for="upsell_ids"><?php _e( 'Up-sells', 'woocommerce' ); ?></label>
<input type="hidden" class="wc-product-search" style="width: 50%;" id="upsell_ids" name="upsell_ids" data-placeholder="<?php esc_attr_e( 'Search for a product&hellip;', 'woocommerce' ); ?>" data-action="woocommerce_json_search_products_and_variations" data-multiple="true" data-exclude="<?php echo intval( $post->ID ); ?>" data-selected="<?php
$product_ids = $product_object->get_upsell_ids( 'edit' );
$json_ids = array();
<select class="wc-product-search" multiple="multiple" style="width: 50%;" id="upsell_ids" name="upsell_ids[]" data-placeholder="<?php esc_attr_e( 'Search for a product&hellip;', 'woocommerce' ); ?>" data-action="woocommerce_json_search_products_and_variations" data-exclude="<?php echo intval( $post->ID ); ?>">
<?php
$product_ids = $product_object->get_upsell_ids( 'edit' );
foreach ( $product_ids as $product_id ) {
$product = wc_get_product( $product_id );
if ( is_object( $product ) ) {
$json_ids[ $product_id ] = wp_kses_post( html_entity_decode( $product->get_formatted_name(), ENT_QUOTES, get_bloginfo( 'charset' ) ) );
foreach ( $product_ids as $product_id ) {
$product = wc_get_product( $product_id );
if ( is_object( $product ) ) {
echo '<option value="' . esc_attr( $product_id ) . '"' . selected( true, true, false ) . '>' . wp_kses_post( $product->get_formatted_name() ) . '</option>';
}
}
}
echo esc_attr( json_encode( $json_ids ) );
?>" value="<?php echo implode( ',', array_keys( $json_ids ) ); ?>" /> <?php echo wc_help_tip( __( 'Up-sells are products which you recommend instead of the currently viewed product, for example, products that are more profitable or better quality or more expensive.', 'woocommerce' ) ); ?>
?>
</select> <?php echo wc_help_tip( __( 'Up-sells are products which you recommend instead of the currently viewed product, for example, products that are more profitable or better quality or more expensive.', 'woocommerce' ) ); ?>
</p>
<p class="form-field">
<label for="crosssell_ids"><?php _e( 'Cross-sells', 'woocommerce' ); ?></label>
<input type="hidden" class="wc-product-search" style="width: 50%;" id="crosssell_ids" name="crosssell_ids" data-placeholder="<?php esc_attr_e( 'Search for a product&hellip;', 'woocommerce' ); ?>" data-action="woocommerce_json_search_products_and_variations" data-multiple="true" data-exclude="<?php echo intval( $post->ID ); ?>" data-selected="<?php
$product_ids = $product_object->get_cross_sell_ids( 'edit' );
$json_ids = array();
<select class="wc-product-search" multiple="multiple" style="width: 50%;" id="crosssell_ids" name="crosssell_ids[]" data-placeholder="<?php esc_attr_e( 'Search for a product&hellip;', 'woocommerce' ); ?>" data-action="woocommerce_json_search_products_and_variations" data-exclude="<?php echo intval( $post->ID ); ?>">
<?php
$product_ids = $product_object->get_cross_sell_ids( 'edit' );
foreach ( $product_ids as $product_id ) {
$product = wc_get_product( $product_id );
if ( is_object( $product ) ) {
$json_ids[ $product_id ] = wp_kses_post( html_entity_decode( $product->get_formatted_name(), ENT_QUOTES, get_bloginfo( 'charset' ) ) );
foreach ( $product_ids as $product_id ) {
$product = wc_get_product( $product_id );
if ( is_object( $product ) ) {
echo '<option value="' . esc_attr( $product_id ) . '"' . selected( true, true, false ) . '>' . wp_kses_post( $product->get_formatted_name() ) . '</option>';
}
}
}
echo esc_attr( json_encode( $json_ids ) );
?>" value="<?php echo implode( ',', array_keys( $json_ids ) ); ?>" /> <?php echo wc_help_tip( __( 'Cross-sells are products which you promote in the cart, based on the current product.', 'woocommerce' ) ); ?>
?>
</select> <?php echo wc_help_tip( __( 'Cross-sells are products which you promote in the cart, based on the current product.', 'woocommerce' ) ); ?>
</p>
<p class="form-field show_if_grouped">
<label for="grouped_products"><?php _e( 'Grouped products', 'woocommerce' ); ?></label>
<input type="hidden" class="wc-product-search" style="width: 50%;" id="grouped_products" name="grouped_products" data-placeholder="<?php esc_attr_e( 'Search for a product&hellip;', 'woocommerce' ); ?>" data-action="woocommerce_json_search_products" data-multiple="true" data-exclude="<?php echo intval( $post->ID ); ?>" data-selected="<?php
$product_ids = $product_object->get_children( 'edit' );
$json_ids = array();
<select class="wc-product-search" multiple="multiple" style="width: 50%;" id="grouped_products" name="grouped_products[]" data-placeholder="<?php esc_attr_e( 'Search for a product&hellip;', 'woocommerce' ); ?>" data-action="woocommerce_json_search_products" data-exclude="<?php echo intval( $post->ID ); ?>">
<?php
$product_ids = $product_object->get_children( 'edit' );
foreach ( $product_ids as $product_id ) {
$product = wc_get_product( $product_id );
if ( is_object( $product ) ) {
$json_ids[ $product_id ] = wp_kses_post( html_entity_decode( $product->get_formatted_name(), ENT_QUOTES, get_bloginfo( 'charset' ) ) );
}
}
echo esc_attr( json_encode( $json_ids ) );
?>" value="<?php echo implode( ',', array_keys( $json_ids ) ); ?>" /> <?php echo wc_help_tip( __( 'This lets you choose which products are part of this group.', 'woocommerce' ) ); ?>
foreach ( $product_ids as $product_id ) {
$product = wc_get_product( $product_id );
if ( is_object( $product ) ) {
echo '<option value="' . esc_attr( $product_id ) . '"' . selected( true, true, false ) . '>' . wp_kses_post( $product->get_formatted_name() ) . '</option>';
}
}
?>
</select> <?php echo wc_help_tip( __( 'This lets you choose which products are part of this group.', 'woocommerce' ) ); ?>
</p>
</div>

View File

@ -201,7 +201,7 @@ class WC_Report_Sales_By_Product extends WC_Admin_Report {
<div class="section">
<form method="GET">
<div>
<input type="hidden" class="wc-product-search" style="width:203px;" name="product_ids[]" data-placeholder="<?php esc_attr_e( 'Search for a product&hellip;', 'woocommerce' ); ?>" data-action="woocommerce_json_search_products_and_variations" />
<select class="wc-product-search" style="width:203px;" multiple="multiple" id="product_ids" name="product_ids[]" data-placeholder="<?php esc_attr_e( 'Search for a product&hellip;', 'woocommerce' ); ?>" data-action="woocommerce_json_search_products_and_variations"></select>
<input type="submit" class="submit button" value="<?php esc_attr_e( 'Show', 'woocommerce' ); ?>" />
<input type="hidden" name="range" value="<?php if ( ! empty( $_GET['range'] ) ) echo esc_attr( $_GET['range'] ) ?>" />
<input type="hidden" name="start_date" value="<?php if ( ! empty( $_GET['start_date'] ) ) echo esc_attr( $_GET['start_date'] ) ?>" />

View File

@ -38,7 +38,9 @@ if ( ! defined( 'ABSPATH' ) ) {
$user->user_email
);
?>
<input type="hidden" class="wc-customer-search" id="key_user" data-placeholder="<?php esc_attr_e( 'Search for a customer&hellip;', 'woocommerce' ); ?>" data-selected="<?php echo esc_attr( $user_string ); ?>" value="<?php echo esc_attr( $user_id ); ?>" data-allow_clear="true" />
<select class="wc-customer-search" id="key_user" data-placeholder="<?php esc_attr_e( 'Search for a user&hellip;', 'woocommerce' ); ?>" data-allow_clear="true">
<option value="<?php echo esc_attr( $user_id ); ?>" selected="selected"><?php echo $user_string; ?><option>
</select>
</td>
</tr>
<tr valign="top">

View File

@ -201,9 +201,9 @@ class WC_Frontend_Scripts {
'version' => WC_VERSION,
),
'select2' => array(
'src' => self::get_asset_url( 'assets/js/select2/select2' . $suffix . '.js' ),
'src' => self::get_asset_url( 'assets/js/select2/select2.full' . $suffix . '.js' ),
'deps' => array( 'jquery' ),
'version' => '3.5.4',
'version' => '4.0.3',
),
'wc-address-i18n' => array(
'src' => self::get_asset_url( 'assets/js/frontend/address-i18n' . $suffix . '.js' ),

View File

@ -96,7 +96,7 @@ class WC_Gateway_COD extends WC_Payment_Gateway {
'title' => __( 'Enable for shipping methods', 'woocommerce' ),
'type' => 'multiselect',
'class' => 'wc-enhanced-select',
'css' => 'width: 450px;',
'css' => 'width: 400px;',
'default' => '',
'description' => __( 'If COD is only available for certain methods, set it up here. Leave blank to enable for all methods.', 'woocommerce' ),
'options' => $shipping_methods,

View File

@ -37,7 +37,7 @@ $settings = array(
'title' => __( 'Specific countries', 'woocommerce' ),
'type' => 'multiselect',
'class' => 'wc-enhanced-select',
'css' => 'width: 450px;',
'css' => 'width: 400px;',
'default' => '',
'options' => WC()->countries->get_shipping_countries(),
'custom_attributes' => array(

View File

@ -106,7 +106,7 @@ class WC_Shipping_Legacy_Free_Shipping extends WC_Shipping_Method {
'title' => __( 'Specific countries', 'woocommerce' ),
'type' => 'multiselect',
'class' => 'wc-enhanced-select',
'css' => 'width: 450px;',
'css' => 'width: 400px;',
'default' => '',
'options' => WC()->countries->get_shipping_countries(),
'custom_attributes' => array(

View File

@ -163,7 +163,7 @@ class WC_Shipping_Legacy_Local_Delivery extends WC_Shipping_Local_Pickup {
'title' => __( 'Specific countries', 'woocommerce' ),
'type' => 'multiselect',
'class' => 'wc-enhanced-select',
'css' => 'width: 450px;',
'css' => 'width: 400px;',
'default' => '',
'options' => WC()->countries->get_shipping_countries(),
'custom_attributes' => array(

View File

@ -119,7 +119,7 @@ class WC_Shipping_Legacy_Local_Pickup extends WC_Shipping_Method {
'title' => __( 'Specific countries', 'woocommerce' ),
'type' => 'multiselect',
'class' => 'wc-enhanced-select',
'css' => 'width: 450px;',
'css' => 'width: 400px;',
'default' => '',
'options' => WC()->countries->get_shipping_countries(),
'custom_attributes' => array(