Make WordPress Core

Ticket #43701: 0001-Make-the-read_private-cap-accessible-over-the-REST-A.patch

File 0001-Make-the-read_private-cap-accessible-over-the-REST-A.patch, 1.3 KB (added by twoelevenjay, 6 years ago)

Amends /wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php line 2286 to allow reading of private post types when current user caps only allow reading the private post type but not editing it.

  • wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php

    From d96a87866d37912100ac27e6c55bc1a13b0eab4a Mon Sep 17 00:00:00 2001
    From: Leon Francis Shelhamer <leon@211j.com>
    Date: Thu, 5 Apr 2018 12:16:18 -0400
    Subject: [PATCH] =?UTF-8?q?Make=20the=20"read=5Fprivate=E2=80=9D=20cap=20a?=
     =?UTF-8?q?ccessible=20over=20the=20REST=20API?=
    MIME-Version: 1.0
    Content-Type: text/plain; charset=UTF-8
    Content-Transfer-Encoding: 8bit
    
    Signed-off-by: Leon Francis Shelhamer <leon@211j.com>
    ---
     wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php | 2 +-
     1 file changed, 1 insertion(+), 1 deletion(-)
    
    diff --git a/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php b/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php
    index 0661152de6..80c0f8d4d2 100644
    a b class WP_REST_Posts_Controller extends WP_REST_Controller { 
    22912291
    22922292                        $post_type_obj = get_post_type_object( $this->post_type );
    22932293
    2294                         if ( current_user_can( $post_type_obj->cap->edit_posts ) ) {
     2294                        if ( current_user_can( $post_type_obj->cap->edit_posts ) || current_user_can( $post_type_obj->cap->read_private_posts ) ) {
    22952295                                $result = rest_validate_request_arg( $status, $request, $parameter );
    22962296                                if ( is_wp_error( $result ) ) {
    22972297                                        return $result;