WordPress.org

Make WordPress Core

Ticket #13246: 14438.diff

File 14438.diff, 1.3 KB (added by scribu, 8 years ago)
  • wp-includes/post.php

     
    20842089        if ( empty($post_type) )
    20852090                $post_type = 'post';
    20862091
    2087         if ( !empty($post_category) )
    2088                 $post_category = array_filter($post_category); // Filter out empty terms
    2089 
    2090         // Make sure we set a valid category.
    2091         if ( empty($post_category) || 0 == count($post_category) || !is_array($post_category) ) {
    2092                 // 'post' requires at least one category.
    2093                 if ( 'post' == $post_type )
    2094                         $post_category = array( get_option('default_category') );
    2095                 else
    2096                         $post_category = array();
    2097         }
    2098 
    20992092        if ( empty($post_author) )
    21002093                $post_author = $user_ID;
    21012094
     
    25662559        $post_ID = (int) $post_ID;
    25672560        $post_type = get_post_type( $post_ID );
    25682561        // If $post_categories isn't already an array, make it one:
    2569         if ( !is_array($post_categories) || 0 == count($post_categories) || empty($post_categories) ) {
     2562        if ( !is_array($post_categories) || empty($post_categories) ) {
    25702563                if ( 'post' == $post_type )
    25712564                        $post_categories = array( get_option('default_category') );
    25722565                else
    25732566                        $post_categories = array();
    2574         } else if ( 1 == count($post_categories) && '' == $post_categories[0] ) {
     2567        } else if ( 1 == count($post_categories) && '' == reset($post_categories) ) {
    25752568                return true;
    25762569        }
    25772570