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
164
165      $result = apply_filters('get_nested_categories', $result);
166      usort( $result, 'sort_cats' );
167
168      return $result;
169 }
170
171 function write_nested_categories( $categories ) {
172      foreach ( $categories as $category ) {
173           echo "\n", '<li id="category-', $category['cat_ID'], '"><label for="in-category-', $category['cat_ID'], '" class="selectit"><input value="', $category['cat_ID'], '" type="checkbox" name="post_category[]" id="in-category-', $category['cat_ID'], '"', ($category['checked'] ? ' checked="checked"' : "" ), '/> ', wp_specialchars( apply_filters('the_category', $category['cat_name'] )), '</label>';
174
175           if ( $category['children'] ) {
176                echo "\n<ul>";
177                write_nested_categories( $category['children'] );
178                echo "\n</ul>";
179           }
180           echo '</li>';
181      }
182 }
 
Line Code
189      $categories = get_terms( $taxonomy, array( 'orderby' => 'count', 'order' => 'DESC', 'number' => $number ) );
190
191      foreach ( (array) $categories as $category ) {
192           $id = "popular-category-$category->term_id";
193           ?>
194
195           <li id="<?php echo $id; ?>" >
196                <label class="selectit" for="in-<?php echo $id; ?>">
197                <input id="in-<?php echo $id; ?>" type="checkbox" value="<?php echo (int) $category->term_id; ?>" />
198                     <?php echo wp_specialchars( apply_filters( 'the_category', $category->name ) ); ?>
199                </label>
200           </li>
201
202           <?php
203      }
204 }
205
206 function dropdown_link_categories( $default = 0 ) {
207      global $link_id;
 
Line Code
218      }
219
220      $categories = get_terms('link_category', 'orderby=count&hide_empty=0');
221
222      if ( empty($categories) )
223           return;
224
225      foreach ( $categories as $category ) {
226           $cat_id = $category->term_id;
227           $name = wp_specialchars( apply_filters('the_category', $category->name));
228           $checked = in_array( $cat_id, $checked_categories );
229           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>";
230      }
231 }
232
233 // Tag stuff
234
235 // Returns a single tag row (see tag_rows below)
236 // Note: this is also used in admin-ajax.php!