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
335      $class = esc_attr( $class );
336      $id = $id ? esc_attr( $id ) : $name;
337
338      if ( ! $r['hide_if_empty'] || ! empty($categories) )
339           $output = "<select name='$name' id='$id' class='$class' $tab_index_attribute>\n";
340      else
341           $output = '';
342
343      if ( empty($categories) && ! $r['hide_if_empty'] && !empty($show_option_none) ) {
344           $show_option_none = apply_filters( 'list_cats', $show_option_none );
345           $output .= "\t<option value='-1' selected='selected'>$show_option_none</option>\n";
346      }
347
348      if ( ! empty( $categories ) ) {
349
350           if ( $show_option_all ) {
351                $show_option_all = apply_filters( 'list_cats', $show_option_all );
352                $selected = ( '0' === strval($r['selected']) ) ? " selected='selected'" : '';
353                $output .= "\t<option value='0'$selected>$show_option_all</option>\n";
354           }
355
356           if ( $show_option_none ) {
357                $show_option_none = apply_filters( 'list_cats', $show_option_none );
358                $selected = ( '-1' === strval($r['selected']) ) ? " selected='selected'" : '';
359                $output .= "\t<option value='-1'$selected>$show_option_none</option>\n";
360           }
361
362           if ( $hierarchical )
363                $depth = $r['depth'];  // Walk the full depth.
364           else
365                $depth = -1; // Flat.
366
 
Line Code
818       * @param string $output Passed by reference. Used to append additional content.
819       * @param object $category Category data object.
820       * @param int $depth Depth of category in reference to parents.
821       * @param array $args
822       */
823      function start_el( &$output, $category, $depth = 0, $args = array(), $id = 0 ) {
824           extract($args);
825
826           $cat_name = esc_attr( $category->name );
827           $cat_name = apply_filters( 'list_cats', $cat_name, $category );
828           $link = '<a href="' . esc_url( get_term_link($category) ) . '" ';
829           if ( $use_desc_for_title == 0 || empty($category->description) )
830                $link .= 'title="' . esc_attr( sprintf(__( 'View all posts filed under %s' ), $cat_name) ) . '"';
831           else
832                $link .= 'title="' . esc_attr( strip_tags( apply_filters( 'category_description', $category->description, $category ) ) ) . '"';
833           $link .= '>';
834           $link .= $cat_name . '</a>';
835
836           if ( !empty($feed_image) || !empty($feed) ) {
 
Line Code
930       *
931       * @param string $output Passed by reference. Used to append additional content.
932       * @param object $category Category data object.
933       * @param int $depth Depth of category. Used for padding.
934       * @param array $args Uses 'selected' and 'show_count' keys, if they exist.
935       */
936      function start_el( &$output, $category, $depth, $args, $id = 0 ) {
937           $pad = str_repeat('&nbsp;', $depth * 3);
938
939           $cat_name = apply_filters('list_cats', $category->name, $category);
940           $output .= "\t<option class=\"level-$depth\" value=\"".$category->term_id."\"";
941           if ( $category->term_id == $args['selected'] )
942                $output .= ' selected="selected"';
943           $output .= '>';
944           $output .= $pad.$cat_name;
945           if ( $args['show_count'] )
946                $output .= '&nbsp;&nbsp;('. $category->count .')';
947           $output .= "</option>\n";
948      }