From 87bfc847b1ef92ae8947bac47dd2428b4d3c3907 Mon Sep 17 00:00:00 2001 From: Andrew Nacin Date: Tue, 25 Mar 2014 12:59:17 +0000 Subject: [PATCH] Gracefully fail in wp_generate_tag_cloud() when emptiness is returned from the tag_cloud_sort filter. props SergeyBiryukov. fixes #27413. git-svn-id: https://develop.svn.wordpress.org/trunk@27709 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/category-template.php | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/wp-includes/category-template.php b/src/wp-includes/category-template.php index 4c78ab86bd..17f78bfc1b 100644 --- a/src/wp-includes/category-template.php +++ b/src/wp-includes/category-template.php @@ -712,21 +712,27 @@ function wp_generate_tag_cloud( $tags, $args = '' ) { * @param array $args An array of tag cloud arguments. */ $tags_sorted = apply_filters( 'tag_cloud_sort', $tags, $args ); - if ( $tags_sorted != $tags ) { + if ( empty( $tags_sorted ) ) { + return $return; + } + + if ( $tags_sorted !== $tags ) { $tags = $tags_sorted; - unset($tags_sorted); + unset( $tags_sorted ); } else { - if ( 'RAND' == $order ) { - shuffle($tags); + if ( 'RAND' === $order ) { + shuffle( $tags ); } else { // SQL cannot save you; this is a second (potentially different) sort on a subset of data. - if ( 'name' == $orderby ) + if ( 'name' === $orderby ) { uasort( $tags, '_wp_object_name_sort_cb' ); - else + } else { uasort( $tags, '_wp_object_count_sort_cb' ); + } - if ( 'DESC' == $order ) + if ( 'DESC' === $order ) { $tags = array_reverse( $tags, true ); + } } }