Skip to content

Google Fonts: retire the Beta module and preserve in-use fonts#49690

Draft
arthur791004 wants to merge 1 commit into
trunkfrom
update/jetpack-1533-retire-google-fonts
Draft

Google Fonts: retire the Beta module and preserve in-use fonts#49690
arthur791004 wants to merge 1 commit into
trunkfrom
update/jetpack-1533-retire-google-fonts

Conversation

@arthur791004

Copy link
Copy Markdown
Contributor

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 default theme.json origin at runtime. A font selection only stores a slug reference (e.g. var:preset|font-family|roboto) — the actual @font-face definition 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

  • Turn it off: add google-fonts to Jetpack::handle_deprecated_modules(), which force-deactivates it once per site. The module is Auto 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.
  • Preserve in-use fonts: the jetpack_deactivate_module_google-fonts hook 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's wp_print_font_faces then emits them natively once the module's runtime registration is gone.
    • New helpers jetpack_get_in_use_google_font_families() and jetpack_merge_preserved_font_families() (dedupes by slug; idempotent).
    • An after_setup_theme timing guard handles being called during bootstrap (e.g. while handling deprecated modules), when global styles aren't resolvable yet.
  • New accessor 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

  • New Jetpack_Google_Fonts_Preservation_Test covers: 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.
  • Fixes a pre-existing broken .php.php require in Jetpack_Google_Font_Face_Test.
  • These are WP integration tests and need the CI DB to run; test_preserved_font_is_emitted_by_core is the empirical check on the persisted data shape.

To test manually:

  1. On a block theme, activate the Google Fonts (Beta) module and select a Google font in global styles (Styles → Typography). Confirm it renders on the front end.
  2. Deactivate the module.
  3. Reload the front end — the font should still render.

🤖 Generated with Claude Code

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>
@arthur791004 arthur791004 marked this pull request as draft June 17, 2026 12:52
@arthur791004 arthur791004 self-assigned this Jun 17, 2026
@github-actions

github-actions Bot commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.

  • To test on WoA, go to the Plugins menu on a WoA dev site. Click on the "Upload" button and follow the upgrade flow to be able to upload, install, and activate the Jetpack Beta plugin. Once the plugin is active, go to Jetpack > Jetpack Beta, select your plugin (Jetpack), and enable the update/jetpack-1533-retire-google-fonts branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack update/jetpack-1533-retire-google-fonts

Interested in more tips and information?

  • In your local development environment, use the jetpack rsync command to sync your changes to a WoA dev blog.
  • Read more about our development workflow here: PCYsg-eg0-p2
  • Figure out when your changes will be shipped to customers here: PCYsg-eg5-p2

@github-actions github-actions Bot added [Feature] Google Fonts [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Tests] Includes Tests labels Jun 17, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • 🔴 Add a "[Status]" label (In Progress, Needs Review, ...).
  • 🔴 Add testing instructions.
  • 🔴 Specify whether this PR includes any changes to data or privacy.
  • ✅ Add changelog entries to affected projects

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:

## Testing instructions:

* Go to '..'
*

🔴 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:

## Does this pull request change what data or activity we track or use?

My PR adds *x* and *y*.

Follow this PR Review Process:

  1. Ensure all required checks appearing at the bottom of this PR are passing.
  2. Make sure to test your changes on all platforms that it applies to. You're responsible for the quality of the code you ship.
  3. You can use GitHub's Reviewers functionality to request a review.
  4. When it's reviewed and merged, you will be pinged in Slack to deploy the changes to WordPress.com simple once the build is done.

If you have questions about anything, reach out in #jetpack-developers for guidance!

@github-actions github-actions Bot added the [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. label Jun 17, 2026
@jp-launch-control

Copy link
Copy Markdown

Code Coverage Summary

Coverage changed in 3 files.

File Coverage Δ% Δ Uncovered
projects/plugins/jetpack/modules/google-fonts/current/load-google-fonts.php 0/142 (0.00%) 0.00% 35 💔
projects/plugins/jetpack/modules/google-fonts/current/class-jetpack-google-font-face.php 0/93 (0.00%) 0.00% 10 💔
projects/plugins/jetpack/class.jetpack.php 759/2292 (33.12%) 0.03% 0 💚

Full summary · PHP report · JS report

If appropriate, add one of these labels to override the failing coverage check: Covered by non-unit tests Use to ignore the Code coverage requirement check when E2Es or other non-unit tests cover the code Coverage tests to be added later Use to ignore the Code coverage requirement check when tests will be added in a follow-up PR I don't care about code coverage for this PR Use this label to ignore the check for insufficient code coveage.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Feature] Google Fonts [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. [Tests] Includes Tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant