wppaste
WordPress

apply_filters( 'pre_delete_attachment', WP_Post|false|null $delete, WP_Post $post, bool $force_delete )

Since
5.5.0
Filters whether an attachment deletion should take place.

Compatibility

WordPress
since 5.5.0
  • 6.7.7
  • 6.8.8
  • 6.9.7
  • 7.0.4
  • 7.1.0

Present in every tracked release (6.7.7 to 7.1.0).

Parameters

$deleteWP_Post|false|null
Whether to go forward with deletion.
$postWP_Post
Post object.
$force_deletebool
Whether to bypass the Trash.

Where this hook fires · 1

  • wp-includes/post.php:6842wp_delete_attachment()

Source code

	 * @since 5.5.0	 *	 * @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.	 */	$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' );

Changelog

Introduced in 5.5.0. Unchanged from 6.7.7 through 7.1.0.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 7.1.0

Signature, return type and hooks compared across 5 parsed releases.

About this page

Parsed data
Generated from the wordpress-develop 7.1.0 tag, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
Corrections
Something wrong on this page? Report it and it gets fixed in the next regeneration.