-
-
Notifications
You must be signed in to change notification settings - Fork 102
Description
Terms
- I have read the guidelines for Contributing to Roots Projects
- This request is not a duplicate of an existing issue
- This is not a personal support request that should be posted on the Roots Discourse community
Summary
Asset
currently has a path()
function that returns the full, absolute path to the asset.
Sometimes the path relative to the theme directory is also needed, as for add_editor_style
.
Currently, additional code/library is needed to get the path relative to theme directory from the absolute path returned by the path()
function.
It would be nice if also a function is added that returns the path to asset relative to the (Sage) theme directory.
Motivation
Why are we doing this?
Sometimes the path relative to the theme directory is also needed.
What use cases does it support?
add_editor_style
requires either an URI (that currently cause an issue post-processing CSS in Gutenberg editor to rewrite URLs relative to stylehsheet) or a path to a local file relative to the theme directory (that doesn't cause this issue).
What is the expected outcome?
Elimination of additional code/library for making the absolute asset path (from path()
) relative to the theme directory path,
so it can be used by functions like add_editor_style
.
Potential conflicts / foreseeable issues
One more API function in acorn
, paths and their handling shouldn't change in the foreseeable future, so once the code (and tests) for a theme-directory-relative path function is in place, no changes should be expected any time soon.
As this functionality would be requires in any theme that adds the frontend styles in the expected way (using add_editor_style
), this should justify adding such an additional function.
Additional Context
https://discourse.roots.io/t/absolute-domain-relative-path-for-asset-urls-in-css/23121/4