WP_REST_Global_Styles_Controller::update_item( WP_REST_Request $request ): WP_REST_Response|WP_Error

In this article

Updates a single global style config.

Parameters

$requestWP_REST_Requestrequired
Full details about the request.

Return

WP_REST_Response|WP_Error Response object on success, or WP_Error object on failure.

Source

		$config['styles'] = $existing_config['styles'];
	}

	// Register theme-defined variations e.g. from block style variation partials under `/styles`.
	$variations = WP_Theme_JSON_Resolver::get_style_variations( 'block' );
	wp_register_block_style_variations_from_theme_json_partials( $variations );

	if ( isset( $request['settings'] ) ) {
		$config['settings'] = $request['settings'];
	} elseif ( isset( $existing_config['settings'] ) ) {
		$config['settings'] = $existing_config['settings'];
	}
	$config['isGlobalStylesUserThemeJSON'] = true;
	$config['version']                     = WP_Theme_JSON::LATEST_SCHEMA;
	/**
	 * JSON encode the data stored in post content.
	 * Escape characters that are likely to be mangled by HTML filters: "<>&".
	 *
	 * This data is later re-encoded by wp_filter_global_styles_post().
	 * The escaping is also applied here as a precaution.
	 */
	$changes->post_content = wp_json_encode( $config, JSON_UNESCAPED_SLASHES | JSON_HEX_TAG | JSON_HEX_AMP );
}

// Post title.
if ( isset( $request['title'] ) ) {
	if ( is_string( $request['title'] ) ) {
		$changes->post_title = $request['title'];

Changelog

VersionDescription
5.9.0Introduced.

User Contributed Notes

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