Gracefully fail in wp_generate_tag_cloud() when emptiness is returned from the tag_cloud_sort filter.

props SergeyBiryukov.
fixes #27413.

Built from https://develop.svn.wordpress.org/trunk@27709


git-svn-id: http://core.svn.wordpress.org/trunk@27548 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Andrew Nacin 2014-03-25 13:00:15 +00:00
parent bc6f50d09a
commit 134ab31b5d
1 changed files with 13 additions and 7 deletions

View File

@ -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 );
}
}
}