Merge pull request #18723 from woocommerce/update/uncategorized-improvements
Further uncategorized improvements
This commit is contained in:
commit
b78aeb2343
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -2443,9 +2443,9 @@ table.wp-list-table {
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
.column-handle,
|
.column-handle {
|
||||||
.column-nosort {
|
|
||||||
width: 17px;
|
width: 17px;
|
||||||
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
tbody {
|
tbody {
|
||||||
|
|
|
@ -4,15 +4,9 @@
|
||||||
jQuery( function( $ ) {
|
jQuery( function( $ ) {
|
||||||
|
|
||||||
var table_selector = 'table.wp-list-table',
|
var table_selector = 'table.wp-list-table',
|
||||||
item_selector = 'tbody tr:not(.inline-edit-row, ' + '#tag-' + woocommerce_term_ordering_params.default + ')';
|
item_selector = 'tbody tr:not(.inline-edit-row)';
|
||||||
|
|
||||||
$( 'table.wp-list-table tr:not(.inline-edit-row)' ).each( function() {
|
$( table_selector ).find( '.column-handle' ).show();
|
||||||
if ( 'tag-' + woocommerce_term_ordering_params.default === $( this ).prop( 'id' ) ) {
|
|
||||||
$( this ).append( '<td class="column-nosort"></td>' );
|
|
||||||
} else {
|
|
||||||
$( this ).append( '<td class="column-handle"></td>' );
|
|
||||||
}
|
|
||||||
} );
|
|
||||||
|
|
||||||
$( table_selector ).sortable({
|
$( table_selector ).sortable({
|
||||||
items: item_selector,
|
items: item_selector,
|
||||||
|
@ -36,11 +30,11 @@ jQuery( function( $ ) {
|
||||||
ui.item.children( 'td, th' ).css( 'border-bottom-width', '1px' );
|
ui.item.children( 'td, th' ).css( 'border-bottom-width', '1px' );
|
||||||
},
|
},
|
||||||
update: function( event, ui ) {
|
update: function( event, ui ) {
|
||||||
var termid = ui.item.find( '.check-column input' ).val(); // this post id
|
var termid = ui.item.find( '.column-handle input[name="term_id"]' ).val(); // this post id
|
||||||
var termparent = ui.item.find( '.parent' ).html(); // post parent
|
var termparent = ui.item.find( '.parent' ).html(); // post parent
|
||||||
|
|
||||||
var prevtermid = ui.item.prev().find( '.check-column input' ).val();
|
var prevtermid = ui.item.prev().find( '.column-handle input[name="term_id"]' ).val();
|
||||||
var nexttermid = ui.item.next().find( '.check-column input' ).val();
|
var nexttermid = ui.item.next().find( '.column-handle input[name="term_id"]' ).val();
|
||||||
|
|
||||||
// Can only sort in same tree
|
// Can only sort in same tree
|
||||||
var prevtermparent, nexttermparent;
|
var prevtermparent, nexttermparent;
|
||||||
|
@ -65,14 +59,16 @@ jQuery( function( $ ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Show Spinner
|
// Show Spinner
|
||||||
ui.item.find( '.check-column input' ).hide().after( '<img alt="processing" src="images/wpspin_light.gif" class="waiting" style="margin-left: 6px;" />' );
|
ui.item.find( '.check-column input' ).hide();
|
||||||
|
ui.item.find( '.check-column' ).append( '<img alt="processing" src="images/wpspin_light.gif" class="waiting" style="margin-left: 6px;" />' );
|
||||||
|
|
||||||
// Go do the sorting stuff via ajax
|
// Go do the sorting stuff via ajax
|
||||||
$.post( ajaxurl, { action: 'woocommerce_term_ordering', id: termid, nextid: nexttermid, thetaxonomy: woocommerce_term_ordering_params.taxonomy }, function(response){
|
$.post( ajaxurl, { action: 'woocommerce_term_ordering', id: termid, nextid: nexttermid, thetaxonomy: woocommerce_term_ordering_params.taxonomy }, function(response){
|
||||||
if ( response === 'children' ) {
|
if ( response === 'children' ) {
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
} else {
|
} else {
|
||||||
ui.item.find( '.check-column input' ).show().siblings( 'img' ).remove();
|
ui.item.find( '.check-column input' ).show();
|
||||||
|
ui.item.find( '.check-column' ).find( 'img' ).remove();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -328,7 +328,6 @@ class WC_Admin_Assets {
|
||||||
|
|
||||||
$woocommerce_term_order_params = array(
|
$woocommerce_term_order_params = array(
|
||||||
'taxonomy' => $taxonomy,
|
'taxonomy' => $taxonomy,
|
||||||
'default' => absint( get_option( 'default_product_cat' ) ),
|
|
||||||
);
|
);
|
||||||
|
|
||||||
wp_localize_script( 'woocommerce_term_ordering', 'woocommerce_term_ordering_params', $woocommerce_term_order_params );
|
wp_localize_script( 'woocommerce_term_ordering', 'woocommerce_term_ordering_params', $woocommerce_term_order_params );
|
||||||
|
|
|
@ -318,7 +318,10 @@ class WC_Admin_Taxonomies {
|
||||||
|
|
||||||
$new_columns['thumb'] = __( 'Image', 'woocommerce' );
|
$new_columns['thumb'] = __( 'Image', 'woocommerce' );
|
||||||
|
|
||||||
return array_merge( $new_columns, $columns );
|
$columns = array_merge( $new_columns, $columns );
|
||||||
|
$columns['handle'] = '';
|
||||||
|
|
||||||
|
return $columns;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -331,9 +334,7 @@ class WC_Admin_Taxonomies {
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function product_cat_column( $columns, $column, $id ) {
|
public function product_cat_column( $columns, $column, $id ) {
|
||||||
|
if ( 'thumb' === $column ) {
|
||||||
if ( 'thumb' == $column ) {
|
|
||||||
|
|
||||||
$thumbnail_id = get_woocommerce_term_meta( $id, 'thumbnail_id', true );
|
$thumbnail_id = get_woocommerce_term_meta( $id, 'thumbnail_id', true );
|
||||||
|
|
||||||
if ( $thumbnail_id ) {
|
if ( $thumbnail_id ) {
|
||||||
|
@ -342,14 +343,13 @@ class WC_Admin_Taxonomies {
|
||||||
$image = wc_placeholder_img_src();
|
$image = wc_placeholder_img_src();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prevent esc_url from breaking spaces in urls for image embeds
|
// Prevent esc_url from breaking spaces in urls for image embeds. Ref: https://core.trac.wordpress.org/ticket/23605
|
||||||
// Ref: https://core.trac.wordpress.org/ticket/23605
|
|
||||||
$image = str_replace( ' ', '%20', $image );
|
$image = str_replace( ' ', '%20', $image );
|
||||||
|
|
||||||
$columns .= '<img src="' . esc_url( $image ) . '" alt="' . esc_attr__( 'Thumbnail', 'woocommerce' ) . '" class="wp-post-image" height="48" width="48" />';
|
$columns .= '<img src="' . esc_url( $image ) . '" alt="' . esc_attr__( 'Thumbnail', 'woocommerce' ) . '" class="wp-post-image" height="48" width="48" />';
|
||||||
|
|
||||||
}
|
}
|
||||||
|
if ( 'handle' === $column ) {
|
||||||
|
$columns .= '<input type="hidden" name="term_id" value="' . esc_attr( $id ) . '" />';
|
||||||
|
}
|
||||||
return $columns;
|
return $columns;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue