Make WordPress Core

Ticket #7115: wp_category_checklist.txt

File wp_category_checklist.txt, 1023 bytes (added by youngmicroserf, 18 years ago)

patched function wp_category_checklist

Line 
1function wp_category_checklist( $post_id = 0, $descendants_and_self = 0, $include_self = 0, $selected_cats = false ) {
2$walker = new Walker_Category_Checklist;
3$descendants_and_self = (int) $descendants_and_self;
4
5args = array();
6
7if ( $post_id )
8 $args['selected_cats'] = wp_get_post_categories($post_id);
9else
10 $args['selected_cats'] = array();
11if ( is_array( $selected_cats ) )
12 $args['selected_cats'] = $selected_cats;
13$args['popular_cats'] = get_terms( 'category', array( 'fields' => 'ids', 'orderby' => 'count', 'order' => 'DESC', 'number' => 10, 'hierarchical' => false ) );
14if ( $descendants_and_self ) {
15 $categories = get_categories( "child_of=$descendants_and_self&hierarchical=0&hide_empty=0" );
16 if ( $include_self ) {
17 $self = get_category( $descendants_and_self );
18 array_unshift( $categories, $self );
19 }
20} else {
21 $categories = get_categories('get=all');
22}
23
24$args = array($categories, 0, $args);
25$output = call_user_func_array(array(&$walker, 'walk'), $args);
26
27echo $output;
28}