Menu Adam R Brown

WP hooks navigation: Home/browseActions indexFilters index

Source View: the_category

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 3 times in this file.

Line Code
463      function end_lvl(&$output, $depth, $args) {
464           $indent = str_repeat("\t", $depth);
465           $output .= "$indent</ul>\n";
466      }
467
468      function start_el(&$output, $category, $depth, $args) {
469           extract($args);
470
471           $class = in_array( $category->term_id, $popular_cats ) ? ' class="popular-category"' : '';
472           $output .= "\n<li id='category-$category->term_id'$class>" . '<label class="selectit"><input value="' . $category->term_id . '" type="checkbox" name="post_category[]" id="in-category-' . $category->term_id . '"' . (in_array( $category->term_id, $selected_cats ) ? ' checked="checked"' : "" ) . '/> ' . esc_html( apply_filters('the_category', $category->name )) . '</label>';
473      }
474
475      function end_el(&$output, $category, $depth, $args) {
476           $output .= "</li>\n";
477      }
478 }
479
480 /**
481  * {@internal Missing Short Description}}
 
Line Code
561           if ( !$echo ) // hack for AJAX use
562                continue;
563           $id = "popular-category-$category->term_id";
564           $checked = in_array( $category->term_id, $checked_categories ) ? 'checked="checked"' : '';
565           ?>
566
567           <li id="<?php echo $id; ?>" class="popular-category">
568                <label class="selectit">
569                <input id="in-<?php echo $id; ?>" type="checkbox" <?php echo $checked; ?> value="<?php echo (int) $category->term_id; ?>" />
570                     <?php echo esc_html( apply_filters( 'the_category', $category->name ) ); ?>
571                </label>
572           </li>
573
574           <?php
575      }
576      return $popular_ids;
577 }
578
579 /**
 
Line Code
613      }
614
615      $categories = get_terms('link_category', 'orderby=count&hide_empty=0');
616
617      if ( empty($categories) )
618           return;
619
620      foreach ( $categories as $category ) {
621           $cat_id = $category->term_id;
622           $name = esc_html( apply_filters('the_category', $category->name));
623           $checked = in_array( $cat_id, $checked_categories );
624           echo '<li id="link-category-', $cat_id, '"><label for="in-link-category-', $cat_id, '" class="selectit"><input value="', $cat_id, '" type="checkbox" name="link_category[]" id="in-link-category-', $cat_id, '"', ($checked ? ' checked="checked"' : "" ), '/> ', $name, "</label></li>";
625      }
626 }
627
628 // Tag stuff
629
630 // Returns a single tag row (see tag_rows below)
631 // Note: this is also used in admin-ajax.php!