diff --git a/wp-includes/class-wp-xmlrpc-server.php b/wp-includes/class-wp-xmlrpc-server.php index c34a6a5d28..d22bc5113d 100644 --- a/wp-includes/class-wp-xmlrpc-server.php +++ b/wp-includes/class-wp-xmlrpc-server.php @@ -3214,34 +3214,54 @@ class wp_xmlrpc_server extends IXR_Server { $password = $args[2]; $struct = isset( $args[3] ) ? $args[3] : array(); - if ( ! $user = $this->login($username, $password ) ) + if ( ! $user = $this->login( $username, $password ) ) { return $this->error; + } /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ do_action( 'xmlrpc_call', 'wp.getComments' ); - if ( isset( $struct['status'] ) ) + if ( isset( $struct['status'] ) ) { $status = $struct['status']; - else + } else { $status = ''; + } if ( ! current_user_can( 'moderate_comments' ) && 'approve' !== $status ) { return new IXR_Error( 401, __( 'Invalid comment status.' ) ); } $post_id = ''; - if ( isset($struct['post_id']) ) - $post_id = absint($struct['post_id']); + if ( isset( $struct['post_id'] ) ) { + $post_id = absint( $struct['post_id'] ); + } + + $post_type = ''; + if ( isset( $struct['post_type'] ) ) { + $post_type_object = get_post_type_object( $struct['post_type'] ); + if ( ! $post_type_object || ! post_type_supports( $post_type_object->name, 'comments' ) ) { + return new IXR_Error( 404, __( 'Invalid post type.' ) ); + } + $post_type = $struct['post_type']; + } $offset = 0; - if ( isset($struct['offset']) ) - $offset = absint($struct['offset']); + if ( isset( $struct['offset'] ) ) { + $offset = absint( $struct['offset'] ); + } $number = 10; - if ( isset($struct['number']) ) - $number = absint($struct['number']); + if ( isset( $struct['number'] ) ) { + $number = absint( $struct['number'] ); + } - $comments = get_comments( array( 'status' => $status, 'post_id' => $post_id, 'offset' => $offset, 'number' => $number ) ); + $comments = get_comments( array( + 'status' => $status, + 'post_id' => $post_id, + 'offset' => $offset, + 'number' => $number, + 'post_type' => $post_type, + ) ); $comments_struct = array(); if ( is_array( $comments ) ) { diff --git a/wp-includes/version.php b/wp-includes/version.php index 01c21c299f..6e5cd2c370 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.4-alpha-34574'; +$wp_version = '4.4-alpha-34575'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.