Action hook 'trashed_post'

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

View Source

trashed_post

Action 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 Action
Line Number 3128

Hook Parameters

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

Usage Examples

Basic Usage
<?php
// Hook into trashed_post
add_action('trashed_post', 'my_custom_function', 10, 1);

function my_custom_function($post) {
    // Your custom code here
}

Source Code Context

wp-includes/class-wp-customize-manager.php:3128 - How this hook is used in WordPress core
<?php
3123  		wp_after_insert_post( get_post( $post_id ), true, $post );
3124  
3125  		wp_trash_post_comments( $post_id );
3126  
3127  		/** This action is documented in wp-includes/post.php */
3128  		do_action( 'trashed_post', $post_id, $previous_status );
3129  
3130  		return $post;
3131  	}
3132  
3133  	/**

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: Action
  • Parameters: 1
  • File: wp-includes/class-wp-customize-manager.php
Related Hooks

Related hooks will be displayed here in future updates.