REST API: Check read permissions on posts when viewing comments.

With a few tests for getting / creating comments to reflect core behaviour.

Props timmyc.
Built from https://develop.svn.wordpress.org/trunk@39295


git-svn-id: http://core.svn.wordpress.org/trunk@39235 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Joe Hoyle 2016-11-18 19:07:30 +00:00
parent bbdf00c95c
commit 81c5b03029
2 changed files with 6 additions and 1 deletions

View File

@ -1454,6 +1454,11 @@ class WP_REST_Comments_Controller extends WP_REST_Controller {
*/
protected function check_read_post_permission( $post ) {
$posts_controller = new WP_REST_Posts_Controller( $post->post_type );
$post_type = get_post_type_object( $post->post_type );
if ( post_password_required( $post ) ) {
return current_user_can( $post_type->cap->edit_post, $post->ID );
}
return $posts_controller->check_read_permission( $post );
}

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.7-beta4-39294';
$wp_version = '4.7-beta4-39295';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.