WP_Theme_JSON_Resolver::resolve_theme_file_uris( WP_Theme_JSON $theme_json ): WP_Theme_JSON

In this article

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

VersionDescription
6.6.0Introduced.

User Contributed Notes

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