mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-04-09 07:04:34 +00:00
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. git-svn-id: https://develop.svn.wordpress.org/trunk@55086 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -1620,7 +1620,7 @@ function wp_default_styles( $styles ) {
|
||||
);
|
||||
|
||||
// Only load the default layout and margin styles for themes without theme.json file.
|
||||
if ( ! WP_Theme_JSON_Resolver::theme_has_support() ) {
|
||||
if ( ! wp_theme_has_theme_json() ) {
|
||||
$wp_edit_blocks_dependencies[] = 'wp-editor-classic-layout-styles';
|
||||
}
|
||||
|
||||
@@ -3667,7 +3667,7 @@ function _wp_theme_json_webfonts_handler() {
|
||||
* @since 6.1.0
|
||||
*/
|
||||
function wp_enqueue_classic_theme_styles() {
|
||||
if ( ! WP_Theme_JSON_Resolver::theme_has_support() ) {
|
||||
if ( ! wp_theme_has_theme_json() ) {
|
||||
$suffix = wp_scripts_get_suffix();
|
||||
wp_register_style( 'classic-theme-styles', '/' . WPINC . "/css/classic-themes$suffix.css", array(), true );
|
||||
wp_enqueue_style( 'classic-theme-styles' );
|
||||
@@ -3685,7 +3685,7 @@ function wp_enqueue_classic_theme_styles() {
|
||||
* @return array A filtered array of editor settings.
|
||||
*/
|
||||
function wp_add_editor_classic_theme_styles( $editor_settings ) {
|
||||
if ( WP_Theme_JSON_Resolver::theme_has_support() ) {
|
||||
if ( wp_theme_has_theme_json() ) {
|
||||
return $editor_settings;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user