apply_filters( "rest_{$this->post_type}_trashable", bool $supports_trash, WP_Post $post )
- Since
- 4.7.0
Filters whether a post is trashable.
Description
The dynamic portion of the hook name, $this->post_type, refers to the post type slug.
Possible hook names include:
rest_post_trashablerest_page_trashablerest_attachment_trashable
Pass false to disable Trash support for the post.
Compatibility
- WordPress
- since 4.7.0
- 6.7.7
- 6.8.8
- 6.9.7
- 7.0.4
- 7.1.0
Present in every tracked release (6.7.7 to 7.1.0).
Parameters
$supports_trashbool- Whether the post type support trashing.
$postWP_Post- The Post object being considered for trashing support.
Where this hook fires · 1
wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php:1123WP_REST_Posts_Controller::delete_item()
Source code
* * @since 4.7.0 * * @param bool $supports_trash Whether the post type support trashing. * @param WP_Post $post The Post object being considered for trashing support. */ $supports_trash = apply_filters( "rest_{$this->post_type}_trashable", $supports_trash, $post ); if ( ! $this->check_delete_permission( $post ) ) { return new WP_Error( 'rest_user_cannot_delete_post', __( 'Sorry, you are not allowed to delete this post.' ), array( 'status' => rest_authorization_required_code() )Changelog
Introduced in 4.7.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
About this page
- Parsed data
- Generated from the wordpress-develop 7.1.0 tag, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
- Corrections
- Something wrong on this page? Report it and it gets fixed in the next regeneration.