Menu Adam R Brown

WP hooks navigation: Home/browseActions indexFilters index

Source View: get_nested_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

Line Code
108      if ( is_array( $cats ) ) {
109           foreach ( $cats as $cat) {
110                $result[$cat]['children'] = get_nested_categories( $default, $cat);
111                $result[$cat]['cat_ID'] = $cat;
112                $result[$cat]['checked'] = in_array( $cat, $checked_categories );
113                $result[$cat]['cat_name'] = get_the_category_by_ID( $cat);
114           }
115      }
116
117      $result = apply_filters('get_nested_categories', $result);
118      usort( $result, 'sort_cats' );
119
120      return $result;
121 }
122
123 function write_nested_categories( $categories ) {
124      foreach ( $categories as $category ) {
125           echo '<li id="category-', $category['cat_ID'], '"><label for="in-category-', $category['cat_ID'], '" class="selectit"><input value="', $category['cat_ID'], '" type="checkbox" name="post_category[]" id="in-category-', $category['cat_ID'], '"', ($category['checked'] ? ' checked="checked"' : "" ), '/> ', wp_specialchars( apply_filters('the_category', $category['cat_name'] )), "</label></li>";
126