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
This commit is contained in:
Scott Taylor 2015-09-12 15:59:24 +00:00
parent 891b76e034
commit 5a21742a6f
2 changed files with 15 additions and 1 deletions

View File

@ -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().
*

View File

@ -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.