Fix term sorting

Closes #12602
This commit is contained in:
Mike Jolley 2016-12-15 14:09:01 +00:00
parent 3c06dab0e8
commit cf0943fda9
2 changed files with 7 additions and 3 deletions

View File

@ -405,7 +405,11 @@ class WC_Admin_Attributes {
$taxonomy = wc_attribute_taxonomy_name( $tax->attribute_name );
if ( taxonomy_exists( $taxonomy ) ) {
$terms = get_terms( $taxonomy, 'hide_empty=0' );
if ( 'menu_order' === wc_attribute_orderby( $taxonomy ) ) {
$terms = get_terms( $taxonomy, 'hide_empty=0&menu_order=ASC' );
} else {
$terms = get_terms( $taxonomy, 'hide_empty=0&menu_order=false' );
}
switch ( $tax->attribute_orderby ) {
case 'name_num' :

View File

@ -143,7 +143,6 @@ function wc_get_product_terms( $product_id, $taxonomy, $args = array() ) {
return apply_filters( 'woocommerce_get_product_terms' , $terms, $product_id, $taxonomy, $args );
}
/**
* Sort by name (numeric).
* @param WP_POST object $a
@ -156,6 +155,7 @@ function _wc_get_product_terms_name_num_usort_callback( $a, $b ) {
}
return ( $a->name + 0 < $b->name + 0 ) ? -1 : 1;
}
/**
* Sort by parent.
* @param WP_POST object $a
@ -464,7 +464,7 @@ function wc_terms_clauses( $clauses, $taxonomies, $args ) {
global $wpdb;
// No sorting when menu_order is false.
if ( isset( $args['menu_order'] ) && false == $args['menu_order'] ) {
if ( isset( $args['menu_order'] ) && ( false === $args['menu_order'] || 'false' === $args['menu_order'] ) ) {
return $clauses;
}