pre_trash_post filter-hookWP 4.9.0

Filters whether a post trashing should take place.

Usage

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(string)
The status of the post about to be trashed.

Changelog

Since 4.9.0 Introduced.
Since 6.3.0 Added the $previous_status parameter.

Where the hook is called

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 );

Where the hook is used in WordPress

Usage not found.