Make WordPress Core


Ignore:
Timestamp:
04/22/2008 10:46:09 PM (16 years ago)
Author:
ryan
Message:

wp_category_checklist() fixes from mdawaffe. fixes #6810 for 2.5

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.5/wp-admin/includes/template.php

    r7770 r7778  
    149149}
    150150
    151 function wp_category_checklist( $post_id = 0 ) {
     151function wp_category_checklist( $post_id = 0, $descendants_and_self = 0, $selected_cats = false ) {
    152152    $walker = new Walker_Category_Checklist;
     153    $descendants_and_self = (int) $descendants_and_self;
    153154
    154155    $args = array();
     
    158159    else
    159160        $args['selected_cats'] = array();
    160     $args['popular_cats'] = get_terms( 'category', array( 'fields' => 'ids', 'orderby' => 'count', 'order' => 'DESC', 'number' => 10 ) );
    161     $categories = get_categories('get=all');
     161    if ( is_array( $selected_cats ) )
     162        $args['selected_cats'] = $selected_cats;
     163    $args['popular_cats'] = get_terms( 'category', array( 'fields' => 'ids', 'orderby' => 'count', 'order' => 'DESC', 'number' => 10, 'hierarchical' => false ) );
     164    if ( $descendants_and_self ) {
     165        $categories = get_categories( "child_of=$descendants_and_self&hierarchical=0&hide_empty=0" );
     166        $self = get_category( $descendants_and_self );
     167        array_unshift( $categories, $self );
     168    } else {
     169        $categories = get_categories('get=all');
     170    }
     171
    162172    $args = array($categories, 0, $args);
    163173    $output = call_user_func_array(array(&$walker, 'walk'), $args);
     
    167177
    168178function wp_popular_terms_checklist( $taxonomy, $default = 0, $number = 10 ) {
    169     $categories = get_terms( $taxonomy, array( 'orderby' => 'count', 'order' => 'DESC', 'number' => $number ) );
     179    $categories = get_terms( $taxonomy, array( 'orderby' => 'count', 'order' => 'DESC', 'number' => $number, 'hierarchical' => false ) );
    170180
    171181    $popular_ids = array();
Note: See TracChangeset for help on using the changeset viewer.