Merge branch 'pr/17098'

This commit is contained in:
Mike Jolley 2017-11-01 12:43:35 +00:00
commit ef4c05a393
4 changed files with 29 additions and 6 deletions

View File

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

View File

@ -1 +1 @@
jQuery(function(e){e("#the-list").on("click",".editinline",function(){inlineEditPost.revert();var t=e(this).closest("tr").attr("id");t=t.replace("post-","");var i=e("#woocommerce_inline_"+t),n=i.find(".sku").text(),o=i.find(".regular_price").text(),l=i.find(".sale_price ").text(),d=i.find(".weight").text(),s=i.find(".length").text(),c=i.find(".width").text(),a=i.find(".height").text(),r=i.find(".shipping_class").text(),_=i.find(".visibility").text(),m=i.find(".stock_status").text(),p=i.find(".stock").text(),u=i.find(".featured").text(),w=i.find(".manage_stock").text(),h=i.find(".menu_order").text(),f=i.find(".tax_status").text(),v=i.find(".tax_class").text(),k=i.find(".backorders").text(),x=o.replace(".",woocommerce_admin.mon_decimal_point),g=l.replace(".",woocommerce_admin.mon_decimal_point);e('input[name="_sku"]',".inline-edit-row").val(n),e('input[name="_regular_price"]',".inline-edit-row").val(x),e('input[name="_sale_price"]',".inline-edit-row").val(g),e('input[name="_weight"]',".inline-edit-row").val(d),e('input[name="_length"]',".inline-edit-row").val(s),e('input[name="_width"]',".inline-edit-row").val(c),e('input[name="_height"]',".inline-edit-row").val(a),e('select[name="_shipping_class"] option:selected',".inline-edit-row").attr("selected",!1).change(),e('select[name="_shipping_class"] option[value="'+r+'"]').attr("selected","selected").change(),e('input[name="_stock"]',".inline-edit-row").val(p),e('input[name="menu_order"]',".inline-edit-row").val(h),e('select[name="_tax_status"] option, select[name="_tax_class"] option, select[name="_visibility"] option, select[name="_stock_status"] option, select[name="_backorders"] option').removeAttr("selected"),e('select[name="_tax_status"] option[value="'+f+'"]',".inline-edit-row").attr("selected","selected"),e('select[name="_tax_class"] option[value="'+v+'"]',".inline-edit-row").attr("selected","selected"),e('select[name="_visibility"] option[value="'+_+'"]',".inline-edit-row").attr("selected","selected"),e('select[name="_stock_status"] option[value="'+m+'"]',".inline-edit-row").attr("selected","selected"),e('select[name="_backorders"] option[value="'+k+'"]',".inline-edit-row").attr("selected","selected"),"yes"===u?e('input[name="_featured"]',".inline-edit-row").attr("checked","checked"):e('input[name="_featured"]',".inline-edit-row").removeAttr("checked"),"yes"===w?(e(".stock_qty_field",".inline-edit-row").show().removeAttr("style"),e('input[name="_manage_stock"]',".inline-edit-row").attr("checked","checked")):(e(".stock_qty_field",".inline-edit-row").hide(),e('input[name="_manage_stock"]',".inline-edit-row").removeAttr("checked"));var y=i.find(".product_type").text(),b=i.find(".product_is_virtual").text();"simple"===y||"external"===y?e(".price_fields",".inline-edit-row").show().removeAttr("style"):e(".price_fields",".inline-edit-row").hide(),"yes"===b?e(".dimension_fields",".inline-edit-row").hide():e(".dimension_fields",".inline-edit-row").show().removeAttr("style"),"grouped"===y?e(".stock_fields",".inline-edit-row").hide():e(".stock_fields",".inline-edit-row").show().removeAttr("style"),e('input[name="comment_status"]').parent().find(".checkbox-title").text(woocommerce_quick_edit.strings.allow_reviews)}),e("#the-list").on("change",'.inline-edit-row input[name="_manage_stock"]',function(){e(this).is(":checked")?e(".stock_qty_field",".inline-edit-row").show().removeAttr("style"):e(".stock_qty_field",".inline-edit-row").hide()}),e("#wpbody").on("click","#doaction, #doaction2",function(){e("input.text",".inline-edit-row").val(""),e("#woocommerce-fields").find("select").prop("selectedIndex",0),e("#woocommerce-fields-bulk").find(".inline-edit-group .change-input").hide()}),e("#wpbody").on("change","#woocommerce-fields-bulk .inline-edit-group .change_to",function(){0<e(this).val()?e(this).closest("div").find(".change-input").show():e(this).closest("div").find(".change-input").hide()})});
jQuery(function(e){e("#the-list").on("click",".editinline",function(){inlineEditPost.revert();var t=e(this).closest("tr").attr("id");t=t.replace("post-","");var i=e("#woocommerce_inline_"+t),n=i.find(".sku").text(),o=i.find(".regular_price").text(),l=i.find(".sale_price ").text(),d=i.find(".weight").text(),s=i.find(".length").text(),c=i.find(".width").text(),a=i.find(".height").text(),r=i.find(".shipping_class").text(),_=i.find(".visibility").text(),m=i.find(".stock_status").text(),p=i.find(".stock").text(),u=i.find(".featured").text(),w=i.find(".manage_stock").text(),h=i.find(".menu_order").text(),f=i.find(".tax_status").text(),v=i.find(".tax_class").text(),k=i.find(".backorders").text(),x=o.replace(".",woocommerce_admin.mon_decimal_point),g=l.replace(".",woocommerce_admin.mon_decimal_point);e('input[name="_sku"]',".inline-edit-row").val(n),e('input[name="_regular_price"]',".inline-edit-row").val(x),e('input[name="_sale_price"]',".inline-edit-row").val(g),e('input[name="_weight"]',".inline-edit-row").val(d),e('input[name="_length"]',".inline-edit-row").val(s),e('input[name="_width"]',".inline-edit-row").val(c),e('input[name="_height"]',".inline-edit-row").val(a),e('select[name="_shipping_class"] option:selected',".inline-edit-row").attr("selected",!1).change(),e('select[name="_shipping_class"] option[value="'+r+'"]').attr("selected","selected").change(),e('input[name="_stock"]',".inline-edit-row").val(p),e('input[name="menu_order"]',".inline-edit-row").val(h),e('select[name="_tax_status"] option, select[name="_tax_class"] option, select[name="_visibility"] option, select[name="_stock_status"] option, select[name="_backorders"] option').removeAttr("selected"),e('select[name="_tax_status"] option[value="'+f+'"]',".inline-edit-row").attr("selected","selected"),e('select[name="_tax_class"] option[value="'+v+'"]',".inline-edit-row").attr("selected","selected"),e('select[name="_visibility"] option[value="'+_+'"]',".inline-edit-row").attr("selected","selected"),e('select[name="_stock_status"] option[value="'+m+'"]',".inline-edit-row").attr("selected","selected"),e('select[name="_backorders"] option[value="'+k+'"]',".inline-edit-row").attr("selected","selected"),"yes"===u?e('input[name="_featured"]',".inline-edit-row").attr("checked","checked"):e('input[name="_featured"]',".inline-edit-row").removeAttr("checked"),"yes"===w?(e(".stock_qty_field",".inline-edit-row").show().removeAttr("style"),e('input[name="_manage_stock"]',".inline-edit-row").attr("checked","checked")):(e(".stock_qty_field",".inline-edit-row").hide(),e('input[name="_manage_stock"]',".inline-edit-row").removeAttr("checked"));var y=i.find(".product_type").text(),b=i.find(".product_is_virtual").text();"simple"===y||"external"===y?e(".price_fields",".inline-edit-row").show().removeAttr("style"):e(".price_fields",".inline-edit-row").hide(),"yes"===b?e(".dimension_fields",".inline-edit-row").hide():e(".dimension_fields",".inline-edit-row").show().removeAttr("style"),"grouped"===y?e(".stock_fields",".inline-edit-row").hide():e(".stock_fields",".inline-edit-row").show().removeAttr("style"),e('input[name="comment_status"]').parent().find(".checkbox-title").text(woocommerce_quick_edit.strings.allow_reviews)}),e("#the-list").on("change",'.inline-edit-row input[name="_manage_stock"]',function(){e(this).is(":checked")?e(".stock_qty_field",".inline-edit-row").show().removeAttr("style"):e(".stock_qty_field",".inline-edit-row").hide()}),e("#wpbody").on("click","#doaction, #doaction2",function(){e("input.text",".inline-edit-row").val(""),e("#woocommerce-fields").find("select").prop("selectedIndex",0),e("#woocommerce-fields-bulk").find(".inline-edit-group .change-input").hide()}),e("#wpbody").on("change","#woocommerce-fields-bulk .inline-edit-group .change_to",function(){0<e(this).val()?e(this).closest("div").find(".change-input").show():e(this).closest("div").find(".change-input").hide()}),e("#wpbody").on("click",".trash-product",function(){return window.confirm(woocommerce_admin.i18_delete_product_notice)})});

View File

@ -154,6 +154,7 @@ class WC_Admin_Assets {
'i18n_mon_decimal_error' => sprintf( __( 'Please enter in monetary decimal (%s) format without thousand separators and currency symbols.', 'woocommerce' ), wc_get_price_decimal_separator() ),
'i18n_country_iso_error' => __( 'Please enter in country code with two capital letters.', 'woocommerce' ),
'i18_sale_less_than_regular_error' => __( 'Please enter in a value less than the regular price.', 'woocommerce' ),
'i18_delete_product_notice' => __( 'This product has produced sales and may be linked to existing orders. Are you sure you want to delete it?', 'woocommerce' ),
'decimal_point' => $decimal,
'mon_decimal_point' => wc_get_price_decimal_separator(),
'strings' => array(

View File

@ -12,7 +12,9 @@ if ( ! defined( 'ABSPATH' ) ) {
* @version 3.0.0
*/
if ( ! class_exists( 'WC_Admin_Duplicate_Product', false ) ) :
if ( class_exists( 'WC_Admin_Duplicate_Product', false ) ) {
return new WC_Admin_Duplicate_Product();
}
/**
* WC_Admin_Duplicate_Product Class.
@ -30,11 +32,14 @@ class WC_Admin_Duplicate_Product {
/**
* Show the "Duplicate" link in admin products list.
* @param array $actions
* @param WP_Post $post Post object
*
* @param array $actions Array of actions.
* @param WP_Post $post Post object.
* @return array
*/
public function dupe_link( $actions, $post ) {
global $the_product;
if ( ! current_user_can( apply_filters( 'woocommerce_duplicate_product_capability', 'manage_woocommerce' ) ) ) {
return $actions;
}
@ -43,6 +48,21 @@ class WC_Admin_Duplicate_Product {
return $actions;
}
// Add Class to Delete Permanently link in row actions.
if ( empty( $the_product ) || $the_product->get_id() !== $post->ID ) {
$the_product = wc_get_product( $post );
}
if ( 'publish' === $post->post_status && $the_product && 0 < $the_product->get_total_sales() ) {
$actions['trash'] = sprintf(
'<a href="%s" class="submitdelete trash-product" aria-label="%s">%s</a>',
get_delete_post_link( $the_product->get_id(), '', false ),
/* translators: %s: post title */
esc_attr( sprintf( __( 'Move &#8220;%s&#8221; to the Trash', 'woocommerce' ), $the_product->get_name() ) ),
__( 'Trash', 'woocommerce' )
);
}
$actions['duplicate'] = '<a href="' . wp_nonce_url( admin_url( 'edit.php?post_type=product&action=duplicate_product&amp;post=' . $post->ID ), 'woocommerce-duplicate-product_' . $post->ID ) . '" aria-label="' . esc_attr__( 'Make a duplicate from this product', 'woocommerce' )
. '" rel="permalink">' . __( 'Duplicate', 'woocommerce' ) . '</a>';
@ -196,6 +216,4 @@ class WC_Admin_Duplicate_Product {
}
}
endif;
return new WC_Admin_Duplicate_Product();