WP_REST_Global_Styles_Revisions_Controller::get_decoded_global_styles_json( string $raw_json ): Array|WP_Error

In this article

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

Parameters

$raw_jsonstringrequired
Encoded JSON from global styles custom post content.

Return

Array|WP_Error

Source

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 )
	);
}

Changelog

VersionDescription
6.3.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.