From 7583965af2fb68ff60a8c7499e37f20b6c827e4c Mon Sep 17 00:00:00 2001 From: Mike Jolley Date: Wed, 7 Dec 2016 10:21:03 +0000 Subject: [PATCH] Use wp_list_sort vs _usort_terms_by_ID Fixes #12525 --- includes/wc-product-functions.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/includes/wc-product-functions.php b/includes/wc-product-functions.php index 5d4479cd0e3..a8ca9dc27c2 100644 --- a/includes/wc-product-functions.php +++ b/includes/wc-product-functions.php @@ -247,8 +247,11 @@ function wc_product_post_type_link( $permalink, $post ) { $terms = get_the_terms( $post->ID, 'product_cat' ); 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 = get_term( $category_object, 'product_cat' ); $product_cat = $category_object->slug;