-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a "global_styles" filter #28687
Add a "global_styles" filter #28687
Conversation
Size Change: 0 B Total Size: 1.37 MB ℹ️ View Unchanged
|
👋 I have two thoughts about this:
|
Correct
The problem is that core doesn't have a method to load fonts... As a result plugins & themes are forced to deal with it anyway and re-invent the wheel every time. There have been proposals to add an API to allow loading webfonts with a consistent method, but that's a big project on its own and will probably take a long time before something can land in core. |
a866186
to
3fc9a53
Compare
Rebased the PR and fixed a conflict, this is now again ready for a review. |
In #34843 I'm asking people for thoughts about consolidating parts of the global styles API, particularly the API for themes & plugins to get access to the data from |
Description
While working on an FSE theme and trying to figure out how to load webfonts, it became apparent that there is currently no way for a theme to determine if a webfont defined in the
theme.json
file is actually used. As a result, themes are forced to always load webfonts they want to use.This PR adds a
global_styles
filter to allow 3rd-party developers (both in themes and plugins) to filter the global styles on the frontend in order to add things if needed.Example for the webfont:
Types of changes
gutenberg_experimental_global_styles_get_stylesheet
function's return.Checklist: