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
402            * 'show_option_none', 'show_option_all', and various forms of the
403            * term name.
404            *
405            * @since 1.2.0
406            *
407            * @see wp_dropdown_categories()
408            *
409            * @param string $element Taxonomy element to list.
410            */
411           $show_option_none = apply_filters( 'list_cats', $r['show_option_none'] );
412           $output .= "\t<option value='" . esc_attr( $option_none_value ) . "' selected='selected'>$show_option_none</option>\n";
413      }
414
415      if ( ! empty( $categories ) ) {
416
417           if ( $r['show_option_all'] ) {
418
419                /** This filter is documented in wp-includes/category-template.php */
420                $show_option_all = apply_filters( 'list_cats', $r['show_option_all'] );
421                $selected = ( '0' === strval($r['selected']) ) ? " selected='selected'" : '';
422                $output .= "\t<option value='0'$selected>$show_option_all</option>\n";
423           }
424
425           if ( $r['show_option_none'] ) {
426
427                /** This filter is documented in wp-includes/category-template.php */
428                $show_option_none = apply_filters( 'list_cats', $r['show_option_none'] );
429                $selected = selected( $option_none_value, $r['selected'], false );
430                $output .= "\t<option value='" . esc_attr( $option_none_value ) . "'$selected>$show_option_none</option>\n";
431           }
432
433           if ( $r['hierarchical'] ) {
434                $depth = $r['depth'];  // Walk the full depth.
435           } else {
436                $depth = -1; // Flat.
437           }
 
Line Code
1033       *
1034       * @param string $output   Passed by reference. Used to append additional content.
1035       * @param object $category Category data object.
1036       * @param int    $depth    Depth of category in reference to parents. Default 0.
1037       * @param array  $args     An array of arguments. @see wp_list_categories()
1038       * @param int    $id       ID of the current category.
1039       */
1040      public function start_el( &$output, $category, $depth = 0, $args = array(), $id = 0 ) {
1041           /** This filter is documented in wp-includes/category-template.php */
1042           $cat_name = apply_filters(
1043                'list_cats',
1044                esc_attr( $category->name ),
1045                $category
1046           );
1047
1048           // Don't generate an element if the category name is empty.
1049           if ( ! $cat_name ) {
1050                return;
1051           }
 
Line Code
1191       * @param object $category Category data object.
1192       * @param int    $depth    Depth of category. Used for padding.
1193       * @param array  $args     Uses 'selected', 'show_count', and 'value_field' keys, if they exist.
1194       *                         See {@see wp_dropdown_categories()}.
1195       */
1196      public function start_el( &$output, $category, $depth = 0, $args = array(), $id = 0 ) {
1197           $pad = str_repeat('&nbsp;', $depth * 3);
1198
1199           /** This filter is documented in wp-includes/category-template.php */
1200           $cat_name = apply_filters( 'list_cats', $category->name, $category );
1201
1202           if ( isset( $args['value_field'] ) && isset( $category->{$args['value_field']} ) ) {
1203                $value_field = $args['value_field'];
1204           } else {
1205                $value_field = 'term_id';
1206           }
1207
1208           $output .= "\t<option class=\"level-$depth\" value=\"" . esc_attr( $category->{$value_field} ) . "\"";
1209