From 165bcc506d44fdddd53e8a0a7e07476889445176 Mon Sep 17 00:00:00 2001 From: Dominik Schilling Date: Tue, 14 Apr 2020 19:24:49 +0000 Subject: [PATCH] Posts, Post Types: Pass the post object to the `before_delete_post`, `delete_post`, `deleted_post`, and `after_delete_post` actions. Props jadpm. Fixes #30940. git-svn-id: https://develop.svn.wordpress.org/trunk@47582 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/post.php | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/src/wp-includes/post.php b/src/wp-includes/post.php index 47c5648ca6..2f547a4cf9 100644 --- a/src/wp-includes/post.php +++ b/src/wp-includes/post.php @@ -2996,12 +2996,14 @@ function wp_delete_post( $postid = 0, $force_delete = false ) { * Fires before a post is deleted, at the start of wp_delete_post(). * * @since 3.2.0 + * @since 5.5.0 Added the `$post` parameter. * * @see wp_delete_post() * - * @param int $postid Post ID. + * @param int $postid Post ID. + * @param WP_Post $post Post object. */ - do_action( 'before_delete_post', $postid ); + do_action( 'before_delete_post', $postid, $post ); delete_post_meta( $postid, '_wp_trash_meta_status' ); delete_post_meta( $postid, '_wp_trash_meta_time' ); @@ -3048,10 +3050,12 @@ function wp_delete_post( $postid = 0, $force_delete = false ) { * Fires immediately before a post is deleted from the database. * * @since 1.2.0 + * @since 5.5.0 Added the `$post` parameter. * - * @param int $postid Post ID. + * @param int $postid Post ID. + * @param WP_Post $post Post object. */ - do_action( 'delete_post', $postid ); + do_action( 'delete_post', $postid, $post ); $result = $wpdb->delete( $wpdb->posts, array( 'ID' => $postid ) ); if ( ! $result ) { return false; @@ -3061,10 +3065,12 @@ function wp_delete_post( $postid = 0, $force_delete = false ) { * Fires immediately after a post is deleted from the database. * * @since 2.2.0 + * @since 5.5.0 Added the `$post` parameter. * - * @param int $postid Post ID. + * @param int $postid Post ID. + * @param WP_Post $post Post object. */ - do_action( 'deleted_post', $postid ); + do_action( 'deleted_post', $postid, $post ); clean_post_cache( $post ); @@ -3080,12 +3086,14 @@ function wp_delete_post( $postid = 0, $force_delete = false ) { * Fires after a post is deleted, at the conclusion of wp_delete_post(). * * @since 3.2.0 + * @since 5.5.0 Added the `$post` parameter. * * @see wp_delete_post() * - * @param int $postid Post ID. + * @param int $postid Post ID. + * @param WP_Post $post Post object. */ - do_action( 'after_delete_post', $postid ); + do_action( 'after_delete_post', $postid, $post ); return $post; }