wppaste
WordPress

WP_Customize_Manager::trash_changeset_post( int|WP_Post $post ): mixed

Since
4.9.0
Source
wp-includes/class-wp-customize-manager.php:3069
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:

  1. apply_filters( pre_trash_post )filterline 3090 (+21 into the body)

    Filters whether a post trashing should take place.

  2. do_action( wp_trash_post )actionline 3096 (+27 into the body)

    Fires before a post is sent to the Trash.

  3. do_action( edit_post_{$post->post_type} )actionline 3109 (+40 into the body)

    Fires once an existing post has been updated.

  4. do_action( edit_post )actionline 3112 (+43 into the body)

    Fires once an existing post has been updated.

  5. do_action( save_post_{$post->post_type} )actionline 3115 (+46 into the body)

    Fires once a post has been saved.

  6. do_action( save_post )actionline 3118 (+49 into the body)

    Fires once a post has been saved.

  7. do_action( wp_insert_post )actionline 3121 (+52 into the body)

    Fires once a post has been saved.

  8. do_action( trashed_post )actionline 3128 (+59 into the body)

    Fires after a post is sent to the Trash.

Uses · 10

Used by · 1

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.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 7.1.0

Signature, return type and hooks compared across 5 parsed releases.

About this page

Parsed data
Generated from the wordpress-develop 6.8.8 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.