GC_Customize_Manager::trash_changeset_post()
最后更新于:2021-11-27 02:34:46
GC_Customize_Manager::trash_changeset_post( int|GC_Post$post)Trash or delete a changeset post.
参数
- $post
-
(int|GC_Post) (Required) The changeset post.
响应
(mixed) A GC_Post object for the trashed post or an empty value on failure.
源文件
文件: gc-includes/class-gc-customize-manager.php
public function trash_changeset_post( $post ) {
global $gcdb;
$post = get_post( $post );
if ( ! ( $post instanceof GC_Post ) ) {
return $post;
}
$post_id = $post->ID;
if ( ! EMPTY_TRASH_DAYS ) {
return gc_delete_post( $post_id, true );
}
if ( 'trash' === get_post_status( $post ) ) {
return false;
}
/** This filter is documented in gc-includes/post.php */
$check = apply_filters( 'pre_trash_post', null, $post );
if ( null !== $check ) {
return $check;
}
/** This action is documented in gc-includes/post.php */
do_action( 'gc_trash_post', $post_id );
add_post_meta( $post_id, '_gc_trash_meta_status', $post->post_status );
add_post_meta( $post_id, '_gc_trash_meta_time', time() );
$old_status = $post->post_status;
$new_status = 'trash';
$gcdb->update( $gcdb->posts, array( 'post_status' => $new_status ), array( 'ID' => $post->ID ) );
clean_post_cache( $post->ID );
$post->post_status = $new_status;
gc_transition_post_status( $new_status, $old_status, $post );
/** This action is documented in gc-includes/post.php */
do_action( "edit_post_{$post->post_type}", $post->ID, $post );
/** This action is documented in gc-includes/post.php */
do_action( 'edit_post', $post->ID, $post );
/** This action is documented in gc-includes/post.php */
do_action( "save_post_{$post->post_type}", $post->ID, $post, true );
/** This action is documented in gc-includes/post.php */
do_action( 'save_post', $post->ID, $post, true );
/** This action is documented in gc-includes/post.php */
do_action( 'gc_insert_post', $post->ID, $post, true );
gc_after_insert_post( get_post( $post_id ), true, $post );
gc_trash_post_comments( $post_id );
/** This action is documented in gc-includes/post.php */
do_action( 'trashed_post', $post_id );
return $post;
}