-
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
Update format used by font resolver #50499
Conversation
Current status of the PR: it returns all the expected results defined by the tests plus the |
This issue uncovered a bug in the way the fonts API enqueues user-provided fonts. See https://github.com/WordPress/gutenberg/pull/50297/files#r1189573512 It relied on the font using the |
Flaky tests detected in 0211bb9. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/4935454675
|
$global_styles = wp_get_global_styles(); | ||
$user_selected_fonts = static::get_user_selected_fonts( $global_styles ); | ||
$user_selected_fonts = array(); | ||
$user_global_styles = WP_Theme_JSON_Resolver_Gutenberg::get_user_data()->get_raw_data(); |
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.
Would this avoid the cache we introduced?
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.
This has the same performance impact than using wp_get_global_styles
. That function has not a cache of their own: both approaches rely on the resolver cache.
What does this mean? The Resolver's intent is to detect and then automatically enqueued fonts that a user "selects" for global usage via the Site Editor > Styles > Typography UI. All of the theme defined fonts (via I assume user "provided" is different than user "selected". @oandregal can you share more about the intent of this PR and the distinction between user "provided" and user "selected"? And do you foresee |
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.
I'm blocking this PR until further discussion happens about its intent and what issues it resolves. Why? The PR is taking a different approach to identify all user "provided" fonts vs user "selected" fonts that are not in a theme's theme.json
file.
There are few things here:
I'm interested in shipping a fix for 1 ASAP as it's blocking development. If necessary, I'm open to revert #50366 but that is not the issue. 2 is also fixed by this PR. 3 requires a larger conversation and I need to look at the fonts code to understand how it is organized and ways forward. The TLDR is this: Does this help? |
More discussion is needed around how to identify which fonts a user selected in the Site Editor > Global Styles > Typography UI. As PR #50297 is currently causing failed tests that is blocking development on other PRs, I'll revert that PR, reopen its enhancement issue, and then reopen a PR with the same code for further discussion. |
Closing this in favor of #50512 |
* Adds user-select fonts enqueuer. * Auto queue before printing * Always set $handles to false when empty When invoked as a hooked callback, it receives an empty string. Empty is the same as false. * Use WP_Theme_JSON_Resolver_Gutenberg::get_user_data(). From PR #50499. Props @oandregal. * Adds print tests. Moves datasets to trait.
Follow-up to #50297 and #50366
What?
Fixes two issues:
Why?
#50366 updated
gutenberg_get_global_styles
so that the custom formatvar:preset|...
is never returned to consumers. Just before it was merged, a PR for the font resolver landed at #50297 that makes use of that format. Hence, when 50366 landed, it broke the font resolver.Investigating this issue uncovered a bug in how the user-provided fonts are detected. See #50297 (comment)
How?
var:preset|...
format that any origin can use.Testing Instructions
Make sure automated test pass.
See manual test instructions at #50297