[wp-trac] [WordPress Trac] #61112: Avoid re-constructing `WP_Theme_JSON` object from raw theme_json, instead use `WP_Theme_JSON` object inside `WP_Theme_JSON_data`

WordPress Trac noreply at wordpress.org
Fri May 24 15:04:53 UTC 2024


#61112: Avoid re-constructing `WP_Theme_JSON` object from raw theme_json, instead
use `WP_Theme_JSON` object inside `WP_Theme_JSON_data`
--------------------------+--------------------------
 Reporter:  thekt12       |       Owner:  thekt12
     Type:  defect (bug)  |      Status:  reopened
 Priority:  normal        |   Milestone:  6.6
Component:  General       |     Version:
 Severity:  normal        |  Resolution:
 Keywords:                |     Focuses:  performance
--------------------------+--------------------------

Comment (by joemcgill):

 This seems to be one of the unfortunate side-effects of the way we're
 currently handling the `WP_Theme_JSON_` related classes between the
 Gutenberg plugin and WP/trunk. Even though the GB plugin prefers its own
 versions of those classes, we have several functions, like
 `wp_get_global_stylesheet()` that reference the core versions directly, by
 calling `WP_Theme_JSON_Resolver::get_merged_data()` rather than allowing
 for the opportunity for the `WP_Theme_JSON_Resolver_Gutenberg` class to be
 preferred.

 We've talked about the possibility of consolidating all development of the
 `WP_Theme_JSON_*` classes to a package in the GB repo that would be synced
 to WP with other package syncs, but we would potentially still have this
 problem for anyone running trunk with a previous version of the GB plugin,
 or when the last sync before beta is made prior to the official 18.5
 release date for GB (maybe an edge case?). The other option, would be to
 make sure that the GB related classes were extending the core versions
 even thought the way that approach was previously implemented was not a
 great DX ([https://github.com/WordPress/gutenberg/pull/46750 see the
 related ticket]).

 In the meantime, I think we need to add a check to make sure anything
 filtering the `wp_theme_json_data_theme` and related filters are returning
 a `WP_Theme_JSON_Data` object before calling the new method.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/61112#comment:16>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list