Google Fonts: retire the Beta module and preserve in-use fonts#49690
Google Fonts: retire the Beta module and preserve in-use fonts#49690arthur791004 wants to merge 1 commit into
Conversation
Block themes now support fonts natively via the WordPress Font Library, so the Google Fonts (Beta) module is retired by adding it to handle_deprecated_modules(), which force-deactivates it once per site. Deactivating naively would break typography: the module registers the whole collection into the 'default' theme.json origin at runtime, but a font selection only stores a slug reference, so the @font-face definition vanishes with the module. To keep existing typography rendering, the deactivation hook now captures the families actually in use and persists their full definitions into the site's saved global styles before cleanup, so core's wp_print_font_faces emits them natively afterwards. The wpcomsh force-activation that previously kept the module on for Atomic sites was already removed in trunk, so this no longer ping-pongs there. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.
Interested in more tips and information?
|
|
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖 🔴 Action required: Please include detailed testing steps, explaining how to test your change, like so: 🔴 Action required: We would recommend that you add a section to the PR description to specify whether this PR includes any changes to data or privacy, like so: Follow this PR Review Process:
If you have questions about anything, reach out in #jetpack-developers for guidance! |
Code Coverage SummaryCoverage changed in 3 files.
Full summary · PHP report · JS report If appropriate, add one of these labels to override the failing coverage check:
Covered by non-unit tests
|
Fixes JETPACK-1533.
What
Block themes now support fonts natively via the WordPress Font Library, so this retires the Google Fonts (Beta) module — while making sure fonts already in use on a site keep rendering after it's gone.
Why retiring it naively breaks typography
The module registers the entire curated Google Fonts collection into the
defaulttheme.json origin at runtime. A font selection only stores a slug reference (e.g.var:preset|font-family|roboto) — the actual@font-facedefinition lives in that runtime origin and disappears the moment the module is deactivated. So a naive deactivation silently strips the fonts off every page that uses one.How
google-fontstoJetpack::handle_deprecated_modules(), which force-deactivates it once per site. The module isAuto Activate: No, and the wpcomsh force-activation that previously kept it on for Atomic sites was already removed in trunk, so this no longer ping-pongs there.jetpack_deactivate_module_google-fontshook now, before cleanup, captures the families actually referenced by the site's global styles and persists their full definitions (including@font-face) into the site's saved global styles. Core'swp_print_font_facesthen emits them natively once the module's runtime registration is gone.jetpack_get_in_use_google_font_families()andjetpack_merge_preserved_font_families()(dedupes by slug; idempotent).after_setup_themetiming guard handles being called during bootstrap (e.g. while handling deprecated modules), when global styles aren't resolvable yet.Jetpack_Google_Font_Face::get_global_styles_fonts_in_use()exposes the in-use slugs safely outside front-end render.Block-level font usage (set on individual blocks rather than global styles) is not enumerable site-wide and is out of scope for preservation.
Testing
Jetpack_Google_Fonts_Preservation_Testcovers: only in-use families are selected, nothing preserved when no fonts are in use, deactivation persists the in-use font with its@font-face, core emits the preserved font once the module is gone, and running twice doesn't duplicate..php.phprequire inJetpack_Google_Font_Face_Test.test_preserved_font_is_emitted_by_coreis the empirical check on the persisted data shape.To test manually:
🤖 Generated with Claude Code