[wp-trac] [WordPress Trac] #61205: Add support for relative paths to theme assets in theme.json
WordPress Trac
noreply at wordpress.org
Mon May 13 06:39:14 UTC 2024
#61205: Add support for relative paths to theme assets in theme.json
-----------------------------+------------------------------
Reporter: ramonopoly | Owner: (none)
Type: feature request | Status: new
Priority: normal | Milestone: Awaiting Review
Component: REST API | Version:
Severity: normal | Resolution:
Keywords: | Focuses: rest-api
-----------------------------+------------------------------
Comment (by ramonopoly):
> Therefore, to keep things performant in the editor, I'm thinking it
would be useful to resolve the relative paths in PHP and send them to the
frontend as part of the Global styles REST API controllers:
In the [https://github.com/WordPress/gutenberg/pull/61271, proof of
concept] I've added the following to the responses:
{{{
"_links": {
"wp:theme-file-uris": [
{
"href": "http://resolve.uri/path/image.png",
"name": "path/image.png",
"path": [ "style", "blocks", "core/group", "background",
"backgroundImage" ]
},
]
}
}}}
"href" and "name" are HAL reserved attributes. "path" I added to represent
the path in the theme.json tree to the value that needs to be replaced.
However, some responses are collections of global styles objects. For
example `WP_REST_Global_Styles_Controller_Gutenberg::get_theme_items` and
`WP_REST_Global_Styles_Revisions_Controller::get_items`. Therefore a
property can't be added to the top-level response.
To get around this I've added `_links` to each item in the collection. I'm
not sure that's HAL-friendly, even though HAL is pretty loose and there's
no formal spec.
I was going to suggest adding another, custom property to the
[https://github.com/wordpress/wordpress-
develop/blob/3a6cca9ff772c77c86a3cf7c5a69398acc4c2272/src/wp-includes
/rest-api/endpoints/class-wp-rest-global-styles-controller.php#L513-L513,
global styles object schema] if `_links` aren't allowed in collection
items.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/61205#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list