Fix: Correct font slug before calculating $to_add#46292
Fix: Correct font slug before calculating $to_add#46292enodekciw wants to merge 1 commit intoWordPress:trunkfrom
Conversation
|
👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @enodekciw! In case you missed it, we'd love to have you join us in our Slack community, where we hold regularly weekly meetings open to anyone to coordinate with each other. If you want to learn more about WordPress development in general, check out the Core Handbook full of helpful information. |
|
Added few reviewers to move this forward; feel free to ping others or un-assign yourself if it makes sense. |
|
Sorry, I am not familiar with the web font codebase and cannot determine if this change is appropriate. @aristath |
|
Thanks a lot, @enodekciw, for working on this! I think this approach you propose breaks in certain cases, specifically when the font family doesn't have a slug defined. It doesn't solve either this related issue around duplicated fonts when using fallback values in the family name. This is a valid theme.json snippet: As you can see in the theme.json schema the slug key is not required but this change makes it required because it is being accessed without checking if it's there and without providing an fallback value when is not. If you use a theme.json like that, this change produces 2 PHP warnings: Before seeing this, I proposed an alternative fix yesterday. Sorry for the partial overlap! thanks again for this valuable work! I would greatly appreciate it if you could review and test this PR. |
|
Oh, didn't know that Yup, saw your PR yesterday. Actually, I think that is an even better way to solve this issue. |
What?
Incorrect font-family slug is being used while registering theme webfonts.
Why?
Solves #46289
How?
Passing
$familytoWP_Webfonts::get_font_slug( $family )returns sanitized font-family. This is OK for webfonts, but not OK when used onsettings.typography.fontFamilies. Also, there's already$family['slug']available to check against.