WP_REST_Global_Styles_Revisions_Controller::get_decoded_global_styles_json()protectedWP 6.3.0

Returns decoded JSON from post content string, or a 404 if not found.

Method of the class: WP_REST_Global_Styles_Revisions_Controller{}

No Hooks.

Return

Array|WP_Error.

Usage

// protected - for code of main (parent) or child class
$result = $this->get_decoded_global_styles_json( $raw_json );
$raw_json(string) (required)
Encoded JSON from global styles custom post content.

Changelog

Since 6.3.0 Introduced.

WP_REST_Global_Styles_Revisions_Controller::get_decoded_global_styles_json() code WP 6.7.1

protected function get_decoded_global_styles_json( $raw_json ) {
	$decoded_json = json_decode( $raw_json, true );

	if ( is_array( $decoded_json ) && isset( $decoded_json['isGlobalStylesUserThemeJSON'] ) && true === $decoded_json['isGlobalStylesUserThemeJSON'] ) {
		return $decoded_json;
	}

	return new WP_Error(
		'rest_global_styles_not_found',
		__( 'Cannot find user global styles revisions.' ),
		array( 'status' => 404 )
	);
}