Make WordPress Core


Ignore:
Timestamp:
09/29/2017 10:18:11 AM (9 years ago)
Author:
SergeyBiryukov
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/post.php

    r41355 r41638  
    25972597
    25982598        /**
     2599         * Filters whether a post trashing should take place.
     2600         *
     2601         * @since 4.9.0
     2602         *
     2603         * @param bool    $trash Whether to go forward with trashing.
     2604         * @param WP_Post $post  Post object.
     2605         */
     2606        $check = apply_filters( 'pre_trash_post', null, $post );
     2607        if ( null !== $check ) {
     2608                return $check;
     2609        }
     2610
     2611        /**
    25992612         * Fires before a post is sent to the trash.
    26002613         *
    … …  
    26392652        if ( $post['post_status'] != 'trash' )
    26402653                return false;
     2654
     2655        /**
     2656         * Filters whether a post untrashing should take place.
     2657         *
     2658         * @since 4.9.0
     2659         *
     2660         * @param bool    $untrash Whether to go forward with untrashing.
     2661         * @param WP_Post $post    Post object.
     2662         */
     2663        $check = apply_filters( 'pre_untrash_post', null, $post );
     2664        if ( null !== $check ) {
     2665                return $check;
     2666        }
    26412667
    26422668        /**
Note: See TracChangeset for help on using the changeset viewer.