[wp-trac] [WordPress Trac] #56975: Replace the internal `WP_Theme_JSON_Resolver::theme_has_support()` with a public function
WordPress Trac
noreply at wordpress.org
Thu Jan 19 07:19:40 UTC 2023
#56975: Replace the internal `WP_Theme_JSON_Resolver::theme_has_support()` with a
public function
-------------------------------------------------+-------------------------
Reporter: oandregal | Owner:
| hellofromTonya
Type: enhancement | Status: reopened
Priority: normal | Milestone: 6.2
Component: Themes | Version:
Severity: normal | Resolution:
Keywords: dev-feedback needs-testing-info | Focuses:
gutenberg-merge has-patch has-unit-tests | performance
-------------------------------------------------+-------------------------
Comment (by flixos90):
@azaozz That's a great pointer, thanks! I took a closer look at that code.
Unfortunately, your suggestion of stubbing `wp_theme_has_theme_json()`
would not work since the `global-styles-and-settings.php` file that
includes it is loaded directly from `load-styles.php`. So we could only
stub that function if it was wrapped in a `function_exists()` check, which
seems a bit fragile to me.
What we could stub is all the `wp_cache_*()` functions, but that would be
a lot, so I'm not sure we want to do that.
For now, I went with the approach of not using the cache if `!
is_admin()`, which fixes the problem in a simpler way. I implemented that
solution in https://github.com/WordPress/wordpress-develop/pull/3867.
If you prefer to stub the `wp_cache_*()` functions, that would make it a
bit more resilient (no need to remember to check for `is_admin()` in other
similar functions in the future), but I'm also unsure about that because
of potential side effects. So to me the `! is_admin()` check seems the
safest solution.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/56975#comment:50>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list