Posts, Post Types: Introduce `pre_trash_post` and `pre_untrash_post` filters to allow for short-circuiting `wp_trash_post()` and `wp_untrash_post()`.

This brings parity with `pre_delete_post` filter in `wp_delete_post()`, introduced in [34082].

Props bor0.
Fixes #42030.
Built from https://develop.svn.wordpress.org/trunk@41638


git-svn-id: http://core.svn.wordpress.org/trunk@41472 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2017-09-29 10:19:49 +00:00
parent 32b555d0a7
commit 70925e6741
2 changed files with 27 additions and 1 deletions

View File

@ -2595,6 +2595,19 @@ function wp_trash_post( $post_id = 0 ) {
if ( $post['post_status'] == 'trash' )
return false;
/**
* Filters whether a post trashing should take place.
*
* @since 4.9.0
*
* @param bool $trash Whether to go forward with trashing.
* @param WP_Post $post Post object.
*/
$check = apply_filters( 'pre_trash_post', null, $post );
if ( null !== $check ) {
return $check;
}
/**
* Fires before a post is sent to the trash.
*
@ -2639,6 +2652,19 @@ function wp_untrash_post( $post_id = 0 ) {
if ( $post['post_status'] != 'trash' )
return false;
/**
* Filters whether a post untrashing should take place.
*
* @since 4.9.0
*
* @param bool $untrash Whether to go forward with untrashing.
* @param WP_Post $post Post object.
*/
$check = apply_filters( 'pre_untrash_post', null, $post );
if ( null !== $check ) {
return $check;
}
/**
* Fires before a post is restored from the trash.
*

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.9-alpha-41636';
$wp_version = '4.9-alpha-41638';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.