wphooks.info - pre_trash_post

pre_trash_post

(trunk - 5.0-alpha-42177)

*** New in trunk ***

The hook occurs in the following 2 files

wp-includes/post.php:
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
	}

	/**
	 * 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.
	 *
	 * @since 3.3.0
	 *
wp-includes/class-wp-customize-manager.php:
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
		if ( ! EMPTY_TRASH_DAYS ) {
			return wp_delete_post( $post_id, true );
		}

		if ( 'trash' === get_post_status( $post ) ) {
			return false;
		}

		/** This filter is documented in wp-includes/post.php */
		$check = apply_filters( 'pre_trash_post', null, $post );
		if ( null !== $check ) {
			return $check;
		}

		/** This action is documented in wp-includes/post.php */
		do_action( 'wp_trash_post', $post_id );

		add_post_meta( $post_id, '_wp_trash_meta_status', $post->post_status );
		add_post_meta( $post_id, '_wp_trash_meta_time', time() );