Use wp_list_sort vs _usort_terms_by_ID

Fixes #12525
This commit is contained in:
Mike Jolley 2016-12-07 10:21:03 +00:00
parent d1f4177c97
commit 7583965af2
1 changed files with 5 additions and 2 deletions

View File

@ -247,8 +247,11 @@ function wc_product_post_type_link( $permalink, $post ) {
$terms = get_the_terms( $post->ID, 'product_cat' ); $terms = get_the_terms( $post->ID, 'product_cat' );
if ( ! empty( $terms ) ) { if ( ! empty( $terms ) ) {
usort( $terms, '_usort_terms_by_ID' ); // order by ID if ( function_exists( 'wp_list_sort' ) ) {
$terms = wp_list_sort( $terms, 'term_id', 'ASC' );
} else {
usort( $terms, '_usort_terms_by_ID' );
}
$category_object = apply_filters( 'wc_product_post_type_link_product_cat', $terms[0], $terms, $post ); $category_object = apply_filters( 'wc_product_post_type_link_product_cat', $terms[0], $terms, $post );
$category_object = get_term( $category_object, 'product_cat' ); $category_object = get_term( $category_object, 'product_cat' );
$product_cat = $category_object->slug; $product_cat = $category_object->slug;