Make WordPress Core


Ignore:
Timestamp:
05/23/2020 03:22:53 PM (5 years ago)
Author:
ocean90
Message:

Role/Capability: Use meta caps edit_post, read_post, and delete_post directly.

Rather than consulting the post type object, let map_meta_cap() handle that for us.

Props peterwilsoncc, ocean90.
Fixes #50128.
See #23226.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-blocks-controller.php

    r46823 r47850  
    2929     */
    3030    public function check_read_permission( $post ) {
    31         // Ensure that the user is logged in and has the read_blocks capability.
    32         $post_type = get_post_type_object( $post->post_type );
    33         if ( ! current_user_can( $post_type->cap->read_post, $post->ID ) ) {
     31        // By default the read_post capability is mapped to edit_posts.
     32        if ( ! current_user_can( 'read_post', $post->ID ) ) {
    3433            return false;
    3534        }
Note: See TracChangeset for help on using the changeset viewer.