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
This commit is contained in:
Andrew Nacin 2014-03-25 12:59:17 +00:00
parent de653fe7ab
commit 87bfc847b1
1 changed files with 13 additions and 7 deletions

View File

@ -712,23 +712,29 @@ 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 );
} else {
if ( 'RAND' == $order ) {
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 );
}
}
}
if ( $number > 0 )
$tags = array_slice($tags, 0, $number);