mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-23 01:27:36 +01:00
Media: Introduce preflight filter to wp_delete_attachment()
.
Introduces the filter `pre_delete_attachment` to allow developers to prevent or modify the deletion of attachments. This improves consistency with `wp_delete_post()` and `wp_trash_post()`. Props joemcgill, peterwilsoncc. Fixes #49597. Built from https://develop.svn.wordpress.org/trunk@47448 git-svn-id: http://core.svn.wordpress.org/trunk@47235 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
9aa864f1a7
commit
a88ac4f003
@ -5620,6 +5620,20 @@ function wp_delete_attachment( $post_id, $force_delete = false ) {
|
||||
return wp_trash_post( $post_id );
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters whether an attachment deletion should take place.
|
||||
*
|
||||
* @since 5.5.0
|
||||
*
|
||||
* @param bool|null $delete Whether to go forward with deletion.
|
||||
* @param WP_Post $post Post object.
|
||||
* @param bool $force_delete Whether to bypass the Trash.
|
||||
*/
|
||||
$check = apply_filters( 'pre_delete_attachment', null, $post, $force_delete );
|
||||
if ( null !== $check ) {
|
||||
return $check;
|
||||
}
|
||||
|
||||
delete_post_meta( $post_id, '_wp_trash_meta_status' );
|
||||
delete_post_meta( $post_id, '_wp_trash_meta_time' );
|
||||
|
||||
|
@ -13,7 +13,7 @@
|
||||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '5.5-alpha-47444';
|
||||
$wp_version = '5.5-alpha-47448';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
Loading…
Reference in New Issue
Block a user