pre_trash_post хук-фильтрWP 4.9.0

Filters whether a post trashing should take place.

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

add_filter( 'pre_trash_post', 'wp_kama_pre_trash_post_filter', 10, 3 );

/**
 * Function for `pre_trash_post` filter-hook.
 * 
 * @param bool|null $trash           Whether to go forward with trashing.
 * @param WP_Post   $post            Post object.
 * @param string    $previous_status The status of the post about to be trashed.
 *
 * @return bool|null
 */
function wp_kama_pre_trash_post_filter( $trash, $post, $previous_status ){

	// filter...
	return $trash;
}
$trash(true|false|null)
Whether to go forward with trashing.
$post(WP_Post)
Post object.
$previous_status(строка)
The status of the post about to be trashed.

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

С версии 4.9.0 Введена.
С версии 6.3.0 Added the $previous_status parameter.

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

wp_trash_post()
pre_trash_post
WP_Customize_Manager::trash_changeset_post()
pre_trash_post
wp-includes/post.php 3679
$check = apply_filters( 'pre_trash_post', null, $post, $previous_status );
wp-includes/class-wp-customize-manager.php 3085
$check = apply_filters( 'pre_trash_post', null, $post, $previous_status );

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

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