Menu Adam R Brown

WP hooks navigation: Home/browseActions indexFilters index

Source View: list_cats

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
203      }
204      $query .=" GROUP BY cat_ID";
205      if ( intval($hide_empty) == 1 )
206           $query .= " HAVING cat_count > 0";
207      $query .= " ORDER BY $sort_column $sort_order, post_date DESC";
208
209      $categories = $wpdb->get_results($query);
210      echo "<select name='cat' class='postform'>\n";
211      if ( intval($optionall) == 1 ) {
212           $all = apply_filters('list_cats', $all);
213           echo "\t<option value='0'>$all</option>\n";
214      }
215      if ( intval($optionnone) == 1 )
216           echo "\t<option value='-1'>".__('None')."</option>\n";
217      if ( $categories ) {
218           foreach ( $categories as $category ) {
219                $cat_name = apply_filters('list_cats', $category->cat_name, $category);
220                echo "\t<option value=\"".$category->cat_ID."\"";
221                if ( $category->cat_ID == $selected )
222                     echo ' selected="selected"';
223                echo '>';
224                echo $cat_name;
225                if ( intval($optioncount) == 1 )
226                     echo '&nbsp;&nbsp;('.$category->cat_count.')';
227                if ( intval($optiondates) == 1 )
228                     echo '&nbsp;&nbsp;'.$category->lastday.'/'.$category->lastmonth;
 
Line Code
322      foreach ( (array) $categories as $category ) {
323           if ( ( intval($hide_empty) == 0 || $category->category_count) && (!$hierarchical || $category->category_parent == $child_of) ) {
324                $num_found++;
325                $link = '<a href="'.get_category_link($category->cat_ID).'" ';
326                if ( $use_desc_for_title == 0 || empty($category->category_description) )
327                     $link .= 'title="'. sprintf(__("View all posts filed under %s"), attribute_escape($category->cat_name)) . '"';
328                else
329                     $link .= 'title="' . attribute_escape(apply_filters('category_description',$category->category_description,$category)) . '"';
330                $link .= '>';
331                $link .= apply_filters('list_cats', $category->cat_name, $category).'</a>';
332
333                if ( (! empty($feed_image)) || (! empty($feed)) ) {
334
335                     $link .= ' ';
336
337                     if ( empty($feed_image) )
338                          $link .= '(';
339
340                     $link .= '<a href="' . get_category_rss_link(0, $category->cat_ID, $category->category_nicename) . '"';
 
Line Code
395      if ( $list && $child_of && $num_found && $recurse ) {
396           $pre = "\t\t<ul class='children'>";
397           $post = "\t\t</ul>\n";
398      } else {
399           $pre = $post = '';
400      }
401      $thelist = $pre . $thelist . $post;
402      if ( $recurse )
403           return $thelist;
404      echo apply_filters('list_cats', $thelist);
405 }
406
407 function in_category($category) { // Check if the current post is in the given category
408      global $category_cache, $post;
409
410      if ( isset( $category_cache[$post->ID][$category] ) )
411           return true;
412      else
413           return false;