Automattic / blocks-everywhere

Gutenberg block editor in WordPress comments, admin pages, bbPress, and BuddyPress.
GNU General Public License v3.0
77 stars 16 forks source link

Build theme.json object by updating the existing value. #208

Open ryelle opened 5 months ago

ryelle commented 5 months ago

This fixes a compatibility issue with Gutenberg <18.5 and WordPress 6.6.

Returning a WP_Theme_JSON_Data_Gutenberg from this filter leads to "Call to undefined method WP_Theme_JSON_Data_Gutenberg::get_theme_json()" when used on the WordPress 6.6 beta. According to this dev note, the value should be set using update_with( … );, which then returns the correct class. It's also more future-friendly, as the post mentions:

By using this mechanism as suggested, core will always make sure their data gets migrated to the latest.

I've also updated the docblock to reflect the updated classes.

See https://core.trac.wordpress.org/ticket/61112

To test