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.
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 usingupdate_with( … );
, which then returns the correct class. It's also more future-friendly, as the post mentions:I've also updated the docblock to reflect the updated classes.
See https://core.trac.wordpress.org/ticket/61112
To test