-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Webfonts API Architecture: Explore leveraging WP_Dependencies existing enqueuing, registration, and internal handling #41481
Comments
Thank you @desrosj for creating this POC in PR #40556. A lot of the functionality that is in the POC and currently in Gutenberg's implementation will be removed and/or changed as part of the current vision in the ongoing roadmap. I have concerns about extending from tl;drI'm thinking Webfonts API doesn't really fit into the intent of
The concept of
|
Thanks for looking at my proof of concept! I have some follow up questions to get some clarifications.
It's true that font faces do not depend on one another, but that's not how my proof of concept works. A font family gets registered with no source URL (which means it is an alias), and then the variations of each font are registered as dependencies of that alias. This practice has been in place for some time with scripts like jQuery, mediaelement, and a handful others. With this approach, it is a 1:many relationship. A font family to many variations. I agree that
I'm on board with this for the fonts in
How is this any different than plugins and themes removing Core defined scripts?
What if a theme specifies fonts to load from Google Fonts, but the site owner wants to include the fonts on their server for loading instead? Would that be possible without this ability? Or what if a company wants to prevent a certain font family from ever appearing as an option due to branding concerns? |
Thanks for the feedback @desrosj. I'll answer this part today and will think on the others.
Theme specified fonts can be changed through the Global Styles Typography interface. For both of scenarios, a company or site admin could customize through a plugin and then select which to apply to the different typography needs. |
Great question @desrosj. How is it different? tl;dr Users decide, rather than having plugins programmatically override the theme. It's different because global styling typography is defined by the theme. A user can override the theme through the Global Styles UI using any of the additional web fonts defined by plugins. Plugins can offer their web fonts for selection, but users decide whether and where to use any of those plugin-defined fonts. |
I'm not sure I follow. Are you thinking a web font could be programmatically enqueued through a shortcode? Web fonts are for global styling, rather than individual blocks. A shortcode block that needs a different family-font or variation could register its web font for user selection. |
I withdraw my objections to this proposal. Let me explain. Initially the plan was to move enqueuing to an internal only inner-workings. After discussing with @mtias in light of @desrosj well-argued points and when considering classic and block themes, the vision changed and was updated in the ongoing roadmap. Now I now agree with @desrosj that it makes sense to move forward with this architectural proposal. Why? It will remove the coupling between the 2 APIs while leveraging inheritance to reuse the functionality and concepts. What about the intent of what dependencies means in the Script/Style Loader component? As Jon points out, there is precedence to bend what a dependency is. In the case of fonts, the variations are dependent upon the font-family and a font-family is dependent upon its variations. I vote to change the architecture based on Jon's POC as a starting point 👍 |
Part of #41479.
Explore changing the current architecture to extend from the
WP_Dependencies
to reuse its implementations of enqueuing, registration, and internal handling.Why?
The current implementation re-implements a lot of the concepts that are already handled by
WP_Dependencies
for the script and style loaders. The script loader classes already have the concepts of dependencies, enqueuing, and registering, as well as a way to "do_item()" (generate CSS or a tag with source, in this case).Goals: reduce code, increase readability, and increase maintainability.
The text was updated successfully, but these errors were encountered: