Make WordPress Core

Ticket #58392: 58392.2.diff

File 58392.2.diff, 3.1 KB (added by SergeyBiryukov, 6 months ago)
  • src/wp-includes/post.php

     
    35733573                return false;
    35743574        }
    35753575
     3576        $previous_status = $post->post_status;
     3577
    35763578        /**
    35773579         * Filters whether a post trashing should take place.
    35783580         *
    35793581         * @since 4.9.0
     3582         * @since 6.3.0 Added the `$previous_status` parameter.
    35803583         *
    3581          * @param bool|null $trash Whether to go forward with trashing.
    3582          * @param WP_Post   $post  Post object.
     3584         * @param bool|null $trash           Whether to go forward with trashing.
     3585         * @param WP_Post   $post            Post object.
     3586         * @param string    $previous_status The status of the post about to be trashed.
    35833587         */
    3584         $check = apply_filters( 'pre_trash_post', null, $post );
     3588        $check = apply_filters( 'pre_trash_post', null, $post, $previous_status );
    35853589
    35863590        if ( null !== $check ) {
    35873591                return $check;
     
    35913595         * Fires before a post is sent to the Trash.
    35923596         *
    35933597         * @since 3.3.0
     3598         * @since 6.3.0 Added the `$previous_status` parameter.
    35943599         *
    3595          * @param int $post_id Post ID.
     3600         * @param int    $post_id         Post ID.
     3601         * @param string $previous_status The status of the post about to be trashed.
    35963602         */
    3597         do_action( 'wp_trash_post', $post_id );
     3603        do_action( 'wp_trash_post', $post_id, $previous_status );
    35983604
    3599         add_post_meta( $post_id, '_wp_trash_meta_status', $post->post_status );
     3605        add_post_meta( $post_id, '_wp_trash_meta_status', $previous_status );
    36003606        add_post_meta( $post_id, '_wp_trash_meta_time', time() );
    36013607
    36023608        $post_updated = wp_update_post(
     
    36163622         * Fires after a post is sent to the Trash.
    36173623         *
    36183624         * @since 2.9.0
     3625         * @since 6.3.0 Added the `$previous_status` parameter.
    36193626         *
    3620          * @param int $post_id Post ID.
     3627         * @param int    $post_id         Post ID.
     3628         * @param string $previous_status The status of the post at the point where it was trashed.
    36213629         */
    3622         do_action( 'trashed_post', $post_id );
     3630        do_action( 'trashed_post', $post_id, $previous_status );
    36233631
    36243632        return $post;
    36253633}
     
    36533661         * Filters whether a post untrashing should take place.
    36543662         *
    36553663         * @since 4.9.0
    3656          * @since 5.6.0 The `$previous_status` parameter was added.
     3664         * @since 5.6.0 Added the `$previous_status` parameter.
    36573665         *
    36583666         * @param bool|null $untrash         Whether to go forward with untrashing.
    36593667         * @param WP_Post   $post            Post object.
     
    36683676         * Fires before a post is restored from the Trash.
    36693677         *
    36703678         * @since 2.9.0
    3671          * @since 5.6.0 The `$previous_status` parameter was added.
     3679         * @since 5.6.0 Added the `$previous_status` parameter.
    36723680         *
    36733681         * @param int    $post_id         Post ID.
    36743682         * @param string $previous_status The status of the post at the point where it was trashed.
     
    37143722         * Fires after a post is restored from the Trash.
    37153723         *
    37163724         * @since 2.9.0
    3717          * @since 5.6.0 The `$previous_status` parameter was added.
     3725         * @since 5.6.0 Added the `$previous_status` parameter.
    37183726         *
    37193727         * @param int    $post_id         Post ID.
    37203728         * @param string $previous_status The status of the post at the point where it was trashed.