mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-05-19 02:34:40 +00:00
REST API: Check read permissions on posts when viewing comments.
With a few tests for getting / creating comments to reflect core behaviour. Props timmyc. git-svn-id: https://develop.svn.wordpress.org/trunk@39295 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -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 );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user