Missing argument in add_theme_support( 'editor-font-sizes' ) displays PHP warning in WP 5.9 #38768
Labels
[Priority] Low
Used to indicate that the issue at hand isn't a top priority to address and can be handled later
[Type] Enhancement
A suggestion for improvement.
[Type] WP Core Ticket
Requires an upstream change from WordPress. Core Trac ticket should be linked.
Description
Updating to WP 5.9 on a site using a classic theme without a theme.json file, I see the following PHP warning:
Warning: Invalid argument supplied for foreach() in \wp-includes\class-wp-theme-json.php on line 1949
Font sizes for this theme are managed in CSS, so the following theme supports have been set to prevent font size controls being exposed in the editor:
The warning appears because an array is expected as an argument of the
editor-font-sizes
support:Testing WP prior to 5.9, passing an argument was not previously required to prevent a warning. A google search returns a couple of tutorial-style sites not setting an empty array, suggesting there might be more of this configuration out there.
In this case it's not a problem applying a fix at the theme level, but to help prevent other themes being affected how about performing a check in
class-wp-theme-json.php
?Checking an array exists prevents the notice:
Step-by-step reproduction instructions
editor-font-sizes
support.Screenshots, screen recording, code snippet
No response
Environment info
Please confirm that you have searched existing issues in the repo.
Yes
Please confirm that you have tested with all plugins deactivated except Gutenberg.
Yes
The text was updated successfully, but these errors were encountered: