WordPress.org

Make WordPress Core

Ticket #38803: 38803.patch

File 38803.patch, 14.4 KB (added by ramiy, 4 years ago)
  • wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php

     
    111111                                if ( ! empty( $post_id ) && $post && ! $this->check_read_post_permission( $post ) ) {
    112112                                        return new WP_Error( 'rest_cannot_read_post', __( 'Sorry, you cannot read the post for this comment.' ), array( 'status' => rest_authorization_required_code() ) );
    113113                                } elseif ( 0 === $post_id && ! current_user_can( 'moderate_comments' ) ) {
    114                                         return new WP_Error( 'rest_cannot_read', __( 'Sorry, you cannot read comments without a post.' ), array( 'status' => rest_authorization_required_code() ) );
     114                                        return new WP_Error( 'rest_cannot_read', __( 'Sorry, you are not allowed to read comments without a post.' ), array( 'status' => rest_authorization_required_code() ) );
    115115                                }
    116116                        }
    117117                }
    118118
    119119                if ( ! empty( $request['context'] ) && 'edit' === $request['context'] && ! current_user_can( 'moderate_comments' ) ) {
    120                         return new WP_Error( 'rest_forbidden_context', __( 'Sorry, you cannot view comments with edit context.' ), array( 'status' => rest_authorization_required_code() ) );
     120                        return new WP_Error( 'rest_forbidden_context', __( 'Sorry, you are not allowed to view comments with edit context.' ), array( 'status' => rest_authorization_required_code() ) );
    121121                }
    122122
    123123                if ( ! current_user_can( 'edit_posts' ) ) {
     
    311311                }
    312312
    313313                if ( ! $this->check_read_permission( $comment ) ) {
    314                         return new WP_Error( 'rest_cannot_read', __( 'Sorry, you cannot read this comment.' ), array( 'status' => rest_authorization_required_code() ) );
     314                        return new WP_Error( 'rest_cannot_read', __( 'Sorry, you are not allowed to read this comment.' ), array( 'status' => rest_authorization_required_code() ) );
    315315                }
    316316
    317317                $post = get_post( $comment->comment_post_ID );
    318318
    319319                if ( $post && ! $this->check_read_post_permission( $post ) ) {
    320                         return new WP_Error( 'rest_cannot_read_post', __( 'Sorry, you cannot read the post for this comment.' ), array( 'status' => rest_authorization_required_code() ) );
     320                        return new WP_Error( 'rest_cannot_read_post', __( 'Sorry, you are not allowed to read the post for this comment.' ), array( 'status' => rest_authorization_required_code() ) );
    321321                }
    322322
    323323                if ( ! empty( $request['context'] ) && 'edit' === $request['context'] && ! current_user_can( 'moderate_comments' ) ) {
    324                         return new WP_Error( 'rest_forbidden_context', __( 'Sorry, you cannot view this comment with edit context.' ), array( 'status' => rest_authorization_required_code() ) );
     324                        return new WP_Error( 'rest_forbidden_context', __( 'Sorry, you are not allowed to view this comment with edit context.' ), array( 'status' => rest_authorization_required_code() ) );
    325325                }
    326326
    327327                return true;
     
    378378                }
    379379
    380380                if ( isset( $request['karma'] ) && $request['karma'] > 0 && ! current_user_can( 'moderate_comments' ) ) {
    381                         return new WP_Error( 'rest_comment_invalid_karma', __( 'Sorry, you cannot set karma for comments.' ), array( 'status' => rest_authorization_required_code() ) );
     381                        return new WP_Error( 'rest_comment_invalid_karma', __( 'Sorry, you are not allowed to set karma for comments.' ), array( 'status' => rest_authorization_required_code() ) );
    382382                }
    383383
    384384                if ( isset( $request['status'] ) && ! current_user_can( 'moderate_comments' ) ) {
    385                         return new WP_Error( 'rest_comment_invalid_status', __( 'Sorry, you cannot set status for comments.' ), array( 'status' => rest_authorization_required_code() ) );
     385                        return new WP_Error( 'rest_comment_invalid_status', __( 'Sorry, you are not allowed to set status for comments.' ), array( 'status' => rest_authorization_required_code() ) );
    386386                }
    387387
    388388                if ( empty( $request['post'] ) && ! current_user_can( 'moderate_comments' ) ) {
    389                         return new WP_Error( 'rest_comment_invalid_post_id', __( 'Sorry, you cannot create this comment without a post.' ), array( 'status' => rest_authorization_required_code() ) );
     389                        return new WP_Error( 'rest_comment_invalid_post_id', __( 'Sorry, you are not allowed to create this comment without a post.' ), array( 'status' => rest_authorization_required_code() ) );
    390390                }
    391391
    392392                if ( ! empty( $request['post'] ) && $post = get_post( (int) $request['post'] ) ) {
    393393                        if ( 'draft' === $post->post_status ) {
    394                                 return new WP_Error( 'rest_comment_draft_post', __( 'Sorry, you cannot create a comment on this post.' ), array( 'status' => 403 ) );
     394                                return new WP_Error( 'rest_comment_draft_post', __( 'Sorry, you are not allowed to create a comment on this post.' ), array( 'status' => 403 ) );
    395395                        }
    396396
    397397                        if ( 'trash' === $post->post_status ) {
    398                                 return new WP_Error( 'rest_comment_trash_post', __( 'Sorry, you cannot create a comment on this post.' ), array( 'status' => 403 ) );
     398                                return new WP_Error( 'rest_comment_trash_post', __( 'Sorry, you are not allowed to create a comment on this post.' ), array( 'status' => 403 ) );
    399399                        }
    400400
    401401                        if ( ! $this->check_read_post_permission( $post ) ) {
  • wp-includes/rest-api/endpoints/class-wp-rest-post-statuses-controller.php

     
    7878                                        return true;
    7979                                }
    8080                        }
    81                         return new WP_Error( 'rest_cannot_view', __( 'Sorry, you cannot view this resource with edit context.' ), array( 'status' => rest_authorization_required_code() ) );
     81                        return new WP_Error( 'rest_cannot_view', __( 'Sorry, you are not allowed to view this resource with edit context.' ), array( 'status' => rest_authorization_required_code() ) );
    8282                }
    8383
    8484                return true;
  • wp-includes/rest-api/endpoints/class-wp-rest-post-types-controller.php

     
    7676                                }
    7777                        }
    7878
    79                         return new WP_Error( 'rest_cannot_view', __( 'Sorry, you cannot view this resource with edit context.' ), array( 'status' => rest_authorization_required_code() ) );
     79                        return new WP_Error( 'rest_cannot_view', __( 'Sorry, you are not allowed to view this resource with edit context.' ), array( 'status' => rest_authorization_required_code() ) );
    8080                }
    8181
    8282                return true;
  • wp-includes/rest-api/endpoints/class-wp-rest-revisions-controller.php

     
    123123                }
    124124                $parent_post_type_obj = get_post_type_object( $parent->post_type );
    125125                if ( ! current_user_can( $parent_post_type_obj->cap->edit_post, $parent->ID ) ) {
    126                         return new WP_Error( 'rest_cannot_read', __( 'Sorry, you cannot view revisions of this post.' ), array( 'status' => rest_authorization_required_code() ) );
     126                        return new WP_Error( 'rest_cannot_read', __( 'Sorry, you are not allowed to view revisions of this post.' ), array( 'status' => rest_authorization_required_code() ) );
    127127                }
    128128
    129129                return true;
  • wp-includes/rest-api/endpoints/class-wp-rest-taxonomies-controller.php

     
    8181                                        return true;
    8282                                }
    8383                        }
    84                         return new WP_Error( 'rest_cannot_view', __( 'Sorry, you cannot view this resource with edit context.' ), array( 'status' => rest_authorization_required_code() ) );
     84                        return new WP_Error( 'rest_cannot_view', __( 'Sorry, you are not allowed to view this resource with edit context.' ), array( 'status' => rest_authorization_required_code() ) );
    8585                }
    8686                return true;
    8787        }
  • wp-includes/rest-api/endpoints/class-wp-rest-terms-controller.php

     
    141141                        return false;
    142142                }
    143143                if ( 'edit' === $request['context'] && ! current_user_can( $tax_obj->cap->edit_terms ) ) {
    144                         return new WP_Error( 'rest_forbidden_context', __( 'Sorry, you cannot view this resource with edit context.' ), array( 'status' => rest_authorization_required_code() ) );
     144                        return new WP_Error( 'rest_forbidden_context', __( 'Sorry, you are not allowed to view this resource with edit context.' ), array( 'status' => rest_authorization_required_code() ) );
    145145                }
    146146                return true;
    147147        }
     
    302302                        return false;
    303303                }
    304304                if ( 'edit' === $request['context'] && ! current_user_can( $tax_obj->cap->edit_terms ) ) {
    305                         return new WP_Error( 'rest_forbidden_context', __( 'Sorry, you cannot view this resource with edit context.' ), array( 'status' => rest_authorization_required_code() ) );
     305                        return new WP_Error( 'rest_forbidden_context', __( 'Sorry, you are not allowed to view this resource with edit context.' ), array( 'status' => rest_authorization_required_code() ) );
    306306                }
    307307                return true;
    308308        }
     
    350350
    351351                $taxonomy_obj = get_taxonomy( $this->taxonomy );
    352352                if ( ! current_user_can( $taxonomy_obj->cap->manage_terms ) ) {
    353                         return new WP_Error( 'rest_cannot_create', __( 'Sorry, you cannot create new resource.' ), array( 'status' => rest_authorization_required_code() ) );
     353                        return new WP_Error( 'rest_cannot_create', __( 'Sorry, you are not allowed to create new resource.' ), array( 'status' => rest_authorization_required_code() ) );
    354354                }
    355355
    356356                return true;
     
    457457                }
    458458
    459459                if ( ! current_user_can( 'edit_term', $term->term_id ) ) {
    460                         return new WP_Error( 'rest_cannot_update', __( 'Sorry, you cannot update resource.' ), array( 'status' => rest_authorization_required_code() ) );
     460                        return new WP_Error( 'rest_cannot_update', __( 'Sorry, you are not allowed to update resource.' ), array( 'status' => rest_authorization_required_code() ) );
    461461                }
    462462
    463463                return true;
     
    546546                }
    547547
    548548                if ( ! current_user_can( 'delete_term', $term->term_id ) ) {
    549                         return new WP_Error( 'rest_cannot_delete', __( 'Sorry, you cannot delete resource.' ), array( 'status' => rest_authorization_required_code() ) );
     549                        return new WP_Error( 'rest_cannot_delete', __( 'Sorry, you are not allowed to delete resource.' ), array( 'status' => rest_authorization_required_code() ) );
    550550                }
    551551
    552552                return true;
  • wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php

     
    144144        public function get_items_permissions_check( $request ) {
    145145                // Check if roles is specified in GET request and if user can list users.
    146146                if ( ! empty( $request['roles'] ) && ! current_user_can( 'list_users' ) ) {
    147                         return new WP_Error( 'rest_user_cannot_view', __( 'Sorry, you cannot filter by role.' ), array( 'status' => rest_authorization_required_code() ) );
     147                        return new WP_Error( 'rest_user_cannot_view', __( 'Sorry, you are not allowed to filter by role.' ), array( 'status' => rest_authorization_required_code() ) );
    148148                }
    149149
    150150                if ( 'edit' === $request['context'] && ! current_user_can( 'list_users' ) ) {
    151                         return new WP_Error( 'rest_forbidden_context', __( 'Sorry, you cannot view this resource with edit context.' ), array( 'status' => rest_authorization_required_code() ) );
     151                        return new WP_Error( 'rest_forbidden_context', __( 'Sorry, you are not allowed to view this resource with edit context.' ), array( 'status' => rest_authorization_required_code() ) );
    152152                }
    153153
    154154                if ( in_array( $request['orderby'], array( 'email', 'registered_date' ), true ) && ! current_user_can( 'list_users' ) ) {
    155                         return new WP_Error( 'rest_forbidden_orderby', __( 'Sorry, you cannot order by this parameter.' ), array( 'status' => rest_authorization_required_code() ) );
     155                        return new WP_Error( 'rest_forbidden_orderby', __( 'Sorry, you are not allowed to order by this parameter.' ), array( 'status' => rest_authorization_required_code() ) );
    156156                }
    157157
    158158                return true;
     
    320320                }
    321321
    322322                if ( 'edit' === $request['context'] && ! current_user_can( 'list_users' ) ) {
    323                         return new WP_Error( 'rest_user_cannot_view', __( 'Sorry, you cannot view this resource with edit context.' ), array( 'status' => rest_authorization_required_code() ) );
     323                        return new WP_Error( 'rest_user_cannot_view', __( 'Sorry, you are not allowed to view this resource with edit context.' ), array( 'status' => rest_authorization_required_code() ) );
    324324                } elseif ( ! count_user_posts( $id, $types ) && ! current_user_can( 'edit_user', $id ) && ! current_user_can( 'list_users' ) ) {
    325                         return new WP_Error( 'rest_user_cannot_view', __( 'Sorry, you cannot view this resource.' ), array( 'status' => rest_authorization_required_code() ) );
     325                        return new WP_Error( 'rest_user_cannot_view', __( 'Sorry, you are not allowed to view this resource.' ), array( 'status' => rest_authorization_required_code() ) );
    326326                }
    327327
    328328                return true;
     
    995995                                && get_current_user_id() === $user_id
    996996                                && ! $potential_role->has_cap( 'edit_users' )
    997997                        ) {
    998                                 return new WP_Error( 'rest_user_invalid_role', __( 'You cannot give resource that role.' ), array( 'status' => rest_authorization_required_code() ) );
     998                                return new WP_Error( 'rest_user_invalid_role', __( 'Sorry, you are not allowed to give resource that role.' ), array( 'status' => rest_authorization_required_code() ) );
    999999                        }
    10001000
    10011001                        /** Include admin functions to get access to get_editable_roles() */
     
    10051005                        $editable_roles = get_editable_roles();
    10061006
    10071007                        if ( empty( $editable_roles[ $role ] ) ) {
    1008                                 return new WP_Error( 'rest_user_invalid_role', __( 'You cannot give resource that role.' ), array( 'status' => 403 ) );
     1008                                return new WP_Error( 'rest_user_invalid_role', __( 'Sorry, you are not allowed to give resource that role.' ), array( 'status' => 403 ) );
    10091009                        }
    10101010                }
    10111011