mirror of
https://github.com/WordPress/WordPress.git
synced 2025-02-23 07:51:49 +01:00
REST API: Use term-specific caps for permission checks in term update and delete endpoints.
See #38505. Built from https://develop.svn.wordpress.org/trunk@38960 git-svn-id: http://core.svn.wordpress.org/trunk@38903 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
919f08fd2d
commit
91b518a716
@ -451,8 +451,7 @@ class WP_REST_Terms_Controller extends WP_REST_Controller {
|
|||||||
return new WP_Error( 'rest_term_invalid', __( "Resource doesn't exist." ), array( 'status' => 404 ) );
|
return new WP_Error( 'rest_term_invalid', __( "Resource doesn't exist." ), array( 'status' => 404 ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
$taxonomy_obj = get_taxonomy( $this->taxonomy );
|
if ( ! current_user_can( 'edit_term', $term->term_id ) ) {
|
||||||
if ( ! current_user_can( $taxonomy_obj->cap->edit_terms ) ) {
|
|
||||||
return new WP_Error( 'rest_cannot_update', __( 'Sorry, you cannot update resource.' ), array( 'status' => rest_authorization_required_code() ) );
|
return new WP_Error( 'rest_cannot_update', __( 'Sorry, you cannot update resource.' ), array( 'status' => rest_authorization_required_code() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -527,8 +526,8 @@ class WP_REST_Terms_Controller extends WP_REST_Controller {
|
|||||||
if ( ! $term ) {
|
if ( ! $term ) {
|
||||||
return new WP_Error( 'rest_term_invalid', __( "Resource doesn't exist." ), array( 'status' => 404 ) );
|
return new WP_Error( 'rest_term_invalid', __( "Resource doesn't exist." ), array( 'status' => 404 ) );
|
||||||
}
|
}
|
||||||
$taxonomy_obj = get_taxonomy( $this->taxonomy );
|
|
||||||
if ( ! current_user_can( $taxonomy_obj->cap->delete_terms ) ) {
|
if ( ! current_user_can( 'delete_term', $term->term_id ) ) {
|
||||||
return new WP_Error( 'rest_cannot_delete', __( 'Sorry, you cannot delete resource.' ), array( 'status' => rest_authorization_required_code() ) );
|
return new WP_Error( 'rest_cannot_delete', __( 'Sorry, you cannot delete resource.' ), array( 'status' => rest_authorization_required_code() ) );
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '4.7-alpha-38959';
|
$wp_version = '4.7-alpha-38960';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
Loading…
Reference in New Issue
Block a user