W3cubDocs

/WordPress

WP_Theme_JSON_Resolver::resolve_theme_file_uris( WP_Theme_JSON $theme_json ): WP_Theme_JSON

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

Parameters

$theme_jsonWP_Theme_JSONrequired
A theme json instance.

Return

WP_Theme_JSON Theme merged with resolved paths, if any found.

Source

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 = array(
		'version' => WP_Theme_JSON::LATEST_SCHEMA,
	);

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

	$theme_json->merge( new WP_Theme_JSON( $resolved_theme_json_data ) );

	return $theme_json;
}

Changelog

Version Description
6.6.0 Introduced.

© 2003–2024 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/wp_theme_json_resolver/resolve_theme_file_uris