Skip to content

Commit

Permalink
Merge pull request woocommerce#18706 from woocommerce/update/uncatego…
Browse files Browse the repository at this point in the history
…rized

Uncategorized tweaks
  • Loading branch information
claudiulodro committed Jan 31, 2018
2 parents 2936daa + b8df0ea commit c28e2e2
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 9 deletions.
2 changes: 1 addition & 1 deletion assets/css/admin-rtl.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/css/admin.css

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion assets/css/admin.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2440,7 +2440,8 @@ table.wp-list-table {
white-space: nowrap;
}

.column-handle {
.column-handle,
.column-nosort {
width: 17px;
}

Expand Down
19 changes: 13 additions & 6 deletions assets/js/admin/term-ordering.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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;
}

Expand Down
1 change: 1 addition & 0 deletions includes/admin/class-wc-admin-assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,7 @@ public function admin_scripts() {

$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 );
Expand Down
1 change: 1 addition & 0 deletions includes/wc-template-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -1854,6 +1854,7 @@ function woocommerce_get_product_subcategories( $parent_id = 0 ) {
'hierarchical' => 1,
'taxonomy' => 'product_cat',
'pad_counts' => 1,
'exclude' => get_option( 'default_product_cat' ),
) ) );
wp_cache_set( 'product-categories-' . $parent_id, $product_categories, 'product_cat' );
}
Expand Down

0 comments on commit c28e2e2

Please sign in to comment.