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
415      function end_lvl(&$output, $depth, $args) {
416           $indent = str_repeat("\t", $depth);
417           $output .= "$indent</ul>\n";
418      }
419
420      function start_el(&$output, $category, $depth, $args) {
421           extract($args);
422
423           $class = in_array( $category->term_id, $popular_cats ) ? ' class="popular-category"' : '';
424           $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"' : "" ) . '/> ' . wp_specialchars( apply_filters('the_category', $category->name )) . '</label>';
425      }
426
427      function end_el(&$output, $category, $depth, $args) {
428           $output .= "</li>\n";
429      }
430 }
431
432 /**
433  * {@internal Missing Short Description}}
 
Line Code
504           $popular_ids[] = $category->term_id;
505           if ( !$echo ) // hack for AJAX use
506                continue;
507           $id = "popular-category-$category->term_id";
508           ?>
509
510           <li id="<?php echo $id; ?>" class="popular-category">
511                <label class="selectit">
512                <input id="in-<?php echo $id; ?>" type="checkbox" value="<?php echo (int) $category->term_id; ?>" />
513                     <?php echo wp_specialchars( apply_filters( 'the_category', $category->name ) ); ?>
514                </label>
515           </li>
516
517           <?php
518      }
519      return $popular_ids;
520 }
521
522 /**
 
Line Code
556      }
557
558      $categories = get_terms('link_category', 'orderby=count&hide_empty=0');
559
560      if ( empty($categories) )
561           return;
562
563      foreach ( $categories as $category ) {
564           $cat_id = $category->term_id;
565           $name = wp_specialchars( apply_filters('the_category', $category->name));
566           $checked = in_array( $cat_id, $checked_categories );
567           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>";
568      }
569 }
570
571 // Tag stuff
572
573 // Returns a single tag row (see tag_rows below)
574 // Note: this is also used in admin-ajax.php!