Make WordPress Core

Changeset 27709


Ignore:
Timestamp:
03/25/2014 12:59:17 PM (11 years ago)
Author:
nacin
Message:

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

props SergeyBiryukov.
fixes #27413.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/category-template.php

    r27708 r27709  
    713713     */
    714714    $tags_sorted = apply_filters( 'tag_cloud_sort', $tags, $args );
    715     if ( $tags_sorted != $tags  ) {
     715    if ( empty( $tags_sorted ) ) {
     716        return $return;
     717    }
     718
     719    if ( $tags_sorted !== $tags ) {
    716720        $tags = $tags_sorted;
    717         unset($tags_sorted);
     721        unset( $tags_sorted );
    718722    } else {
    719         if ( 'RAND' == $order ) {
    720             shuffle($tags);
     723        if ( 'RAND' === $order ) {
     724            shuffle( $tags );
    721725        } else {
    722726            // SQL cannot save you; this is a second (potentially different) sort on a subset of data.
    723             if ( 'name' == $orderby )
     727            if ( 'name' === $orderby ) {
    724728                uasort( $tags, '_wp_object_name_sort_cb' );
    725             else
     729            } else {
    726730                uasort( $tags, '_wp_object_count_sort_cb' );
    727 
    728             if ( 'DESC' == $order )
     731            }
     732
     733            if ( 'DESC' === $order ) {
    729734                $tags = array_reverse( $tags, true );
     735            }
    730736        }
    731737    }
Note: See TracChangeset for help on using the changeset viewer.