WordPress.org

Make WordPress Core

Ticket #18812: rpc.diff

File rpc.diff, 1.5 KB (added by josephscott, 4 years ago)
  • wp-includes/class-wp-xmlrpc-server.php

     
    23972397                // We've got all the data -- post it: 
    23982398                $postdata = compact('post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_title', 'post_category', 'post_status', 'post_excerpt', 'comment_status', 'ping_status', 'to_ping', 'post_type', 'post_name', 'post_password', 'post_parent', 'menu_order', 'tags_input', 'page_template'); 
    23992399 
    2400                 $post_ID = wp_insert_post($postdata, true); 
     2400                // For published posts set it to an auto-draft first, to get a post id. 
     2401                // That gives us a chance to add the additional data to the post 
     2402                // before triggering a publish event. 
     2403                if ( $post_status == 'publish' ) { 
     2404                        $postdata['post_status'] = 'auto-draft'; 
     2405                } 
     2406 
     2407                $post_ID = $postdata['ID'] = wp_insert_post($postdata, true); 
    24012408                if ( is_wp_error( $post_ID ) ) 
    24022409                        return new IXR_Error(500, $post_ID->get_error_message()); 
    24032410 
     
    24262433                if ( isset( $content_struct['wp_post_format'] ) ) 
    24272434                        wp_set_post_terms( $post_ID, array( 'post-format-' . $content_struct['wp_post_format'] ), 'post_format' ); 
    24282435 
     2436                // Make sure the proper status is set, for publishing that would 
     2437                // be from auto-draft to publish. 
     2438                $postdata['post_status'] = $post_status; 
     2439                $status = wp_update_post( $postdata, true ); 
     2440 
    24292441                logIO('O', "Posted ! ID: $post_ID"); 
    24302442 
    24312443                return strval($post_ID);