Prevent uncategorized from being sorted. it's always top of the list.

This commit is contained in:
Mike Jolley 2018-01-31 13:34:55 +00:00
parent bbae2cd5ba
commit 6f6ddf2eeb
5 changed files with 18 additions and 9 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -2440,7 +2440,8 @@ table.wp-list-table {
white-space: nowrap;
}
.column-handle {
.column-handle,
.column-nosort {
width: 17px;
}

View File

@ -3,12 +3,19 @@
/* Modifided script from the simple-page-ordering plugin */
jQuery( function( $ ) {
$( 'table.widefat.wp-list-table tr' ).append(
'<td class="column-handle"></td>'
);
var table_selector = 'table.wp-list-table',
item_selector = 'tbody tr:not(.inline-edit-row, ' + '#tag-' + woocommerce_term_ordering_params.default + ')';
$( 'table.widefat.wp-list-table' ).sortable({
items: '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 ).sortable({
items: item_selector,
cursor: 'move',
handle: '.column-handle',
axis: 'y',
@ -53,7 +60,7 @@ jQuery( function( $ ) {
// If previous and next not at same tree level, or next not at same tree level and the previous is the parent of the next, or just moved item beneath its own children
if ( ( prevtermid === undefined && nexttermid === undefined ) || ( nexttermid === undefined && nexttermparent === prevtermid ) || ( nexttermid !== undefined && prevtermparent === termid ) ) {
$( 'table.widefat.wp-list-table' ).sortable( 'cancel' );
$( table_selector ).sortable( 'cancel' );
return;
}

View File

@ -328,6 +328,7 @@ 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 );