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
376            * 'show_option_none', 'show_option_all', and various forms of the
377            * term name.
378            *
379            * @since 1.2.0
380            *
381            * @see wp_dropdown_categories()
382            *
383            * @param string $element Taxonomy element to list.
384            */
385           $show_option_none = apply_filters( 'list_cats', $r['show_option_none'] );
386           $output .= "\t<option value='" . esc_attr( $option_none_value ) . "' selected='selected'>$show_option_none</option>\n";
387      }
388
389      if ( ! empty( $categories ) ) {
390
391           if ( $r['show_option_all'] ) {
392
393                /** This filter is documented in wp-includes/category-template.php */
394                $show_option_all = apply_filters( 'list_cats', $r['show_option_all'] );
395                $selected = ( '0' === strval($r['selected']) ) ? " selected='selected'" : '';
396                $output .= "\t<option value='0'$selected>$show_option_all</option>\n";
397           }
398
399           if ( $r['show_option_none'] ) {
400
401                /** This filter is documented in wp-includes/category-template.php */
402                $show_option_none = apply_filters( 'list_cats', $r['show_option_none'] );
403                $selected = selected( $option_none_value, $r['selected'], false );
404                $output .= "\t<option value='" . esc_attr( $option_none_value ) . "'$selected>$show_option_none</option>\n";
405           }
406
407           if ( $r['hierarchical'] ) {
408                $depth = $r['depth'];  // Walk the full depth.
409           } else {
410                $depth = -1; // Flat.
411           }
 
Line Code
959       *
960       * @param string $output   Passed by reference. Used to append additional content.
961       * @param object $category Category data object.
962       * @param int    $depth    Depth of category in reference to parents. Default 0.
963       * @param array  $args     An array of arguments. @see wp_list_categories()
964       * @param int    $id       ID of the current category.
965       */
966      public function start_el( &$output, $category, $depth = 0, $args = array(), $id = 0 ) {
967           /** This filter is documented in wp-includes/category-template.php */
968           $cat_name = apply_filters(
969                'list_cats',
970                esc_attr( $category->name ),
971                $category
972           );
973
974           $link = '<a href="' . esc_url( get_term_link( $category ) ) . '" ';
975           if ( $args['use_desc_for_title'] && ! empty( $category->description ) ) {
976                /**
977                 * Filter the category description for display.
 
Line Code
1092       * @param string $output   Passed by reference. Used to append additional content.
1093       * @param object $category Category data object.
1094       * @param int    $depth    Depth of category. Used for padding.
1095       * @param array  $args     Uses 'selected' and 'show_count' keys, if they exist. @see wp_dropdown_categories()
1096       */
1097      public function start_el( &$output, $category, $depth = 0, $args = array(), $id = 0 ) {
1098           $pad = str_repeat('&nbsp;', $depth * 3);
1099
1100           /** This filter is documented in wp-includes/category-template.php */
1101           $cat_name = apply_filters( 'list_cats', $category->name, $category );
1102
1103           $output .= "\t<option class=\"level-$depth\" value=\"".$category->term_id."\"";
1104           if ( $category->term_id == $args['selected'] )
1105                $output .= ' selected="selected"';
1106           $output .= '>';
1107           $output .= $pad.$cat_name;
1108           if ( $args['show_count'] )
1109                $output .= '&nbsp;&nbsp;('. number_format_i18n( $category->count ) .')';
1110           $output .= "</option>\n";