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;
|
||||
}
|
||||
|
||||
.column-handle,
|
||||
.column-nosort {
|
||||
.column-handle {
|
||||
width: 17px;
|
||||
display: none;
|
||||
}
|
||||
|
||||
tbody {
|
||||
|
|
|
@ -4,15 +4,9 @@
|
|||
jQuery( function( $ ) {
|
||||
|
||||
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() {
|
||||
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 ).find( '.column-handle' ).show();
|
||||
|
||||
$( table_selector ).sortable({
|
||||
items: item_selector,
|
||||
|
@ -36,11 +30,11 @@ jQuery( function( $ ) {
|
|||
ui.item.children( 'td, th' ).css( 'border-bottom-width', '1px' );
|
||||
},
|
||||
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 prevtermid = ui.item.prev().find( '.check-column input' ).val();
|
||||
var nexttermid = ui.item.next().find( '.check-column input' ).val();
|
||||
var prevtermid = ui.item.prev().find( '.column-handle input[name="term_id"]' ).val();
|
||||
var nexttermid = ui.item.next().find( '.column-handle input[name="term_id"]' ).val();
|
||||
|
||||
// Can only sort in same tree
|
||||
var prevtermparent, nexttermparent;
|
||||
|
@ -65,14 +59,16 @@ jQuery( function( $ ) {
|
|||
}
|
||||
|
||||
// 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
|
||||
$.post( ajaxurl, { action: 'woocommerce_term_ordering', id: termid, nextid: nexttermid, thetaxonomy: woocommerce_term_ordering_params.taxonomy }, function(response){
|
||||
if ( response === 'children' ) {
|
||||
window.location.reload();
|
||||
} 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(
|
||||
'taxonomy' => $taxonomy,
|
||||
'default' => absint( get_option( 'default_product_cat' ) ),
|
||||
);
|
||||
|
||||
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' );
|
||||
|
||||
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
|
||||
*/
|
||||
public function product_cat_column( $columns, $column, $id ) {
|
||||
|
||||
if ( 'thumb' == $column ) {
|
||||
|
||||
if ( 'thumb' === $column ) {
|
||||
$thumbnail_id = get_woocommerce_term_meta( $id, 'thumbnail_id', true );
|
||||
|
||||
if ( $thumbnail_id ) {
|
||||
|
@ -342,14 +343,13 @@ class WC_Admin_Taxonomies {
|
|||
$image = wc_placeholder_img_src();
|
||||
}
|
||||
|
||||
// Prevent esc_url from breaking spaces in urls for image embeds
|
||||
// Ref: https://core.trac.wordpress.org/ticket/23605
|
||||
// Prevent esc_url from breaking spaces in urls for image embeds. Ref: https://core.trac.wordpress.org/ticket/23605
|
||||
$image = str_replace( ' ', '%20', $image );
|
||||
|
||||
$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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue