-
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
Webfonts API: expose enqueueing method instead of directly enqueueing fonts on registration #39327
Closed
Closed
Changes from 1 commit
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
86ece5f
Separate between registered and enqueued webfonts
zaguiini b084fd0
Expose webfont enqueueing method
zaguiini a9bf4b6
Register fonts from theme.json instead of directly enqueueing them
zaguiini 91dbeba
Expose bulk webfont enqueueing method
zaguiini ab36072
Remove misleading comment regarding arguments list
zaguiini 53ab9d1
Enhance wp_register_webfonts and wp_register_webfont tests
zaguiini 0888132
Add wp_enqueue_webfonts and wp_enqueue_webfont tests
zaguiini 6a0cf04
Make sure wp-block-library is enqueued before adding inline styles to it
zaguiini 59ef049
Remove static variable declaration for registered and enqueued webfonts
jeyip e0a573d
Reference the registered_webfonts as an instance variable
jeyip 391b0b0
Reference the enqueued_webfonts as an instance variable
jeyip 2df17bf
Add test for generate_and_enqueue_styles
zaguiini 7a12067
Add test for generate_and_enqueue_editor_styles
jeyip 5ab6da7
Move src attribute processing to the local provider
zaguiini File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Register fonts from theme.json instead of directly enqueueing them
- Loading branch information
commit a9bf4b6ec62ec6aa89fdec79e0d24dffec1f4104
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The sole reason we're doing this ternary is that it might break themes already using the Webfont API and registering webfonts, but without specifying the font id.
The thing is, the Webfont API hasn't been made public yet, so we can do whatever we want with the signature... Including breaking changes such as this one.
"Why are we making the
id
key required?"The idea is that developers provide their own hashing mechanism so they can register IDs that works for them, since they're creating their own.
I do believe that adding the
gutenberg_generate_font_id
function is confusing. The reason why it's there is that no theme specifies the ID when registering a font through theme.json so we wanted to maintain it backward compatible. That's why this function is used there.So, now that we're separating registration from enqueueing, I do think it makes sense for the developers to come with their own IDs, so that they can register and enqueue the fonts as they need instead of relying on an abstract mechanism that they're not aware of. Explicit is better than implicit.