Repository navigation
Google Fonts: Prevent Gutenberg 22.4+ from printing all registered fonts - #46734
Conversation
|
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 🤖 Follow this PR Review Process:
If you have questions about anything, reach out in #jetpack-developers for guidance! Jetpack plugin: The Jetpack plugin has different release cadences depending on the platform:
If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. |
There was a problem hiding this comment.
Pull request overview
This PR fixes an issue where Gutenberg 22.4+ adds a new function gutenberg_print_font_faces that prints all registered fonts, which conflicts with Jetpack's Google Fonts module's optimization that only prints fonts actually in use. The fix removes this new Gutenberg hook alongside the existing Core hooks that are already being removed.
Changes:
- Adds removal of
gutenberg_print_font_faceshook in the Google Fonts module - Includes appropriate changelog entry
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
projects/plugins/jetpack/modules/google-fonts/current/class-jetpack-google-font-face.php |
Adds removal of Gutenberg 22.4+ font printing hook to maintain the module's behavior of only printing fonts in use |
projects/plugins/jetpack/changelog/gb224-print-font-faces-fix |
Adds changelog entry for the bugfix |
| Significance: patch | ||
| Type: bugfix | ||
|
|
||
| Google Fonts: Prevent Gutenberg 22.4+ from printing all registered fonts |
There was a problem hiding this comment.
The changelog entry is missing a period at the end. According to the project's changelog guidelines, entries should end with a period.
Code Coverage SummaryCoverage changed in 1 file.
|
Gutenberg 22.4.0 introduced
gutenberg_print_font_faces()to enable font support for classic themes (WordPress/gutenberg#73971). This function prints all fonts registered in global settings, including all ~60 font families (with ~720 total @font-face declarations for weight/style variations) registered by this module.The
Jetpack_Google_Font_Faceclass already prevents WordPress Core'swp_print_font_faces()from printing all fonts, instead collecting and printing only fonts actually used in global styles and blocks. However, it doesn't account for Gutenberg's new function.Proposed changes:
gutenberg_print_font_facesto the list of font-printing functions we disable, allowing our font handling to take over.Problem being fixed:
With Gutenberg 22.4.0+, sites using the Google Fonts module see:
<style id='wp-fonts-local'>Other information:
Jetpack product discussion
Does this pull request change what data or activity we track or use?
Testing instructions:
wp-fonts-localstylesRelated
lib/compat/wordpress-7.0/global-styles.php