Filter hook 'pre_trash_post'

in WP Core File wp-includes/class-wp-customize-manager.php at line 3090

View Source

pre_trash_post

Filter Hook
Description
Trashes or deletes a changeset post. The following re-formulates the logic from `wp_trash_post()` as done in `wp_publish_post()`. The reason for bypassing `wp_trash_post()` is that it will mutate the the `post_content` and the `post_name` when they should be untouched.

Hook Information

File Location wp-includes/class-wp-customize-manager.php View on GitHub
Hook Type Filter
Line Number 3090

Hook Parameters

Type Name Description
int|WP_Post $post The changeset post.

Usage Examples

Basic Usage
<?php
// Hook into pre_trash_post
add_filter('pre_trash_post', 'my_custom_filter', 10, 1);

function my_custom_filter($post) {
    // Your custom filtering logic here
    return $post;
}

Source Code Context

wp-includes/class-wp-customize-manager.php:3090 - How this hook is used in WordPress core
<?php
3085  		}
3086  
3087  		$previous_status = $post->post_status;
3088  
3089  		/** This filter is documented in wp-includes/post.php */
3090  		$check = apply_filters( 'pre_trash_post', null, $post, $previous_status );
3091  		if ( null !== $check ) {
3092  			return $check;
3093  		}
3094  
3095  		/** This action is documented in wp-includes/post.php */

PHP Documentation

<?php
/**
	 * Trashes or deletes a changeset post.
	 *
	 * The following re-formulates the logic from `wp_trash_post()` as done in
	 * `wp_publish_post()`. The reason for bypassing `wp_trash_post()` is that it
	 * will mutate the the `post_content` and the `post_name` when they should be
	 * untouched.
	 *
	 * @since 4.9.0
	 *
	 * @see wp_trash_post()
	 * @global wpdb $wpdb WordPress database abstraction object.
	 *
	 * @param int|WP_Post $post The changeset post.
	 * @return mixed A WP_Post object for the trashed post or an empty value on failure.
	 */
Quick Info
  • Hook Type: Filter
  • Parameters: 1
  • File: wp-includes/class-wp-customize-manager.php
Related Hooks

Related hooks will be displayed here in future updates.