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
39           if ( empty($taxonomy) )
40                $taxonomy = 'category';
41
42           if ( $taxonomy == 'category' )
43                $name = 'post_category';
44           else
45                $name = 'tax_input['.$taxonomy.']';
46
47           $class = in_array( $category->term_id, $popular_cats ) ? ' class="popular-category"' : '';
48           $output .= "\n<li id='{$taxonomy}-{$category->term_id}'$class>" . '<label class="selectit"><input value="' . $category->term_id . '" type="checkbox" name="'.$name.'[]" id="in-'.$taxonomy.'-' . $category->term_id . '"' . checked( in_array( $category->term_id, $selected_cats ), true, false ) . disabled( empty( $args['disabled'] ), false, false ) . ' /> ' . esc_html( apply_filters('the_category', $category->name )) . '</label>';
49      }
50
51      function end_el( &$output, $category, $depth = 0, $args = array() ) {
52           $output .= "</li>\n";
53      }
54 }
55
56 /**
57  * Output an unordered list of checkbox <input> elements labelled
 
Line Code
183           if ( !$echo ) // hack for AJAX use
184                continue;
185           $id = "popular-$taxonomy-$term->term_id";
186           $checked = in_array( $term->term_id, $checked_terms ) ? 'checked="checked"' : '';
187           ?>
188
189           <li id="<?php echo $id; ?>" class="popular-category">
190                <label class="selectit">
191                <input id="in-<?php echo $id; ?>" type="checkbox" <?php echo $checked; ?> value="<?php echo (int) $term->term_id; ?>" <?php disabled( ! current_user_can( $tax->cap->assign_terms ) ); ?> />
192                     <?php echo esc_html( apply_filters( 'the_category', $term->name ) ); ?>
193                </label>
194           </li>
195
196           <?php
197      }
198      return $popular_ids;
199 }
200
201 /**
 
Line Code
218      }
219
220      $categories = get_terms( 'link_category', array( 'orderby' => 'name', 'hide_empty' => 0 ) );
221
222      if ( empty( $categories ) )
223           return;
224
225      foreach ( $categories as $category ) {
226           $cat_id = $category->term_id;
227           $name = esc_html( apply_filters( 'the_category', $category->name ) );
228           $checked = in_array( $cat_id, $checked_categories ) ? ' checked="checked"' : '';
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, '/> ', $name, "</label></li>";
230      }
231 }
232
233 // adds hidden fields with the data for use in the inline editor for posts and pages
234 /**
235  * {@internal Missing Short Description}}
236  *