WP_Theme_JSON_Resolver::resolve_theme_file_urispublic staticWP 6.6.0

Resolves relative paths in theme.json styles to theme absolute paths and merges them with incoming theme JSON.

Method of the class: WP_Theme_JSON_Resolver{}

No Hooks.

Returns

WP_Theme_JSON. Theme merged with resolved paths, if any found.

Usage

$result = WP_Theme_JSON_Resolver::resolve_theme_file_uris( $theme_json );
$theme_json(WP_Theme_JSON) (required)
A theme json instance.

Changelog

Since 6.6.0 Introduced.

WP_Theme_JSON_Resolver::resolve_theme_file_uris() code WP 7.0

public static function resolve_theme_file_uris( $theme_json ) {
	$resolved_urls = static::get_resolved_theme_uris( $theme_json );
	if ( empty( $resolved_urls ) ) {
		return $theme_json;
	}

	$resolved_theme_json_data = $theme_json->get_raw_data();

	foreach ( $resolved_urls as $resolved_url ) {
		$path = explode( '.', $resolved_url['target'] );
		_wp_array_set( $resolved_theme_json_data, $path, $resolved_url['href'] );
	}

	return new WP_Theme_JSON( $resolved_theme_json_data );
}