Allow wp.uploadFile to upload the attachment to a post. props djzone, josephscott, maxcutler. fixes #13917.

git-svn-id: http://core.svn.wordpress.org/trunk@21896 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Andrew Nacin 2012-09-18 19:06:27 +00:00
parent 8892592379
commit 3c4460fc86
1 changed files with 6 additions and 1 deletions

View File

@ -4894,8 +4894,13 @@ class wp_xmlrpc_server extends IXR_Server {
return new IXR_Error(500, $errorString);
}
// Construct the attachment array
// attach to post_id 0
$post_id = 0;
if ( ! empty( $data['post_id'] ) ) {
$post_id = (int) $data['post_id'];
if ( ! current_user_can( 'edit_post', $post_id ) )
return new IXR_Error( 401, __( 'Sorry, you cannot edit this post.' ) );
}
$attachment = array(
'post_title' => $name,
'post_content' => '',