Menu Adam R Brown

WP hooks navigation: Home/browseActions indexFilters index

Source View: list_cats

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.

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

Source View

This hook occurs 5 times in this file.

Line Code
338      $class = esc_attr( $class );
339      $id = $id ? esc_attr( $id ) : $name;
340
341      if ( ! $r['hide_if_empty'] || ! empty($categories) )
342           $output = "<select name='$name' id='$id' class='$class' $tab_index_attribute>\n";
343      else
344           $output = '';
345
346      if ( empty($categories) && ! $r['hide_if_empty'] && !empty($show_option_none) ) {
347           $show_option_none = apply_filters( 'list_cats', $show_option_none );
348           $output .= "\t<option value='-1' selected='selected'>$show_option_none</option>\n";
349      }
350
351      if ( ! empty( $categories ) ) {
352
353           if ( $show_option_all ) {
354                $show_option_all = apply_filters( 'list_cats', $show_option_all );
355                $selected = ( '0' === strval($r['selected']) ) ? " selected='selected'" : '';
356                $output .= "\t<option value='0'$selected>$show_option_all</option>\n";
357           }
358
359           if ( $show_option_none ) {
360                $show_option_none = apply_filters( 'list_cats', $show_option_none );
361                $selected = ( '-1' === strval($r['selected']) ) ? " selected='selected'" : '';
362                $output .= "\t<option value='-1'$selected>$show_option_none</option>\n";
363           }
364
365           if ( $hierarchical )
366                $depth = $r['depth'];  // Walk the full depth.
367           else
368                $depth = -1; // Flat.
369
 
Line Code
825       * @param string $output Passed by reference. Used to append additional content.
826       * @param object $category Category data object.
827       * @param int $depth Depth of category in reference to parents.
828       * @param array $args
829       */
830      function start_el(&$output, $category, $depth, $args) {
831           extract($args);
832
833           $cat_name = esc_attr( $category->name );
834           $cat_name = apply_filters( 'list_cats', $cat_name, $category );
835           $link = '<a href="' . esc_attr( get_term_link($category) ) . '" ';
836           if ( $use_desc_for_title == 0 || empty($category->description) )
837                $link .= 'title="' . esc_attr( sprintf(__( 'View all posts filed under %s' ), $cat_name) ) . '"';
838           else
839                $link .= 'title="' . esc_attr( strip_tags( apply_filters( 'category_description', $category->description, $category ) ) ) . '"';
840           $link .= '>';
841           $link .= $cat_name . '</a>';
842
843           if ( !empty($feed_image) || !empty($feed) ) {
 
Line Code
940       *
941       * @param string $output Passed by reference. Used to append additional content.
942       * @param object $category Category data object.
943       * @param int $depth Depth of category. Used for padding.
944       * @param array $args Uses 'selected', 'show_count', and 'show_last_update' keys, if they exist.
945       */
946      function start_el(&$output, $category, $depth, $args) {
947           $pad = str_repeat('&nbsp;', $depth * 3);
948
949           $cat_name = apply_filters('list_cats', $category->name, $category);
950           $output .= "\t<option class=\"level-$depth\" value=\"".$category->term_id."\"";
951           if ( $category->term_id == $args['selected'] )
952                $output .= ' selected="selected"';
953           $output .= '>';
954           $output .= $pad.$cat_name;
955           if ( $args['show_count'] )
956                $output .= '&nbsp;&nbsp;('. $category->count .')';
957           if ( $args['show_last_update'] ) {
958                $format = 'Y-m-d';