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.

  • Action hooks look like this: do_action( "hook_name" )
  • Filter hooks look like this: apply_filters( "hook_name", "what_to_filter" ).

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
156                foreach ( $cats as $cat ) {
157                     $result[$cat]['children'] = get_nested_categories( $default, $cat );
158                     $result[$cat]['cat_ID'] = $cat;
159                     $result[$cat]['checked'] = in_array( $cat, $checked_categories );
160                     $result[$cat]['cat_name'] = get_the_category_by_ID( $cat );
161                }
162           }
163      }
164
165      $result = apply_filters('get_nested_categories', $result);
166      usort( $result, 'sort_cats' );
167
168      return $result;
169 }
170
171 function write_nested_categories( $categories ) {
172      foreach ( $categories as $category ) {
173           echo "\n", '<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>';
174