Skip to content
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

WP Webfonts: avoid duplicated font families if the font family name was defined using fallback values. #46378

Merged
merged 4 commits into from
Dec 9, 2022

Conversation

matiasbenedetto
Copy link
Contributor

@matiasbenedetto matiasbenedetto commented Dec 7, 2022

What?

WP Webfonts: avoid duplicated font families if the font family name was defined using fallback values

Why?

Because of #46376

How?

The function gutenberg_add_registered_webfonts_to_theme_json is adding the fonts twice when the font family name has fallback values. This is because how are we compairing the slug of the fonts.

In this PR, we change the get_font_slug function to return the family slug if it is already defined. If it's not defined, the function returns the font family name. If the font family has fallback values, it creates the slug using the first font family name.

Testing Instructions

Follow test instructions from: #46376
And see that the font is no longer repeated

Fixes: #46376

@matiasbenedetto matiasbenedetto mentioned this pull request Dec 7, 2022
10 tasks
Copy link
Contributor

@jffng jffng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested this with Vivre and the fix works as described:

Before After
Screenshot 2022-12-08 at 4 58 40 PM Screenshot 2022-12-08 at 4 59 40 PM

@matiasbenedetto matiasbenedetto merged commit 3cb3881 into trunk Dec 9, 2022
@matiasbenedetto matiasbenedetto deleted the fix/wp-webfonts_get-font-slug branch December 9, 2022 02:03
@github-actions github-actions bot added this to the Gutenberg 14.8 milestone Dec 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Duplicated font families in global settings
2 participants