From f15d3fc7739d88f9f7993e7e7975f207f89b5e2e Mon Sep 17 00:00:00 2001 From: Ryan Boren Date: Fri, 18 Apr 2008 18:12:04 +0000 Subject: [PATCH] Don't query post cats if no post. see #2621 git-svn-id: https://develop.svn.wordpress.org/trunk@7739 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-admin/edit-form-advanced.php | 2 +- wp-admin/includes/template.php | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/wp-admin/edit-form-advanced.php b/wp-admin/edit-form-advanced.php index 00fc5f8f2c..96776d4e3e 100644 --- a/wp-admin/edit-form-advanced.php +++ b/wp-admin/edit-form-advanced.php @@ -241,7 +241,7 @@ endif; ?>
diff --git a/wp-admin/includes/template.php b/wp-admin/includes/template.php index 71b4ec2556..7ed2d03d9d 100644 --- a/wp-admin/includes/template.php +++ b/wp-admin/includes/template.php @@ -156,11 +156,15 @@ class Walker_Category_Checklist extends Walker { } } -function wp_category_checklist( $post_id ) { +function wp_category_checklist( $post_id = 0 ) { $walker = new Walker_Category_Checklist; $args = array(); - $args['selected_cats'] = wp_get_post_categories($post_id); + + if ( $post_id ) + $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'); $args = array($categories, 0, $args);