rest_(post_type)_trashable хук-фильтрWP 4.7.0

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.

Использование

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.

Список изменений

С версии 4.7.0 Введена.

Где вызывается хук

WP_REST_Posts_Controller::delete_item()
rest_(post_type)_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 );

Где используется хук в WordPress

Использование не найдено.