From 5cb687dbce0a91e057fb3010dbdbd163e7863eb1 Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Tue, 19 Mar 2024 09:33:11 +0000 Subject: [PATCH] Posts, Post Types: Introduce `delete_post_{$post->post_type}` and `deleted_post_{$post->post_type}` hooks. The hooks fire before the general `delete_post` / `deleted_post` hooks and have the same parameters. They complement the `save_post_{$post->post_type}` hook added in [25050] and the `edit_post_{$post->post_type}` hook added in [43617]. Props benniledl, swissspidy, dargus. Fixes #60433. Built from https://develop.svn.wordpress.org/trunk@57853 git-svn-id: http://core.svn.wordpress.org/trunk@57354 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/post.php | 26 ++++++++++++++++++++++++++ wp-includes/version.php | 2 +- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/wp-includes/post.php b/wp-includes/post.php index 7645043a47..3ecadddd9d 100644 --- a/wp-includes/post.php +++ b/wp-includes/post.php @@ -3552,6 +3552,19 @@ function wp_delete_post( $postid = 0, $force_delete = false ) { delete_metadata_by_mid( 'post', $mid ); } + /** + * Fires immediately before a post is deleted from the database. + * + * The dynamic portion of the hook name, `$post->post_type`, refers to + * the post type slug. + * + * @since 6.6.0 + * + * @param int $postid Post ID. + * @param WP_Post $post Post object. + */ + do_action( "delete_post_{$post->post_type}", $postid, $post ); + /** * Fires immediately before a post is deleted from the database. * @@ -3568,6 +3581,19 @@ function wp_delete_post( $postid = 0, $force_delete = false ) { return false; } + /** + * Fires immediately after a post is deleted from the database. + * + * The dynamic portion of the hook name, `$post->post_type`, refers to + * the post type slug. + * + * @since 6.6.0 + * + * @param int $postid Post ID. + * @param WP_Post $post Post object. + */ + do_action( "deleted_post_{$post->post_type}", $postid, $post ); + /** * Fires immediately after a post is deleted from the database. * diff --git a/wp-includes/version.php b/wp-includes/version.php index d596832586..aefcbf053e 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.6-alpha-57851'; +$wp_version = '6.6-alpha-57853'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.