pre_trash_post
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. |
Где вызывается хук
pre_trash_post
wp-includes/post.php 4035
$check = apply_filters( 'pre_trash_post', null, $post, $previous_status );
wp-includes/class-wp-customize-manager.php 3091
$check = apply_filters( 'pre_trash_post', null, $post, $previous_status );