WP_Customize_Manager::trash_changeset_post( int|WP_Post $post ): mixed
- Since
- 4.9.0
- Source
wp-includes/class-wp-customize-manager.php:3070
Trashes or deletes a changeset post.
Description
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.Parameters
$postint|WP_Post- The changeset post.
Return
mixed- A WP_Post object for the trashed post or an empty value on failure.
Hooks fired · 8
8 hooks fire while WP_Customize_Manager::trash_changeset_post() runs, in this order:
- apply_filters( pre_trash_post )filterline 3091 (+21 into the body)
Filters whether a post trashing should take place.
- do_action( wp_trash_post )actionline 3097 (+27 into the body)
Fires before a post is sent to the Trash.
- do_action( edit_post_{$post->post_type} )actionline 3110 (+40 into the body)
Fires once an existing post has been updated.
- do_action( edit_post )actionline 3113 (+43 into the body)
Fires once an existing post has been updated.
- do_action( save_post_{$post->post_type} )actionline 3116 (+46 into the body)
Fires once a post has been saved.
- do_action( trashed_post )actionline 3129 (+59 into the body)
Fires after a post is sent to the Trash.
Uses · 10
- get_post()Retrieves post data given a post ID or post object.
- wp_delete_post()Trashes or deletes a post or page.
- get_post_status()Retrieves the post status based on the post ID.
- apply_filters()Calls the callback functions that have been added to a filter hook.
- do_action()Calls the callback functions that have been added to an action hook.
- add_post_meta()Adds a meta field to the given post.
- clean_post_cache()Will clean the post in the cache.
- wp_transition_post_status()Fires actions related to the transitioning of a post's status.
- wp_after_insert_post()Fires actions after a post, its terms and meta data has been saved.
- wp_trash_post_comments()Moves comments for a post to the Trash.
Used by · 1
- WP_Customize_Manager::handle_changeset_trash_request()Handles request to trash a changeset.
Source
public function trash_changeset_post( $post ) { global $wpdb; $post = get_post( $post ); if ( ! ( $post instanceof WP_Post ) ) { return $post; } $post_id = $post->ID; if ( ! EMPTY_TRASH_DAYS ) { return wp_delete_post( $post_id, true ); } if ( 'trash' === get_post_status( $post ) ) { return false; } $previous_status = $post->post_status; /** This filter is documented in wp-includes/post.php */ $check = apply_filters( 'pre_trash_post', null, $post, $previous_status ); if ( null !== $check ) { return $check; } /** This action is documented in wp-includes/post.php */ do_action( 'wp_trash_post', $post_id, $previous_status ); add_post_meta( $post_id, '_wp_trash_meta_status', $previous_status ); add_post_meta( $post_id, '_wp_trash_meta_time', time() ); $new_status = 'trash'; $wpdb->update( $wpdb->posts, array( 'post_status' => $new_status ), array( 'ID' => $post->ID ) ); clean_post_cache( $post->ID ); $post->post_status = $new_status; wp_transition_post_status( $new_status, $previous_status, $post ); /** This action is documented in wp-includes/post.php */ do_action( "edit_post_{$post->post_type}", $post->ID, $post ); /** This action is documented in wp-includes/post.php */ do_action( 'edit_post', $post->ID, $post ); /** This action is documented in wp-includes/post.php */ do_action( "save_post_{$post->post_type}", $post->ID, $post, true ); /** This action is documented in wp-includes/post.php */ do_action( 'save_post', $post->ID, $post, true ); /** This action is documented in wp-includes/post.php */ do_action( 'wp_insert_post', $post->ID, $post, true ); wp_after_insert_post( get_post( $post_id ), true, $post ); wp_trash_post_comments( $post_id ); /** This action is documented in wp-includes/post.php */ do_action( 'trashed_post', $post_id, $previous_status ); return $post; }History
Introduced in 4.9.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
About this page
- Parsed data
- Generated from the wordpress-develop 7.0.4 tag, from
src/wp-includes/class-wp-customize-manager.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it. - Corrections
- Something wrong on this page? Report it and it gets fixed in the next regeneration.