pre_delete_attachment
Filters whether an attachment deletion should take place.
Usage
add_filter( 'pre_delete_attachment', 'wp_kama_pre_delete_attachment_filter', 10, 3 ); /** * Function for `pre_delete_attachment` filter-hook. * * @param WP_Post|false|null $delete Whether to go forward with deletion. * @param WP_Post $post Post object. * @param bool $force_delete Whether to bypass the Trash. * * @return WP_Post|false|null */ function wp_kama_pre_delete_attachment_filter( $delete, $post, $force_delete ){ // filter... return $delete; }
- $delete(WP_Post|false|null)
- Whether to go forward with deletion.
- $post(WP_Post)
- Post object.
- $force_delete(true|false)
- Whether to bypass the Trash.
Changelog
Since 5.5.0 | Introduced. |
Where the hook is called
wp-includes/post.php 6577
$check = apply_filters( 'pre_delete_attachment', null, $post, $force_delete );