Make WordPress Core

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

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

More coding standards: braces on all if

  • post.php

     
    30413041                $wpdb->update( $wpdb->posts, array( 'post_name' => $data['post_name'] ), $where );
    30423042        }
    30433043
    3044         if ( is_object_in_taxonomy($post_type, 'category') )
    3045                 wp_set_post_categories( $post_ID, $post_category );
     3044        if ( is_object_in_taxonomy($post_type, 'category') ) {
     3045                wp_set_post_categories( $post_ID, $post_category, false, $post_type, $post_status );
     3046        }
    30463047
    30473048        if ( isset( $tags_input ) && is_object_in_taxonomy($post_type, 'post_tag') )
    30483049                wp_set_post_tags( $post_ID, $tags_input );
     
    33963397 * @param int $post_ID Post ID.
    33973398 * @param array|int $post_categories Optional. List of categories or ID of category.
    33983399 * @param bool $append If true, don't delete existing categories, just add on. If false, replace the categories with the new categories.
     3400 * @param string $post_type Optional post type
     3401 * @param string $post_status Optional post status
    33993402 * @return bool|mixed
    34003403 */
    3401 function wp_set_post_categories( $post_ID = 0, $post_categories = array(), $append = false ) {
     3404function wp_set_post_categories( $post_ID = 0, $post_categories = array(), $append = false, $post_type = '', $post_status = '' ) {
    34023405        $post_ID = (int) $post_ID;
    3403         $post_type = get_post_type( $post_ID );
    3404         $post_status = get_post_status( $post_ID );
     3406        if( !$post_type ) {
     3407                $post_type = get_post_type( $post_ID );
     3408        }
     3409        if( !$post_status ) {
     3410                $post_status = get_post_status( $post_ID );
     3411        }
    34053412        // If $post_categories isn't already an array, make it one:
    34063413        $post_categories = (array) $post_categories;
    34073414        if ( empty( $post_categories ) ) {
     
    42704277                $wpdb->update( $wpdb->posts, compact("post_name"), array( 'ID' => $post_ID ) );
    42714278        }
    42724279
    4273         if ( is_object_in_taxonomy($post_type, 'category') )
    4274                 wp_set_post_categories( $post_ID, $post_category );
     4280        if ( is_object_in_taxonomy($post_type, 'category') ) {
     4281                wp_set_post_categories( $post_ID, $post_category, false, $post_type, $post_status );
     4282        }
    42754283
    42764284        if ( isset( $tags_input ) && is_object_in_taxonomy($post_type, 'post_tag') )
    42774285                wp_set_post_tags( $post_ID, $tags_input );