From d6a835521fdffe9ee110a9b8f074dbe360e487b0 Mon Sep 17 00:00:00 2001 From: josephscott Date: Mon, 10 Oct 2011 21:27:05 +0000 Subject: [PATCH] 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 git-svn-id: http://svn.automattic.com/wordpress/trunk@18933 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/class-wp-xmlrpc-server.php | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/wp-includes/class-wp-xmlrpc-server.php b/wp-includes/class-wp-xmlrpc-server.php index 96b27d351..a4ba0f883 100644 --- a/wp-includes/class-wp-xmlrpc-server.php +++ b/wp-includes/class-wp-xmlrpc-server.php @@ -2394,15 +2394,9 @@ class wp_xmlrpc_server extends IXR_Server { } } - // We've got all the data -- post it: $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'); - $post_ID = wp_insert_post($postdata, true); - if ( is_wp_error( $post_ID ) ) - return new IXR_Error(500, $post_ID->get_error_message()); - - if ( !$post_ID ) - return new IXR_Error(500, __('Sorry, your entry could not be posted. Something wrong happened.')); + $post_ID = $postdata['ID'] = get_default_post_to_edit( $post_type, true )->ID; // Only posts can be sticky if ( $post_type == 'post' && isset( $content_struct['sticky'] ) ) { @@ -2426,6 +2420,13 @@ class wp_xmlrpc_server extends IXR_Server { if ( isset( $content_struct['wp_post_format'] ) ) wp_set_post_terms( $post_ID, array( 'post-format-' . $content_struct['wp_post_format'] ), 'post_format' ); + $post_ID = wp_insert_post( $postdata, true ); + if ( is_wp_error( $post_ID ) ) + return new IXR_Error(500, $post_ID->get_error_message()); + + if ( !$post_ID ) + return new IXR_Error(500, __('Sorry, your entry could not be posted. Something wrong happened.')); + logIO('O', "Posted ! ID: $post_ID"); return strval($post_ID);