Disallow changing the post type in mw_editPost(). see #18429

git-svn-id: https://develop.svn.wordpress.org/trunk@19914 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Ryan Boren 2012-02-13 21:01:55 +00:00
parent aeff5194b5
commit 362ef00fc4
1 changed files with 11 additions and 0 deletions

View File

@ -3168,6 +3168,14 @@ class wp_xmlrpc_server extends IXR_Server {
if ( ! current_user_can( 'edit_post', $post_ID ) )
return new IXR_Error( 401, __( 'Sorry, you do not have the right to edit this post.' ) );
// Use wp.editPost to edit post types other than post and page.
if ( ! in_array( $postdata[ 'post_type' ], array( 'post', 'page' ) ) )
return new IXR_Error( 401, __( 'Invalid post type.' ) );
// Thwart attempt to change the post type.
if ( ! empty( $content_struct[ 'post_type' ] ) && ( $content_struct['post_type'] != $postdata[ 'post_type' ] ) )
return new IXR_Error( 401, __( 'The post type may not be changed.' ) );
// Check for a valid post format if one was given
if ( isset( $content_struct['wp_post_format'] ) ) {
$content_struct['wp_post_format'] = sanitize_key( $content_struct['wp_post_format'] );
@ -3197,6 +3205,9 @@ class wp_xmlrpc_server extends IXR_Server {
if ( isset($content_struct['wp_page_order']) )
$menu_order = $content_struct['wp_page_order'];
if ( ! empty( $content_struct['wp_page_template'] ) && 'page' == $post_type )
$page_template = $content_struct['wp_page_template'];
$post_author = $postdata['post_author'];
// Only set the post_author if one is set.