trash_changeset_post example

if ( 'trash' === get_post_status( $changeset_post_id ) ) {
            wp_send_json_error(
                array(
                    'message' => __( 'Changes have already been trashed.' ),
                    'code'    => 'changeset_already_trashed',
                )
            );
            return;
        }

        $r = $this->trash_changeset_post( $changeset_post_id );
        if ( ! ( $r instanceof WP_Post ) ) {
            wp_send_json_error(
                array(
                    'code'    => 'changeset_trash_failure',
                    'message' => __( 'Unable to trash changes.' ),
                )
            );
        }

        wp_send_json_success(
            array(
                
/* * Trash the changeset post if revisions are not enabled. Unpublished * changesets by default get garbage collected due to the auto-draft status. * When a changeset post is published, however, it would no longer get cleaned * out. This is a problem when the changeset posts are never displayed anywhere, * since they would just be endlessly piling up. So here we use the revisions * feature to indicate whether or not a published changeset should get trashed * and thus garbage collected. */
    if ( ! wp_revisions_enabled( $changeset_post ) ) {
        $wp_customize->trash_changeset_post( $changeset_post->ID );
    }
}

/** * Filters changeset post data upon insert to ensure post_name is intact. * * This is needed to prevent the post_name from being dropped when the post is * transitioned into pending status by a contributor. * * @since 4.7.0 * * @see wp_insert_post() * * @param array $post_data An array of slashed post data. * @param array $supplied_post_data An array of sanitized, but otherwise unmodified post data. * @return array Filtered data. */
Home | Imprint | This part of the site doesn't use cookies.