Make WordPress Core


Ignore:
Timestamp:
05/23/2020 03:22:53 PM (4 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-revisions-controller.php

    r47547 r47850  
    170170        }
    171171
    172         $parent_post_type_obj = get_post_type_object( $parent->post_type );
    173 
    174         if ( ! current_user_can( $parent_post_type_obj->cap->edit_post, $parent->ID ) ) {
     172        if ( ! current_user_can( 'edit_post', $parent->ID ) ) {
    175173            return new WP_Error(
    176174                'rest_cannot_read',
     
    410408        $parent_post_type = get_post_type_object( $parent->post_type );
    411409
    412         if ( ! current_user_can( $parent_post_type->cap->delete_post, $parent->ID ) ) {
     410        if ( ! current_user_can( 'delete_post', $parent->ID ) ) {
    413411            return new WP_Error(
    414412                'rest_cannot_delete',
     
    428426        }
    429427
    430         $post_type = get_post_type_object( 'revision' );
    431 
    432         if ( ! current_user_can( $post_type->cap->delete_post, $revision->ID ) ) {
     428        if ( ! current_user_can( 'delete_post', $revision->ID ) ) {
    433429            return new WP_Error(
    434430                'rest_cannot_delete',
Note: See TracChangeset for help on using the changeset viewer.