WordPress at Your Fingertips
function is not described

WP_Customize_Manager::get_changeset_post_data() protected WP 4.7.0

Get the data stored in a changeset post.

{} It's a method of the class: WP_Customize_Manager{}

No Hooks.

Return

Array|WP_Error. Changeset data or WP_Error on error.

Usage

// protected - for code of main (parent) or child class
$result = $this->get_changeset_post_data( $post_id );
$post_id(int) (required)
Changeset post ID.

Changelog

Since 4.7.0 Introduced.

Code of WP_Customize_Manager::get_changeset_post_data() WP 5.8.1

protected function get_changeset_post_data( $post_id ) {
	if ( ! $post_id ) {
		return new WP_Error( 'empty_post_id' );
	}
	$changeset_post = get_post( $post_id );
	if ( ! $changeset_post ) {
		return new WP_Error( 'missing_post' );
	}
	if ( 'revision' === $changeset_post->post_type ) {
		if ( 'customize_changeset' !== get_post_type( $changeset_post->post_parent ) ) {
			return new WP_Error( 'wrong_post_type' );
		}
	} elseif ( 'customize_changeset' !== $changeset_post->post_type ) {
		return new WP_Error( 'wrong_post_type' );
	}
	$changeset_data = json_decode( $changeset_post->post_content, true );
	$last_error     = json_last_error();
	if ( $last_error ) {
		return new WP_Error( 'json_parse_error', '', $last_error );
	}
	if ( ! is_array( $changeset_data ) ) {
		return new WP_Error( 'expected_array' );
	}
	return $changeset_data;
}