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
214         $query .= get_category_children($hide, " AND cat_ID != ");
215     }
216     $query .=" GROUP BY cat_ID";
217     if (intval($hide_empty) == 1) $query .= " HAVING cat_count > 0";
218     $query .= " ORDER BY $sort_column $sort_order, post_date DESC";
219
220     $categories = $wpdb->get_results($query);
221     echo "<select name='cat' class='postform'>\n";
222     if (intval($optionall) == 1) {
223         $all = apply_filters('list_cats', $all);
224         echo "\t<option value='all'>$all</option>\n";
225     }
226     if (intval($optionnone) == 1) echo "\t<option value='0'>None</option>\n";
227     if ($categories) {
228         foreach ($categories as $category) {
229             $cat_name = apply_filters('list_cats', $category->cat_name);
230             echo "\t<option value=\"".$category->cat_ID."\"";
231             if ($category->cat_ID == $selected)
232                 echo ' selected="selected"';
233             echo '>';
234             echo stripslashes($cat_name);
235             if (intval($optioncount) == 1) echo '&nbsp;&nbsp;('.$category->cat_count.')';
236             if (intval($optiondates) == 1) echo '&nbsp;&nbsp;'.$category->lastday.'/'.$category->lastmonth;
237             echo "</option>\n";
238         }
 
Line Code
317           WHERE post_status = 'publish' $exclusions
318           GROUP BY category_id");
319           foreach ($cat_dates as $cat_date) {
320                $category_lastday["$cat_date->cat_ID"] = $cat_date->lastday;
321                $category_lastmonth["$cat_date->cat_ID"] = $cat_date->lastmonth;
322           }
323      }
324      
325      if (intval($optionall) == 1 && !$child_of && $categories) {
326           $all = apply_filters('list_cats', $all);
327           $link = "<a href=\"".$file.$querystring_start.'cat'.$querystring_equal.'all">'.$all."</a>";
328           if ($list) {
329                echo "\n\t<li>$link</li>";
330           } else {
331                echo "\t$link<br />\n";
332           }
333      }
334      
335      $num_found=0;
 
Line Code
406           $pre = "\t\t<ul class='children'>";
407           $post = "\t\t</ul>\n";
408      } else {
409           $pre = $post = '';
410      }
411      $thelist = $pre . $thelist . $post;
412      if ($recurse) {
413           return $thelist;
414      }
415      echo apply_filters('list_cats', $thelist);
416 }
417
418 function in_category($category) { // Check if the current post is in the given category
419      global $post, $category_cache;
420      $cats = '';
421      foreach ($category_cache[$post->ID] as $cat) :
422           $cats[] = $cat->category_id;
423      endforeach;
424