WordPress.org

Make WordPress Core

Changeset 18933


Ignore:
Timestamp:
10/10/2011 09:27:05 PM (7 years ago)
Author:
josephscott
Message:

Follow the pattern of wp-admin a bit more for metaWeblog.newPost by using get_default_post_to_edit() to generate a post ID before the post is actually published.

Fixes #18812
Props koke, nacin

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/class-wp-xmlrpc-server.php

    r18633 r18933  
    23952395        }
    23962396
    2397         // We've got all the data -- post it:
    23982397        $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');
    23992398
    2400         $post_ID = wp_insert_post($postdata, true);
    2401         if ( is_wp_error( $post_ID ) )
    2402             return new IXR_Error(500, $post_ID->get_error_message());
    2403 
    2404         if ( !$post_ID )
    2405             return new IXR_Error(500, __('Sorry, your entry could not be posted. Something wrong happened.'));
     2399        $post_ID = $postdata['ID'] = get_default_post_to_edit( $post_type, true )->ID;
    24062400
    24072401        // Only posts can be sticky
     
    24262420        if ( isset( $content_struct['wp_post_format'] ) )
    24272421            wp_set_post_terms( $post_ID, array( 'post-format-' . $content_struct['wp_post_format'] ), 'post_format' );
     2422
     2423        $post_ID = wp_insert_post( $postdata, true );
     2424        if ( is_wp_error( $post_ID ) )
     2425            return new IXR_Error(500, $post_ID->get_error_message());
     2426
     2427        if ( !$post_ID )
     2428            return new IXR_Error(500, __('Sorry, your entry could not be posted. Something wrong happened.'));
    24282429
    24292430        logIO('O', "Posted ! ID: $post_ID");
Note: See TracChangeset for help on using the changeset viewer.