From ba5853e0f6b0a9c3565d6079a9ff6c795670e402 Mon Sep 17 00:00:00 2001 From: Andrew Nacin Date: Tue, 18 Sep 2012 19:06:27 +0000 Subject: [PATCH] Allow wp.uploadFile to upload the attachment to a post. props djzone, josephscott, maxcutler. fixes #13917. git-svn-id: https://develop.svn.wordpress.org/trunk@21896 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/class-wp-xmlrpc-server.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/wp-includes/class-wp-xmlrpc-server.php b/wp-includes/class-wp-xmlrpc-server.php index 1af45e6a12..f8d0428ea4 100644 --- a/wp-includes/class-wp-xmlrpc-server.php +++ b/wp-includes/class-wp-xmlrpc-server.php @@ -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' => '',