[wp-trac] [WordPress Trac] #56078: PHP Warning when adding fonts to fontFamilies in wp_global_styles post
WordPress Trac
noreply at wordpress.org
Fri Nov 18 08:58:27 UTC 2022
#56078: PHP Warning when adding fonts to fontFamilies in wp_global_styles post
-----------------------------------+---------------------------------------
Reporter: domainsupport | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: 6.2
Component: Editor | Version: 6.0
Severity: normal | Resolution:
Keywords: has-patch needs- | Focuses: administration, template
testing |
-----------------------------------+---------------------------------------
Comment (by domainsupport):
Replying to [comment:10 azaozz]:
> I think what @audrasjb meant was to show an example of the code that
adds these extra fonts.
Oh right, sure. OK, well the easiest way to demonstrate that is to install
Template Editor plugin https://wordpress.org/plugins/template-editor/ then
go to "Dashboard - Appearance - Theme Options", choose a font (and style)
and "Save Options".
The code to save the fonts can be found here
https://plugins.trac.wordpress.org/browser/template-editor/trunk/template-
editor.php#L1396
> > injecting additional Google Fonts to the Full Site Editor global
styles by adding elements to `['settings']['typography']['fontFamilies']`
of the wp_global_styles post type in the database
>
> Hmmm, not sure if this is supported/expected/documented way of adding
more fonts? :)
Haha :) Sure, it's not documented ... but the way that `script-loader.php`
loads the fonts from those in the `wp_global_styles` post ''and'' then
merges them with those from `theme.json` suggests that it is expected
(even if `array_unique()` isn't used correctly, hence the error).
> > you can only use array_unique with an array of string values
>
> Right, `array_unique()` cannot be used for multi-dimensional arrays.
There's an example of a function in the PHP manual that may be helpful
here: https://www.php.net/manual/en/function.array-unique.php#116302.
Yes, I've used something similar in the past ... are you saying you'd like
me to amend the patch accordingly rather than just adding `SORT_REGULAR`
which prevents the PHP notification?
Oliver
--
Ticket URL: <https://core.trac.wordpress.org/ticket/56078#comment:11>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list