WordPress.org

Make WordPress Core

Ticket #13531: 13531.diff

File 13531.diff, 1.5 KB (added by ryan, 8 years ago)

Don't see default category for auto-drafts

  • wp-includes/post.php

     
    21742174        if ( empty($post_type) )
    21752175                $post_type = 'post';
    21762176
     2177        if ( empty($post_status) )
     2178                $post_status = 'draft';
     2179
    21772180        if ( !empty($post_category) )
    21782181                $post_category = array_filter($post_category); // Filter out empty terms
    21792182
    21802183        // Make sure we set a valid category.
    21812184        if ( empty($post_category) || 0 == count($post_category) || !is_array($post_category) ) {
    21822185                // 'post' requires at least one category.
    2183                 if ( 'post' == $post_type )
     2186                if ( 'post' == $post_type && 'auto-draft' != $post_status )
    21842187                        $post_category = array( get_option('default_category') );
    21852188                else
    21862189                        $post_category = array();
     
    21892192        if ( empty($post_author) )
    21902193                $post_author = $user_ID;
    21912194
    2192         if ( empty($post_status) )
    2193                 $post_status = 'draft';
    2194 
    21952195        $post_ID = 0;
    21962196
    21972197        // Get the post ID and GUID
     
    26602660function wp_set_post_categories($post_ID = 0, $post_categories = array()) {
    26612661        $post_ID = (int) $post_ID;
    26622662        $post_type = get_post_type( $post_ID );
     2663        $post_status = get_post_status( $post_ID );
    26632664        // If $post_categories isn't already an array, make it one:
    26642665        if ( !is_array($post_categories) || empty($post_categories) ) {
    2665                 if ( 'post' == $post_type )
     2666                if ( 'post' == $post_type && 'auto-draft' != $post_status )
    26662667                        $post_categories = array( get_option('default_category') );
    26672668                else
    26682669                        $post_categories = array();