wp_transition_post_status example

do_action( 'wp_trash_post', $post_id );

        add_post_meta( $post_id, '_wp_trash_meta_status', $post->post_status );
        add_post_meta( $post_id, '_wp_trash_meta_time', time() );

        $old_status = $post->post_status;
        $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$old_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 */
        
if ( $wp_error ) {
                return new WP_Error( 'invalid_page_template', __( 'Invalid page template.' ) );
            }

            update_post_meta( $post_id, '_wp_page_template', 'default' );
        } else {
            update_post_meta( $post_id, '_wp_page_template', $postarr['page_template'] );
        }
    }

    if ( 'attachment' !== $postarr['post_type'] ) {
        wp_transition_post_status( $data['post_status']$previous_status$post );
    } else {
        if ( $update ) {
            /** * Fires once an existing attachment has been updated. * * @since 2.0.0 * * @param int $post_id Attachment ID. */
            do_action( 'edit_attachment', $post_id );

            
Home | Imprint | This part of the site doesn't use cookies.