On this page
WP_REST_Posts_Controller::check_delete_permission( WP_Post $post ): bool
Checks if a post can be deleted.
Parameters
$postWP_Post Required-
Post object.
Return
bool Whether the post can be deleted.
Source
File: wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php. View all references
protected function check_delete_permission( $post ) {
$post_type = get_post_type_object( $post->post_type );
if ( ! $this->check_is_post_type_allowed( $post_type ) ) {
return false;
}
return current_user_can( 'delete_post', $post->ID );
}
Related
Uses
| Uses | Description |
|---|---|
| WP_REST_Posts_Controller::check_is_post_type_allowed() wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php | Checks if a given post type can be viewed or managed. |
| current_user_can() wp-includes/capabilities.php | Returns whether the current user has the specified capability. |
| get_post_type_object() wp-includes/post.php | Retrieves a post type object by name. |
Used By
| Used By | Description |
|---|---|
| WP_REST_Posts_Controller::delete_item_permissions_check() wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php | Checks if a given request has access to delete a post. |
| WP_REST_Posts_Controller::delete_item() wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php | Deletes a single post. |
Changelog
| Version | Description |
|---|---|
| 4.7.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/wp_rest_posts_controller/check_delete_permission