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
556           $popular_ids[] = $category->term_id;
557           if ( !$echo ) // hack for AJAX use
558                continue;
559           $id = "popular-category-$category->term_id";
560           ?>
561
562           <li id="<?php echo $id; ?>" class="popular-category">
563                <label class="selectit">
564                <input id="in-<?php echo $id; ?>" type="checkbox" value="<?php echo (int) $category->term_id; ?>" />
565                     <?php echo esc_html( apply_filters( 'the_category', $category->name ) ); ?>
566                </label>
567           </li>
568
569           <?php
570      }
571      return $popular_ids;
572 }
573
574 /**
 
Line Code
608      }
609
610      $categories = get_terms('link_category', 'orderby=count&hide_empty=0');
611
612      if ( empty($categories) )
613           return;
614
615      foreach ( $categories as $category ) {
616           $cat_id = $category->term_id;
617           $name = esc_html( apply_filters('the_category', $category->name));
618           $checked = in_array( $cat_id, $checked_categories );
619           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>";
620      }
621 }
622
623 // Tag stuff
624
625 // Returns a single tag row (see tag_rows below)
626 // Note: this is also used in admin-ajax.php!