Make WordPress Core

Ticket #27736: 27736.post.php.2.patch

File 27736.post.php.2.patch, 1.8 KB (added by ozh, 10 years ago)

fix wp_insert_attachment() as well

  • post.php

     
    30423042        }
    30433043
    30443044        if ( is_object_in_taxonomy($post_type, 'category') )
    3045                 wp_set_post_categories( $post_ID, $post_category );
     3045                wp_set_post_categories( $post_ID, $post_category, false, $post_type, $post_status );
    30463046
    30473047        if ( isset( $tags_input ) && is_object_in_taxonomy($post_type, 'post_tag') )
    30483048                wp_set_post_tags( $post_ID, $tags_input );
     
    33963396 * @param int $post_ID Post ID.
    33973397 * @param array|int $post_categories Optional. List of categories or ID of category.
    33983398 * @param bool $append If true, don't delete existing categories, just add on. If false, replace the categories with the new categories.
     3399 * @param string $post_type Optional post type
     3400 * @param string $post_status Optional post status
    33993401 * @return bool|mixed
    34003402 */
    3401 function wp_set_post_categories( $post_ID = 0, $post_categories = array(), $append = false ) {
     3403function wp_set_post_categories( $post_ID = 0, $post_categories = array(), $append = false, $post_type = '', $post_status = '' ) {
    34023404        $post_ID = (int) $post_ID;
    3403         $post_type = get_post_type( $post_ID );
    3404         $post_status = get_post_status( $post_ID );
     3405        if( !$post_type )
     3406                $post_type = get_post_type( $post_ID );
     3407    if( !$post_status )
     3408                $post_status = get_post_status( $post_ID );
    34053409        // If $post_categories isn't already an array, make it one:
    34063410        $post_categories = (array) $post_categories;
    34073411        if ( empty( $post_categories ) ) {
     
    42714275        }
    42724276
    42734277        if ( is_object_in_taxonomy($post_type, 'category') )
    4274                 wp_set_post_categories( $post_ID, $post_category );
     4278                wp_set_post_categories( $post_ID, $post_category, false, $post_type, $post_status );
    42754279
    42764280        if ( isset( $tags_input ) && is_object_in_taxonomy($post_type, 'post_tag') )
    42774281                wp_set_post_tags( $post_ID, $tags_input );