Code Duplication    Length = 12-14 lines in 2 locations

wp-includes/class-wp-xmlrpc-server.php 2 locations

@@ 4913-4924 (lines=12) @@
4910
4911
		// If an author id was provided then use it instead.
4912
		if ( isset( $content_struct['wp_author_id'] ) && ( $user->ID != $content_struct['wp_author_id'] ) ) {
4913
			switch ( $post_type ) {
4914
				case "post":
4915
					if ( !current_user_can( 'edit_others_posts' ) )
4916
						return new IXR_Error( 401, __( 'Sorry, you are not allowed to create posts as this user.' ) );
4917
					break;
4918
				case "page":
4919
					if ( !current_user_can( 'edit_others_pages' ) )
4920
						return new IXR_Error( 401, __( 'Sorry, you are not allowed to create pages as this user.' ) );
4921
					break;
4922
				default:
4923
					return new IXR_Error( 401, __( 'Invalid post type.' ) );
4924
			}
4925
			$author = get_userdata( $content_struct['wp_author_id'] );
4926
			if ( ! $author )
4927
				return new IXR_Error( 404, __( 'Invalid author ID.' ) );
@@ 5250-5263 (lines=14) @@
5247
		if ( isset( $content_struct['wp_author_id'] ) ) {
5248
			// Check permissions if attempting to switch author to or from another user.
5249
			if ( $user->ID != $content_struct['wp_author_id'] || $user->ID != $post_author ) {
5250
				switch ( $post_type ) {
5251
					case 'post':
5252
						if ( ! current_user_can( 'edit_others_posts' ) ) {
5253
							return new IXR_Error( 401, __( 'Sorry, you are not allowed to change the post author as this user.' ) );
5254
						}
5255
						break;
5256
					case 'page':
5257
						if ( ! current_user_can( 'edit_others_pages' ) ) {
5258
							return new IXR_Error( 401, __( 'Sorry, you are not allowed to change the page author as this user.' ) );
5259
						}
5260
						break;
5261
					default:
5262
						return new IXR_Error( 401, __( 'Invalid post type.' ) );
5263
				}
5264
				$post_author = $content_struct['wp_author_id'];
5265
			}
5266
		}