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
172      function end_lvl(&$output, $depth, $args) {
173           $indent = str_repeat("\t", $depth);
174           $output .= "$indent</ul>\n";
175      }
176
177      function start_el(&$output, $category, $depth, $args) {
178           extract($args);
179
180           $class = in_array( $category->term_id, $popular_cats ) ? ' class="popular-category"' : '';
181           $output .= "\n<li id='category-$category->term_id'$class>" . '<label for="in-category-' . $category->term_id . '" 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>';
182      }
183
184      function end_el(&$output, $category, $depth, $args) {
185           $output .= "</li>\n";
186      }
187 }
188
189 function wp_category_checklist( $post_id = 0, $descendants_and_self = 0, $selected_cats = false, $popular_cats = false ) {
190      $walker = new Walker_Category_Checklist;
 
Line Code
240           $popular_ids[] = $category->term_id;
241           if ( !$echo ) // hack for AJAX use
242                continue;
243           $id = "popular-category-$category->term_id";
244           ?>
245
246           <li id="<?php echo $id; ?>" class="popular-category">
247                <label class="selectit" for="in-<?php echo $id; ?>">
248                <input id="in-<?php echo $id; ?>" type="checkbox" value="<?php echo (int) $category->term_id; ?>" />
249                     <?php echo wp_specialchars( apply_filters( 'the_category', $category->name ) ); ?>
250                </label>
251           </li>
252
253           <?php
254      }
255      return $popular_ids;
256 }
257
258 // Deprecated. Use wp_link_category_checklist
 
Line Code
275      }
276
277      $categories = get_terms('link_category', 'orderby=count&hide_empty=0');
278
279      if ( empty($categories) )
280           return;
281
282      foreach ( $categories as $category ) {
283           $cat_id = $category->term_id;
284           $name = wp_specialchars( apply_filters('the_category', $category->name));
285           $checked = in_array( $cat_id, $checked_categories );
286           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>";
287      }
288 }
289
290 // Tag stuff
291
292 // Returns a single tag row (see tag_rows below)
293 // Note: this is also used in admin-ajax.php!