diff --git a/src/wp-includes/post.php b/src/wp-includes/post.php index b5eff61a06..20feed2c40 100644 --- a/src/wp-includes/post.php +++ b/src/wp-includes/post.php @@ -5717,10 +5717,12 @@ function wp_delete_attachment( $post_id, $force_delete = false ) { * Fires before an attachment is deleted, at the start of wp_delete_attachment(). * * @since 2.0.0 + * @since 5.5.0 Added the `$post` parameter. * - * @param int $post_id Attachment ID. + * @param int $post_id Attachment ID. + * @param WP_Post $post Post object. */ - do_action( 'delete_attachment', $post_id ); + do_action( 'delete_attachment', $post_id, $post ); wp_delete_object_term_relationships( $post_id, array( 'category', 'post_tag' ) ); wp_delete_object_term_relationships( $post_id, get_object_taxonomies( $post->post_type ) ); @@ -5743,13 +5745,13 @@ function wp_delete_attachment( $post_id, $force_delete = false ) { } /** This action is documented in wp-includes/post.php */ - do_action( 'delete_post', $post_id ); + do_action( 'delete_post', $post_id, $post ); $result = $wpdb->delete( $wpdb->posts, array( 'ID' => $post_id ) ); if ( ! $result ) { return false; } /** This action is documented in wp-includes/post.php */ - do_action( 'deleted_post', $post_id ); + do_action( 'deleted_post', $post_id, $post ); wp_delete_attachment_files( $post_id, $meta, $backup_sizes, $file );