Changeset 39257
- Timestamp:
- 11/15/2016 10:22:33 PM (7 years ago)
- Location:
- trunk/src/wp-includes/rest-api/endpoints
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php
r39252 r39257 112 112 return new WP_Error( 'rest_cannot_read_post', __( 'Sorry, you cannot read the post for this comment.' ), array( 'status' => rest_authorization_required_code() ) ); 113 113 } elseif ( 0 === $post_id && ! current_user_can( 'moderate_comments' ) ) { 114 return new WP_Error( 'rest_cannot_read', __( 'Sorry, you cannotread 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() ) ); 115 115 } 116 116 } … … 118 118 119 119 if ( ! empty( $request['context'] ) && 'edit' === $request['context'] && ! current_user_can( 'moderate_comments' ) ) { 120 return new WP_Error( 'rest_forbidden_context', __( 'Sorry, you cannotview 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() ) ); 121 121 } 122 122 … … 312 312 313 313 if ( ! $this->check_read_permission( $comment ) ) { 314 return new WP_Error( 'rest_cannot_read', __( 'Sorry, you cannotread 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() ) ); 315 315 } 316 316 … … 318 318 319 319 if ( $post && ! $this->check_read_post_permission( $post ) ) { 320 return new WP_Error( 'rest_cannot_read_post', __( 'Sorry, you cannotread 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() ) ); 321 321 } 322 322 323 323 if ( ! empty( $request['context'] ) && 'edit' === $request['context'] && ! current_user_can( 'moderate_comments' ) ) { 324 return new WP_Error( 'rest_forbidden_context', __( 'Sorry, you cannotview 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() ) ); 325 325 } 326 326 … … 379 379 380 380 if ( isset( $request['karma'] ) && $request['karma'] > 0 && ! current_user_can( 'moderate_comments' ) ) { 381 return new WP_Error( 'rest_comment_invalid_karma', __( 'Sorry, you cannotset 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() ) ); 382 382 } 383 383 384 384 if ( isset( $request['status'] ) && ! current_user_can( 'moderate_comments' ) ) { 385 return new WP_Error( 'rest_comment_invalid_status', __( 'Sorry, you cannotset 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() ) ); 386 386 } 387 387 388 388 if ( empty( $request['post'] ) && ! current_user_can( 'moderate_comments' ) ) { 389 return new WP_Error( 'rest_comment_invalid_post_id', __( 'Sorry, you cannotcreate 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() ) ); 390 390 } 391 391 392 392 if ( ! empty( $request['post'] ) && $post = get_post( (int) $request['post'] ) ) { 393 393 if ( 'draft' === $post->post_status ) { 394 return new WP_Error( 'rest_comment_draft_post', __( 'Sorry, you cannotcreate 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 ) ); 395 395 } 396 396 397 397 if ( 'trash' === $post->post_status ) { 398 return new WP_Error( 'rest_comment_trash_post', __( 'Sorry, you cannotcreate 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 ) ); 399 399 } 400 400 -
trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-post-statuses-controller.php
r39106 r39257 79 79 } 80 80 } 81 return new WP_Error( 'rest_cannot_view', __( 'Sorry, you cannotview 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() ) ); 82 82 } 83 83 -
trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-post-types-controller.php
r39250 r39257 77 77 } 78 78 79 return new WP_Error( 'rest_cannot_view', __( 'Sorry, you cannotview 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() ) ); 80 80 } 81 81 -
trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-revisions-controller.php
r39161 r39257 124 124 $parent_post_type_obj = get_post_type_object( $parent->post_type ); 125 125 if ( ! current_user_can( $parent_post_type_obj->cap->edit_post, $parent->ID ) ) { 126 return new WP_Error( 'rest_cannot_read', __( 'Sorry, you cannotview 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() ) ); 127 127 } 128 128 -
trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-taxonomies-controller.php
r39250 r39257 82 82 } 83 83 } 84 return new WP_Error( 'rest_cannot_view', __( 'Sorry, you cannotview 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() ) ); 85 85 } 86 86 return true; -
trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-terms-controller.php
r39223 r39257 142 142 } 143 143 if ( 'edit' === $request['context'] && ! current_user_can( $tax_obj->cap->edit_terms ) ) { 144 return new WP_Error( 'rest_forbidden_context', __( 'Sorry, you cannotview 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() ) ); 145 145 } 146 146 return true; … … 303 303 } 304 304 if ( 'edit' === $request['context'] && ! current_user_can( $tax_obj->cap->edit_terms ) ) { 305 return new WP_Error( 'rest_forbidden_context', __( 'Sorry, you cannotview 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() ) ); 306 306 } 307 307 return true; … … 351 351 $taxonomy_obj = get_taxonomy( $this->taxonomy ); 352 352 if ( ! current_user_can( $taxonomy_obj->cap->manage_terms ) ) { 353 return new WP_Error( 'rest_cannot_create', __( 'Sorry, you cannotcreate 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() ) ); 354 354 } 355 355 … … 458 458 459 459 if ( ! current_user_can( 'edit_term', $term->term_id ) ) { 460 return new WP_Error( 'rest_cannot_update', __( 'Sorry, you cannotupdate 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() ) ); 461 461 } 462 462 … … 547 547 548 548 if ( ! current_user_can( 'delete_term', $term->term_id ) ) { 549 return new WP_Error( 'rest_cannot_delete', __( 'Sorry, you cannotdelete 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() ) ); 550 550 } 551 551 -
trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php
r39250 r39257 145 145 // Check if roles is specified in GET request and if user can list users. 146 146 if ( ! empty( $request['roles'] ) && ! current_user_can( 'list_users' ) ) { 147 return new WP_Error( 'rest_user_cannot_view', __( 'Sorry, you cannotfilter 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() ) ); 148 148 } 149 149 150 150 if ( 'edit' === $request['context'] && ! current_user_can( 'list_users' ) ) { 151 return new WP_Error( 'rest_forbidden_context', __( 'Sorry, you cannotview 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() ) ); 152 152 } 153 153 154 154 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 cannotorder 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() ) ); 156 156 } 157 157 … … 321 321 322 322 if ( 'edit' === $request['context'] && ! current_user_can( 'list_users' ) ) { 323 return new WP_Error( 'rest_user_cannot_view', __( 'Sorry, you cannotview 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() ) ); 324 324 } 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 cannotview 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() ) ); 326 326 } 327 327 … … 996 996 && ! $potential_role->has_cap( 'edit_users' ) 997 997 ) { 998 return new WP_Error( 'rest_user_invalid_role', __( ' You cannotgive 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() ) ); 999 999 } 1000 1000 … … 1006 1006 1007 1007 if ( empty( $editable_roles[ $role ] ) ) { 1008 return new WP_Error( 'rest_user_invalid_role', __( ' You cannotgive 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 ) ); 1009 1009 } 1010 1010 }
Note: See TracChangeset
for help on using the changeset viewer.