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:
parent
de653fe7ab
commit
87bfc847b1
@ -712,23 +712,29 @@ function wp_generate_tag_cloud( $tags, $args = '' ) {
|
|||||||
* @param array $args An array of tag cloud arguments.
|
* @param array $args An array of tag cloud arguments.
|
||||||
*/
|
*/
|
||||||
$tags_sorted = apply_filters( 'tag_cloud_sort', $tags, $args );
|
$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;
|
$tags = $tags_sorted;
|
||||||
unset($tags_sorted);
|
unset( $tags_sorted );
|
||||||
} else {
|
} else {
|
||||||
if ( 'RAND' == $order ) {
|
if ( 'RAND' === $order ) {
|
||||||
shuffle($tags);
|
shuffle( $tags );
|
||||||
} else {
|
} else {
|
||||||
// SQL cannot save you; this is a second (potentially different) sort on a subset of data.
|
// 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' );
|
uasort( $tags, '_wp_object_name_sort_cb' );
|
||||||
else
|
} else {
|
||||||
uasort( $tags, '_wp_object_count_sort_cb' );
|
uasort( $tags, '_wp_object_count_sort_cb' );
|
||||||
|
}
|
||||||
|
|
||||||
if ( 'DESC' == $order )
|
if ( 'DESC' === $order ) {
|
||||||
$tags = array_reverse( $tags, true );
|
$tags = array_reverse( $tags, true );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ( $number > 0 )
|
if ( $number > 0 )
|
||||||
$tags = array_slice($tags, 0, $number);
|
$tags = array_slice($tags, 0, $number);
|
||||||
|
Loading…
Reference in New Issue
Block a user