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 4 times in this file.

Line Code
95
96                if ( in_array( $category->term_id, $args['selected_cats'] ) ) {
97                     $inner_class .= ' selected';
98                     $aria_cheched = 'true';
99                }
100
101                $output .= "\n" . '<li' . $class . '>' .
102                     '<div class="' . $inner_class . '" data-term-id=' . $category->term_id .
103                     ' tabindex="0" role="checkbox" aria-checked="' . $aria_cheched . '">' .
104                     esc_html( apply_filters( 'the_category', $category->name ) ) . '</div>';
105           } else {
106                $output .= "\n<li id='{$taxonomy}-{$category->term_id}'$class>" .
107                     '<label class="selectit"><input value="' . $category->term_id . '" type="checkbox" name="'.$name.'[]" id="in-'.$taxonomy.'-' . $category->term_id . '"' .
108                     checked( in_array( $category->term_id, $args['selected_cats'] ), true, false ) .
109                     disabled( empty( $args['disabled'] ), false, false ) . ' /> ' .
110                     esc_html( apply_filters( 'the_category', $category->name ) ) . '</label>';
111           }
112      }
113
114      /**
115       * Ends the element output, if needed.
116       *
117       * @see Walker::end_el()
118       *
119       * @since 2.5.1
 
Line Code
306           $id = "popular-$taxonomy-$term->term_id";
307           $checked = in_array( $term->term_id, $checked_terms ) ? 'checked="checked"' : '';
308           ?>
309
310           <li id="<?php echo $id; ?>" class="popular-category">
311                <label class="selectit">
312                     <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 ) ); ?> />
313                     <?php
314                     /** This filter is documented in wp-includes/category-template.php */
315                     echo esc_html( apply_filters( 'the_category', $term->name ) );
316                     ?>
317                </label>
318           </li>
319
320           <?php
321      }
322      return $popular_ids;
323 }
324
 
Line Code
347      $categories = get_terms( 'link_category', array( 'orderby' => 'name', 'hide_empty' => 0 ) );
348
349      if ( empty( $categories ) )
350           return;
351
352      foreach ( $categories as $category ) {
353           $cat_id = $category->term_id;
354
355           /** This filter is documented in wp-includes/category-template.php */
356           $name = esc_html( apply_filters( 'the_category', $category->name ) );
357           $checked = in_array( $cat_id, $checked_categories ) ? ' checked="checked"' : '';
358           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>";
359      }
360 }
361
362 /**
363  * Adds hidden fields with the data for use in the inline editor for posts and pages.
364  *
365  * @since 2.7.0