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. git-svn-id: https://develop.svn.wordpress.org/trunk@41638 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
58140009e5
commit
fa754724e1
|
@ -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.
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue