rest_(post_type)_trashable
Filters whether a post is trashable.
The dynamic portion of the hook name, $this->post_type, refers to the post type slug.
Possible hook names include:
Pass false to disable Trash support for the post.
Usage
add_filter( 'rest_(post_type)_trashable', 'wp_kama_rest_post_type_trashable_filter', 10, 2 );
/**
* Function for `rest_(post_type)_trashable` filter-hook.
*
* @param bool $supports_trash Whether the post type support trashing.
* @param WP_Post $post The Post object being considered for trashing support.
*
* @return bool
*/
function wp_kama_rest_post_type_trashable_filter( $supports_trash, $post ){
// filter...
return $supports_trash;
}
- $supports_trash(true|false)
- Whether the post type support trashing.
- $post(WP_Post)
- The Post object being considered for trashing support.
Changelog
| Since 4.7.0 | Introduced. |
Where the hook is called
rest_(post_type)_trashable
wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php 1115
$supports_trash = apply_filters( "rest_{$this->post_type}_trashable", $supports_trash, $post );