[wp-trac] [WordPress Trac] #56975: Evolve theme.json APIs

WordPress Trac noreply at wordpress.org
Wed Jan 18 11:38:31 UTC 2023


#56975: Evolve theme.json APIs
---------------------------------------------+-----------------------------
 Reporter:  oandregal                        |       Owner:  hellofromTonya
     Type:  enhancement                      |      Status:  closed
 Priority:  normal                           |   Milestone:  6.2
Component:  Editor                           |     Version:
 Severity:  normal                           |  Resolution:  fixed
 Keywords:  has-patch has-unit-tests commit  |     Focuses:  performance
---------------------------------------------+-----------------------------
Changes (by hellofromTonya):

 * status:  reviewing => closed
 * resolution:   => fixed


Comment:

 In [changeset:"55086" 55086]:
 {{{
 #!CommitTicketReference repository="" revision="55086"
 Themes: Introduce wp_theme_has_theme_json() for public consumption.

 Adds `wp_theme_has_theme_json()` for public consumption, to replace the
 private internal Core-only `WP_Theme_JSON_Resolver::theme_has_support()`
 method. This new global function checks if a theme or its parent has a
 `theme.json` file.

 For performance, results are cached as an integer `1` or `0` in the
 `'theme_json'` group with `'wp_theme_has_theme_json'` key. This is a non-
 persistent cache. Why? To make the derived data from `theme.json` is
 always fresh from the potential modifications done via hooks that can use
 dynamic data (modify the stylesheet depending on some option, settings
 depending on user permissions, etc.).

 Also adds a new public function `wp_clean_theme_json_cache()` to clear the
 cache on `'switch_theme'` and `start_previewing_theme'`.

 References:
 * [https://github.com/WordPress/gutenberg/pull/45168 Gutenberg PR 45168]
 Add `wp_theme_has_theme_json` as a public API to know whether a theme has
 a `theme.json`.
 * [https://github.com/WordPress/gutenberg/pull/45380 Gutenberg PR 45380]
 Deprecate `WP_Theme_JSON_Resolver:theme_has_support()`.
 * [https://github.com/WordPress/gutenberg/pull/46150 Gutenberg PR 46150]
 Make `theme.json` object caches non-persistent.
 * [https://github.com/WordPress/gutenberg/pull/45979 Gutenberg PR 45979]
 Don't check if constants set by `wp_initial_constants()` are defined.
 * [https://github.com/WordPress/gutenberg/pull/45950 Gutenberg PR 45950]
 Cleaner logic in `wp_theme_has_theme_json`.

 Follow-up to [54493], [53282], [52744], [52049], [50959].

 Props oandregal, afragen, alexstine, aristath, azaozz, costdev, flixos90,
 hellofromTonya, mamaduka, mcsf, ocean90, spacedmonkey.
 Fixes #56975.
 }}}

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


More information about the wp-trac mailing list