rest_post_trashable filter-hookWP 4.7.0

Filters whether a post is trashable.

Pass false to disable Trash support for the post.

This is one of the variants of the dynamic hook rest_(post_type)_trashable

Usage

add_filter( 'rest_post_trashable', 'wp_kama_rest_post_trashable_filter', 10, 2 );

/**
 * Function for `rest_post_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_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

WP_REST_Posts_Controller::delete_item()
rest_post_trashable
wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php 1023
$supports_trash = apply_filters( "rest_{$this->post_type}_trashable", $supports_trash, $post );

Where the hook is used in WordPress

Usage not found.