[wp-trac] [WordPress Trac] #56975: Replace the internal `WP_Theme_JSON_Resolver::theme_has_support()` with a public function (was: Evolve theme.json APIs)
WordPress Trac
noreply at wordpress.org
Wed Jan 18 16:11:31 UTC 2023
#56975: Replace the internal `WP_Theme_JSON_Resolver::theme_has_support()` with a
public function
---------------------------------------------+-----------------------------
Reporter: oandregal | Owner: hellofromTonya
Type: enhancement | Status: closed
Priority: normal | Milestone: 6.2
Component: Themes | Version:
Severity: normal | Resolution: fixed
Keywords: has-patch has-unit-tests commit | Focuses: performance
---------------------------------------------+-----------------------------
Changes (by hellofromTonya):
* keywords: has-patch has-unit-tests => has-patch has-unit-tests commit
* status: reopened => closed
* resolution: => fixed
Old description:
> This issue is to track the evolution of theme.json APIs on two key
> aspects:
>
> - availability of public methods for common operations
> - improve performance of hot paths
>
> See https://github.com/WordPress/gutenberg/issues/45171 for a detailed
> description of initiatives and actionable tasks to work on.
New description:
The `WP_Theme_JSON_Resolver::theme_has_support()` method is used to check
if a theme or its parent has a `theme.json` file. However, this class is
an internal Core-only class.
The proposal is to add a global public function called
`wp_theme_has_theme_json()` making it available to extenders for public
consumption.
In addition, for performance, the results should be cached using 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.).
The work has already been done in Gutenberg and is ready for backporting
to Core:
- [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.
This work is part of a larger strategy. See
https://github.com/WordPress/gutenberg/issues/45171 for a detailed
description of initiatives and actionable tasks to work on.
--
Comment:
Revising to focus this Trac ticket on `wp_theme_has_theme_json()` rather
than a larger body of work. Reclosing as the work is committed.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/56975#comment:31>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list