From 81c5b030290a94ef9b8130dad64c1c4eef3b6d79 Mon Sep 17 00:00:00 2001 From: Joe Hoyle Date: Fri, 18 Nov 2016 19:07:30 +0000 Subject: [PATCH] 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 --- .../rest-api/endpoints/class-wp-rest-comments-controller.php | 5 +++++ wp-includes/version.php | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php b/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php index 9582b72672..bfa3159bf1 100644 --- a/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php +++ b/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php @@ -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 ); } diff --git a/wp-includes/version.php b/wp-includes/version.php index ba383348cd..ec63ca0885 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -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.