Welcome, visitor! Log in
 

Source View: tag_cloud_sort

To save our bandwidth, we show only a snippet of code around each occurence of the hook. View complete file in SVN  (without highlighting).

Understanding Source Code

The best way to understand what a hook does is to look at where it occurs in the source code.

  • Action hooks look like this: do_action( "hook_name" )
  • Filter hooks look like this: apply_filters( "hook_name", "what_to_filter" ).

Remember, this hook may occur in more than one file. Moreover, the hook's context may change from version to version.

Source View

Line Code
653       );
654  
655       if ( !isset( $args['topic_count_text_callback'] ) && isset( $args['single_text'] ) && isset( $args['multiple_text'] ) ) {
656            $body = 'return sprintf (
657                 _n(' . var_export($args['single_text'], true) . ', ' . var_export($args['multiple_text'], true) . ', $count),
658                 number_format_i18n( $count ));';
659            $args['topic_count_text_callback'] = create_function('$count', $body);
660       }
661  
662       $args = wp_parse_args( $args, $defaults );
663       extract( $args );
664  
665       if ( empty( $tags ) )
666            return;
667  
668       $tags_sorted = apply_filters( 'tag_cloud_sort', $tags, $args );
669       if ( $tags_sorted != $tags  ) { // the tags have been sorted by a plugin
670            $tags = $tags_sorted;
671            unset($tags_sorted);
672       } else {
673            if ( 'RAND' == $order ) {
674                 shuffle($tags);
675            } else {
676                 // SQL cannot save you; this is a second (potentially different) sort on a subset of data.
677                 if ( 'name' == $orderby )
678                      uasort( $tags, create_function('$a, $b', 'return strnatcasecmp($a->name, $b->name);') );
679                 else
680                      uasort( $tags, create_function('$a, $b', 'return ($a->count > $b->count);') );
681  
682                 if ( 'DESC' == $order )
683                      $tags = array_reverse( $tags, true );