Skip to content

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

Open
ryelle wants to merge 1 commit intotrunkfrom
fix/core-6-6-gb-compat
Open

Build theme.json object by updating the existing value.#208
ryelle wants to merge 1 commit intotrunkfrom
fix/core-6-6-gb-compat

Conversation

@ryelle
Copy link

@ryelle ryelle commented Jun 6, 2024

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

  • Use Gutenberg 17.9 & WordPress 6.6 beta
  • View a front-end editor
  • Before this PR, it would fatal error
  • With the PR, it should render correctly

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

See https://core.trac.wordpress.org/ticket/61112
@ryelle ryelle requested a review from johngodley June 6, 2024 20:44
@ryelle ryelle self-assigned this Jun 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant