[Fonts API] Refactor theme.json global functions into the WP_Fonts_Resolver #50914
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.
Part of #50250.
What?
Refactors the 2 theme.json global functions (in
lib/experimental/fonts-api/register-fonts-from-theme.json.php
) by placing them into the existingWP_Fonts _Resolver
and then splitting the tasks into separate internal static methods.gutenberg_register_fonts_from_theme_json()
->WP_Fonts_Resolver::register_fonts_from_theme_json()
gutenberg_add_registered_fonts_to_theme_json()
->WP_Fonts_Resolver::add_registered_fonts_to_theme_json()
Why?
Copied from the enhancement issue:
How?
WP_Fonts_Resolver
and remove the added class. Why? These methods are resolving between theme JSON data and the Fonts API, i.e. they are resolver functionality.Testing Instructions
Manual Testing
How these functions work and what they do did not change. This means the functionality should work exactly as it did for, i.e. scope of this PR should be a pure refactoring. Manual testing is focused on ensuring no changes happened to the functionality, i.e. works the same as in
trunk
.Setting up your local test site:
Testing the theme's fonts get automatically registered and enqueued into the Fonts API:
wp-fonts-local
. Expectation: It should be in the<head>
and contain the@font-face
styles for the theme's fonts.Testing plugin fonts are added to the Theme JSON data layer:
wp-fonts-jetpack-google-fonts
. Expectation: The<style>
element should be in the<head>
and the CSS in it should only contain@font-face
styles for Playfair Display.wp-fonts-local
. Expectation: It should be in the<head>
and contain the@font-face
styles for the theme's fonts.Automated Testing
Run the following:
All tests should pass.