From 5a21742a6f75c958d34ee397c6c779a583c77178 Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Sat, 12 Sep 2015 15:59:24 +0000 Subject: [PATCH] `wp_delete_post()`: add a filter, 'pre_delete_post', to allow bailout from the function if the filter returns a non-null value. Props boonebgorges. Fixes #32933. Built from https://develop.svn.wordpress.org/trunk@34082 git-svn-id: http://core.svn.wordpress.org/trunk@34050 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/post-functions.php | 14 ++++++++++++++ wp-includes/version.php | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/wp-includes/post-functions.php b/wp-includes/post-functions.php index 7c0786239a..1d6ae6fc39 100644 --- a/wp-includes/post-functions.php +++ b/wp-includes/post-functions.php @@ -2317,6 +2317,20 @@ function wp_delete_post( $postid = 0, $force_delete = false ) { if ( $post->post_type == 'attachment' ) return wp_delete_attachment( $postid, $force_delete ); + /** + * Filter whether a post deletion should take place. + * + * @since 4.4.0 + * + * @param bool $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_post', null, $post, $force_delete ); + if ( null !== $check ) { + return $check; + } + /** * Fires before a post is deleted, at the start of wp_delete_post(). * diff --git a/wp-includes/version.php b/wp-includes/version.php index efb5ae670b..5cf73da0f5 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.4-alpha-34081'; +$wp_version = '4.4-alpha-34082'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.