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

git-svn-id: http://svn.automattic.com/wordpress/trunk@7777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2008-04-22 22:45:53 +00:00
parent 444391eaff
commit 6e23bed1fd
4 changed files with 17 additions and 8 deletions

View File

@ -162,9 +162,8 @@ case 'add-category' : // On the Fly
if ( $parent ) // Do these all at once in a second
continue;
$category = get_category( $cat_id );
$checked_categories[] = $cat_id;
ob_start();
dropdown_categories( 0, $category );
wp_category_checklist( 0, $cat_id, $checked_categories );
$data = ob_get_contents();
ob_end_clean();
$x->add( array(

View File

@ -148,8 +148,9 @@ class Walker_Category_Checklist extends Walker {
}
}
function wp_category_checklist( $post_id = 0 ) {
function wp_category_checklist( $post_id = 0, $descendants_and_self = 0, $selected_cats = false ) {
$walker = new Walker_Category_Checklist;
$descendants_and_self = (int) $descendants_and_self;
$args = array();
@ -157,8 +158,17 @@ function wp_category_checklist( $post_id = 0 ) {
$args['selected_cats'] = wp_get_post_categories($post_id);
else
$args['selected_cats'] = array();
$args['popular_cats'] = get_terms( 'category', array( 'fields' => 'ids', 'orderby' => 'count', 'order' => 'DESC', 'number' => 10 ) );
$categories = get_categories('get=all');
if ( is_array( $selected_cats ) )
$args['selected_cats'] = $selected_cats;
$args['popular_cats'] = get_terms( 'category', array( 'fields' => 'ids', 'orderby' => 'count', 'order' => 'DESC', 'number' => 10, 'hierarchical' => false ) );
if ( $descendants_and_self ) {
$categories = get_categories( "child_of=$descendants_and_self&hierarchical=0&hide_empty=0" );
$self = get_category( $descendants_and_self );
array_unshift( $categories, $self );
} else {
$categories = get_categories('get=all');
}
$args = array($categories, 0, $args);
$output = call_user_func_array(array(&$walker, 'walk'), $args);
@ -166,7 +176,7 @@ function wp_category_checklist( $post_id = 0 ) {
}
function wp_popular_terms_checklist( $taxonomy, $default = 0, $number = 10 ) {
$categories = get_terms( $taxonomy, array( 'orderby' => 'count', 'order' => 'DESC', 'number' => $number ) );
$categories = get_terms( $taxonomy, array( 'orderby' => 'count', 'order' => 'DESC', 'number' => $number, 'hierarchical' => false ) );
$popular_ids = array();
foreach ( (array) $categories as $category ) {

View File

@ -131,7 +131,7 @@ jQuery(document).ready( function() {
var th = jQuery(this);
var val = th.find('input').val();
var id = th.find('input')[0].id
jQuery('#' + id).change( syncChecks );
jQuery('#' + id).change( syncChecks ).change();
if ( newCatParent.find( 'option[value=' + val + ']' ).size() )
return;
var name = jQuery.trim( th.text() );

View File

@ -144,7 +144,7 @@ class WP_Scripts {
'save' => __('Save'),
'cancel' => __('Cancel'),
) );
$this->add( 'post', '/wp-admin/js/post.js', array('suggest', 'jquery-ui-tabs', 'wp-lists', 'postbox', 'slug'), '20080411' );
$this->add( 'post', '/wp-admin/js/post.js', array('suggest', 'jquery-ui-tabs', 'wp-lists', 'postbox', 'slug'), '20080422' );
$this->localize( 'post', 'postL10n', array(
'tagsUsed' => __('Tags used on this post:'),
'add' => attribute_escape(__('Add')),