Changeset 11744 for trunk/wp-includes/category-template.php
- Timestamp:
- 07/26/2009 01:23:46 AM (17 years ago)
- File:
-
- 1 edited
-
trunk/wp-includes/category-template.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/category-template.php
r11450 r11744 574 574 * the 'format' argument will return in PHP array type format. 575 575 * 576 * The 'tag_cloud_sort' filter allows you to override the sorting done 577 * by the 'orderby' argument; passed to the filter: $tags array and $args array. 576 * The 'tag_cloud_sort' filter allows you to override the sorting. 577 * Passed to the filter: $tags array and $args array, has to return the $tags array 578 * after sorting it. 578 579 * 579 580 * The 'orderby' argument will accept 'name' or 'count' and defaults to 'name'. … … 605 606 if ( !isset( $args['topic_count_text_callback'] ) && isset( $args['single_text'] ) && isset( $args['multiple_text'] ) ) { 606 607 $body = 'return sprintf ( 607 _n(' .var_export($args['single_text'], true).', '.var_export($args['multiple_text'], true).', $count),608 _n(' . var_export($args['single_text'], true) . ', ' . var_export($args['multiple_text'], true) . ', $count), 608 609 number_format_i18n( $count ));'; 609 610 $args['topic_count_text_callback'] = create_function('$count', $body); … … 611 612 612 613 $args = wp_parse_args( $args, $defaults ); 613 614 614 extract( $args ); 615 615 … … 617 617 return; 618 618 619 // SQL cannot save you; this is a second (potentially different) sort on a subset of data. 620 if ( 'name' == $orderby ) 621 uasort( $tags, create_function('$a, $b', 'return strnatcasecmp($a->name, $b->name);') ); 622 else 623 uasort( $tags, create_function('$a, $b', 'return ($a->count > $b->count);') ); 624 625 $tags = apply_filters( 'tag_cloud_sort', $tags, $args ); 626 627 if ( 'DESC' == $order ) 628 $tags = array_reverse( $tags, true ); 629 elseif ( 'RAND' == $order ) { 630 $keys = (array) array_rand( $tags, count( $tags ) ); 631 $temp = array(); 632 foreach ( $keys as $key ) 633 $temp[$key] = $tags[$key]; 634 635 $tags = $temp; 636 $temp = null; 637 unset( $temp ); 619 $tags_sorted = apply_filters( 'tag_cloud_sort', $tags, $args ); 620 if ( $tags_sorted != $tags ) { // the tags have been sorted by a plugin 621 $tags = $tags_sorted; 622 unset($tags_sorted); 623 } else { 624 if ( 'RAND' == $order ) { 625 shuffle($tags); 626 } else { 627 // SQL cannot save you; this is a second (potentially different) sort on a subset of data. 628 if ( 'name' == $orderby ) 629 uasort( $tags, create_function('$a, $b', 'return strnatcasecmp($a->name, $b->name);') ); 630 else 631 uasort( $tags, create_function('$a, $b', 'return ($a->count > $b->count);') ); 632 633 if ( 'DESC' == $order ) 634 $tags = array_reverse( $tags, true ); 635 } 638 636 } 639 637
Note: See TracChangeset
for help on using the changeset viewer.