From 1f169578f934ccea4427fd4a08bdeb7c3c440b33 Mon Sep 17 00:00:00 2001 From: ryan Date: Mon, 22 Feb 2010 17:19:54 +0000 Subject: [PATCH] Don't require a default category for attachment types other than 'post'. Props jfarthing84. see #9674 git-svn-id: http://svn.automattic.com/wordpress/trunk@13291 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/post.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/wp-includes/post.php b/wp-includes/post.php index 87d4aa0c2..cbb18798e 100644 --- a/wp-includes/post.php +++ b/wp-includes/post.php @@ -3133,16 +3133,20 @@ function wp_insert_attachment($object, $file = false, $parent = 0) { // export array as variables extract($object, EXTR_SKIP); - // Make sure we set a valid category - if ( !isset($post_category) || 0 == count($post_category) || !is_array($post_category)) { - $post_category = array(get_option('default_category')); - } - if ( empty($post_author) ) $post_author = $user_ID; $post_type = 'attachment'; $post_status = 'inherit'; + + // Make sure we set a valid category. + if ( !isset($post_category) || 0 == count($post_category) || !is_array($post_category) ) { + // 'post' requires at least one category. + if ( 'post' == $post_type ) + $post_category = array( get_option('default_category') ); + else + $post_category = array(); + } // Are we updating or creating? if ( !empty($ID) ) {