Menu Adam R Brown

WP hooks navigation: Home/browseActions indexFilters index

Source View: get_categories

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

Line Code
27           $r['orderby'] = 'category_count';
28      else
29           $r['orderby'] = "cat_" . $r['orderby'];  // restricts order by to cat_ID and cat_name fields
30      $r['number'] = (int) $r['number'];
31      extract($r);
32
33      $key = md5( serialize( $r ) );
34      if ( $cache = wp_cache_get( 'get_categories', 'category' ) )
35           if ( isset( $cache[ $key ] ) )
36                return apply_filters('get_categories', $cache[$key], $r);
37
38      $where = 'cat_ID > 0';
39      $inclusions = '';
40      if ( !empty($include) ) {
41           $child_of = 0; //ignore child_of and exclude params if using include
42           $exclude = '';
43           $incategories = preg_split('/[\s,]+/',$include);
44           if ( count($incategories) ) {
45                foreach ( $incategories as $incat ) {
 
Line Code
128                     unset($categories[$k]);
129                }
130           }
131      }
132      reset ( $categories );
133
134      $cache[ $key ] = $categories;
135      wp_cache_add( 'get_categories', $cache, 'category' );
136
137      $categories = apply_filters('get_categories', $categories, $r);
138      return $categories;
139 }
140
141 // Retrieves category data given a category ID or category object.
142 // Handles category caching.
143 function &get_category(&$category, $output = OBJECT) {
144      global $wpdb;
145
146      if ( empty($category) )