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