From e63b2b97be22d405986afb4372376eec92d34612 Mon Sep 17 00:00:00 2001 From: Ryan Boren Date: Tue, 25 May 2010 14:43:39 +0000 Subject: [PATCH] Don't set default category when saving an auto-draft. fixes #13531 git-svn-id: https://develop.svn.wordpress.org/trunk@14883 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/post.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/wp-includes/post.php b/wp-includes/post.php index 42ba2c0c04..10e79ea79b 100644 --- a/wp-includes/post.php +++ b/wp-includes/post.php @@ -2174,13 +2174,16 @@ function wp_insert_post($postarr = array(), $wp_error = false) { if ( empty($post_type) ) $post_type = 'post'; + if ( empty($post_status) ) + $post_status = 'draft'; + if ( !empty($post_category) ) $post_category = array_filter($post_category); // Filter out empty terms // Make sure we set a valid category. if ( empty($post_category) || 0 == count($post_category) || !is_array($post_category) ) { // 'post' requires at least one category. - if ( 'post' == $post_type ) + if ( 'post' == $post_type && 'auto-draft' != $post_status ) $post_category = array( get_option('default_category') ); else $post_category = array(); @@ -2189,9 +2192,6 @@ function wp_insert_post($postarr = array(), $wp_error = false) { if ( empty($post_author) ) $post_author = $user_ID; - if ( empty($post_status) ) - $post_status = 'draft'; - $post_ID = 0; // Get the post ID and GUID @@ -2660,9 +2660,10 @@ function wp_set_post_terms( $post_id = 0, $tags = '', $taxonomy = 'post_tag', $a function wp_set_post_categories($post_ID = 0, $post_categories = array()) { $post_ID = (int) $post_ID; $post_type = get_post_type( $post_ID ); + $post_status = get_post_status( $post_ID ); // If $post_categories isn't already an array, make it one: if ( !is_array($post_categories) || empty($post_categories) ) { - if ( 'post' == $post_type ) + if ( 'post' == $post_type && 'auto-draft' != $post_status ) $post_categories = array( get_option('default_category') ); else $post_categories = array();