<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[55086] trunk: Themes: Introduce wp_theme_has_theme_json() for public consumption.</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { white-space: pre-line; overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="https://core.trac.wordpress.org/changeset/55086">55086</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"https://core.trac.wordpress.org/changeset/55086","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>hellofromTonya</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2023-01-18 11:38:16 +0000 (Wed, 18 Jan 2023)</dd>
</dl>

<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>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 <a href="https://core.trac.wordpress.org/changeset/54493">[54493]</a>, <a href="https://core.trac.wordpress.org/changeset/53282">[53282]</a>, <a href="https://core.trac.wordpress.org/changeset/52744">[52744]</a>, <a href="https://core.trac.wordpress.org/changeset/52049">[52049]</a>, <a href="https://core.trac.wordpress.org/changeset/50959">[50959]</a>.

Props oandregal, afragen, alexstine, aristath, azaozz, costdev, flixos90, hellofromTonya, mamaduka, mcsf, ocean90, spacedmonkey.
Fixes <a href="https://core.trac.wordpress.org/ticket/56975">#56975</a>.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcwpadmineditformblocksphp">trunk/src/wp-admin/edit-form-blocks.php</a></li>
<li><a href="#trunksrcwpadminsiteeditorphp">trunk/src/wp-admin/site-editor.php</a></li>
<li><a href="#trunksrcwpincludesblockeditorphp">trunk/src/wp-includes/block-editor.php</a></li>
<li><a href="#trunksrcwpincludesblockpatternsphp">trunk/src/wp-includes/block-patterns.php</a></li>
<li><a href="#trunksrcwpincludesblocksupportslayoutphp">trunk/src/wp-includes/block-supports/layout.php</a></li>
<li><a href="#trunksrcwpincludesblocktemplateutilsphp">trunk/src/wp-includes/block-template-utils.php</a></li>
<li><a href="#trunksrcwpincludesclasswpthemejsonresolverphp">trunk/src/wp-includes/class-wp-theme-json-resolver.php</a></li>
<li><a href="#trunksrcwpincludesdefaultfiltersphp">trunk/src/wp-includes/default-filters.php</a></li>
<li><a href="#trunksrcwpincludesglobalstylesandsettingsphp">trunk/src/wp-includes/global-styles-and-settings.php</a></li>
<li><a href="#trunksrcwpincludesloadphp">trunk/src/wp-includes/load.php</a></li>
<li><a href="#trunksrcwpincludesmsblogsphp">trunk/src/wp-includes/ms-blogs.php</a></li>
<li><a href="#trunksrcwpincludesscriptloaderphp">trunk/src/wp-includes/script-loader.php</a></li>
<li><a href="#trunksrcwpincludesthemetemplatesphp">trunk/src/wp-includes/theme-templates.php</a></li>
<li><a href="#trunktestsphpunitincludesabstracttestcasephp">trunk/tests/phpunit/includes/abstract-testcase.php</a></li>
<li><a href="#trunktestsphpunitteststhemethemeDirphp">trunk/tests/phpunit/tests/theme/themeDir.php</a></li>
<li><a href="#trunktestsphpunitteststhemewpThemeJsonResolverphp">trunk/tests/phpunit/tests/theme/wpThemeJsonResolver.php</a></li>
<li><a href="#trunktestsphpunittestswebfontswpThemeJsonWebfontsHandlerphp">trunk/tests/phpunit/tests/webfonts/wpThemeJsonWebfontsHandler.php</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li>trunk/tests/phpunit/data/themedir1/block-theme-child-no-theme-json/</li>
<li><a href="#trunktestsphpunitdatathemedir1blockthemechildnothemejsonstylecss">trunk/tests/phpunit/data/themedir1/block-theme-child-no-theme-json/style.css</a></li>
<li>trunk/tests/phpunit/data/themedir1/default-child-no-theme-json/</li>
<li><a href="#trunktestsphpunitdatathemedir1defaultchildnothemejsonstylecss">trunk/tests/phpunit/data/themedir1/default-child-no-theme-json/style.css</a></li>
<li><a href="#trunktestsphpunitteststhemewpThemeHasThemeJsonphp">trunk/tests/phpunit/tests/theme/wpThemeHasThemeJson.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcwpadmineditformblocksphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-admin/edit-form-blocks.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/edit-form-blocks.php   2023-01-18 11:18:36 UTC (rev 55085)
+++ trunk/src/wp-admin/edit-form-blocks.php     2023-01-18 11:38:16 UTC (rev 55086)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -203,7 +203,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                'unlockNonce' => wp_create_nonce( 'update-post_' . $post->ID ),
</span><span class="cx" style="display: block; padding: 0 10px">                'ajaxUrl'     => admin_url( 'admin-ajax.php' ),
</span><span class="cx" style="display: block; padding: 0 10px">        ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        'supportsLayout'       => WP_Theme_JSON_Resolver::theme_has_support(),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'supportsLayout'       => wp_theme_has_theme_json(),
</ins><span class="cx" style="display: block; padding: 0 10px">         'supportsTemplateMode' => current_theme_supports( 'block-templates' ),
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        // Whether or not to load the 'postcustom' meta box is stored as a user meta
</span></span></pre></div>
<a id="trunksrcwpadminsiteeditorphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-admin/site-editor.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/site-editor.php        2023-01-18 11:18:36 UTC (rev 55085)
+++ trunk/src/wp-admin/site-editor.php  2023-01-18 11:38:16 UTC (rev 55086)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -74,7 +74,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">        'styles'                    => get_block_editor_theme_styles(),
</span><span class="cx" style="display: block; padding: 0 10px">        'defaultTemplateTypes'      => $indexed_template_types,
</span><span class="cx" style="display: block; padding: 0 10px">        'defaultTemplatePartAreas'  => get_allowed_block_template_part_areas(),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        'supportsLayout'            => WP_Theme_JSON_Resolver::theme_has_support(),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'supportsLayout'            => wp_theme_has_theme_json(),
</ins><span class="cx" style="display: block; padding: 0 10px">         'supportsTemplatePartsMode' => ! wp_is_block_theme() && current_theme_supports( 'block-template-parts' ),
</span><span class="cx" style="display: block; padding: 0 10px">        '__unstableHomeTemplate'    => $home_template,
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span></span></pre></div>
<a id="trunksrcwpincludesblockeditorphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/block-editor.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/block-editor.php    2023-01-18 11:18:36 UTC (rev 55085)
+++ trunk/src/wp-includes/block-editor.php      2023-01-18 11:38:16 UTC (rev 55086)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -417,7 +417,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                }
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        if ( WP_Theme_JSON_Resolver::theme_has_support() ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( wp_theme_has_theme_json() ) {
</ins><span class="cx" style="display: block; padding: 0 10px">                 $block_classes = array(
</span><span class="cx" style="display: block; padding: 0 10px">                        'css'            => 'styles',
</span><span class="cx" style="display: block; padding: 0 10px">                        '__unstableType' => 'theme',
</span></span></pre></div>
<a id="trunksrcwpincludesblockpatternsphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/block-patterns.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/block-patterns.php  2023-01-18 11:18:36 UTC (rev 55085)
+++ trunk/src/wp-includes/block-patterns.php    2023-01-18 11:38:16 UTC (rev 55086)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -139,7 +139,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                return;
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        if ( ! WP_Theme_JSON_Resolver::theme_has_support() ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( ! wp_theme_has_theme_json() ) {
</ins><span class="cx" style="display: block; padding: 0 10px">                 return;
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span></span></pre></div>
<a id="trunksrcwpincludesblocksupportslayoutphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/block-supports/layout.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/block-supports/layout.php   2023-01-18 11:18:36 UTC (rev 55085)
+++ trunk/src/wp-includes/block-supports/layout.php     2023-01-18 11:38:16 UTC (rev 55086)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -464,7 +464,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">        );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        if (
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                WP_Theme_JSON_Resolver::theme_has_support() ||
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         wp_theme_has_theme_json() ||
</ins><span class="cx" style="display: block; padding: 0 10px">                 1 === preg_match( $group_with_inner_container_regex, $block_content ) ||
</span><span class="cx" style="display: block; padding: 0 10px">                ( isset( $block['attrs']['layout']['type'] ) && 'flex' === $block['attrs']['layout']['type'] )
</span><span class="cx" style="display: block; padding: 0 10px">        ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -527,7 +527,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> )/iUx";
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        if (
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                WP_Theme_JSON_Resolver::theme_has_support() ||
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         wp_theme_has_theme_json() ||
</ins><span class="cx" style="display: block; padding: 0 10px">                 0 === preg_match( $image_with_align, $block_content, $matches )
</span><span class="cx" style="display: block; padding: 0 10px">        ) {
</span><span class="cx" style="display: block; padding: 0 10px">                return $block_content;
</span></span></pre></div>
<a id="trunksrcwpincludesblocktemplateutilsphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/block-template-utils.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/block-template-utils.php    2023-01-18 11:18:36 UTC (rev 55085)
+++ trunk/src/wp-includes/block-template-utils.php      2023-01-18 11:38:16 UTC (rev 55086)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -347,7 +347,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">  * @return array Template item.
</span><span class="cx" style="display: block; padding: 0 10px">  */
</span><span class="cx" style="display: block; padding: 0 10px"> function _add_block_template_info( $template_item ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        if ( ! WP_Theme_JSON_Resolver::theme_has_support() ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( ! wp_theme_has_theme_json() ) {
</ins><span class="cx" style="display: block; padding: 0 10px">                 return $template_item;
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -370,7 +370,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">  * @return array Template info.
</span><span class="cx" style="display: block; padding: 0 10px">  */
</span><span class="cx" style="display: block; padding: 0 10px"> function _add_block_template_part_area_info( $template_info ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        if ( WP_Theme_JSON_Resolver::theme_has_support() ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( wp_theme_has_theme_json() ) {
</ins><span class="cx" style="display: block; padding: 0 10px">                 $theme_data = WP_Theme_JSON_Resolver::get_theme_data( array(), array( 'with_supports' => false ) )->get_template_parts();
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span></span></pre></div>
<a id="trunksrcwpincludesclasswpthemejsonresolverphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/class-wp-theme-json-resolver.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/class-wp-theme-json-resolver.php    2023-01-18 11:18:36 UTC (rev 55085)
+++ trunk/src/wp-includes/class-wp-theme-json-resolver.php      2023-01-18 11:38:16 UTC (rev 55086)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -58,14 +58,6 @@
</span><span class="cx" style="display: block; padding: 0 10px">        protected static $theme = null;
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-         * Whether or not the theme supports theme.json.
-        *
-        * @since 5.8.0
-        * @var bool
-        */
-       protected static $theme_has_support = null;
-
-       /**
</del><span class="cx" style="display: block; padding: 0 10px">          * Container for data coming from the user.
</span><span class="cx" style="display: block; padding: 0 10px">         *
</span><span class="cx" style="display: block; padding: 0 10px">         * @since 5.9.0
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -295,7 +287,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                 * and merge the static::$theme upon that.
</span><span class="cx" style="display: block; padding: 0 10px">                 */
</span><span class="cx" style="display: block; padding: 0 10px">                $theme_support_data = WP_Theme_JSON::get_from_editor_settings( get_default_block_editor_settings() );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                if ( ! static::theme_has_support() ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         if ( ! wp_theme_has_theme_json() ) {
</ins><span class="cx" style="display: block; padding: 0 10px">                         if ( ! isset( $theme_support_data['settings']['color'] ) ) {
</span><span class="cx" style="display: block; padding: 0 10px">                                $theme_support_data['settings']['color'] = array();
</span><span class="cx" style="display: block; padding: 0 10px">                        }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -421,11 +413,11 @@
</span><span class="cx" style="display: block; padding: 0 10px">                /*
</span><span class="cx" style="display: block; padding: 0 10px">                 * Bail early if the theme does not support a theme.json.
</span><span class="cx" style="display: block; padding: 0 10px">                 *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                 * Since WP_Theme_JSON_Resolver::theme_has_support() only supports the active
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+          * Since wp_theme_has_theme_json() only supports the active
</ins><span class="cx" style="display: block; padding: 0 10px">                  * theme, the extra condition for whether $theme is the active theme is
</span><span class="cx" style="display: block; padding: 0 10px">                 * present here.
</span><span class="cx" style="display: block; padding: 0 10px">                 */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                if ( $theme->get_stylesheet() === get_stylesheet() && ! static::theme_has_support() ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         if ( $theme->get_stylesheet() === get_stylesheet() && ! wp_theme_has_theme_json() ) {
</ins><span class="cx" style="display: block; padding: 0 10px">                         return array();
</span><span class="cx" style="display: block; padding: 0 10px">                }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -602,18 +594,14 @@
</span><span class="cx" style="display: block; padding: 0 10px">         *
</span><span class="cx" style="display: block; padding: 0 10px">         * @since 5.8.0
</span><span class="cx" style="display: block; padding: 0 10px">         * @since 5.9.0 Added a check in the parent theme.
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         * @deprecated 6.2.0 Use wp_theme_has_theme_json() instead.
</ins><span class="cx" style="display: block; padding: 0 10px">          *
</span><span class="cx" style="display: block; padding: 0 10px">         * @return bool
</span><span class="cx" style="display: block; padding: 0 10px">         */
</span><span class="cx" style="display: block; padding: 0 10px">        public static function theme_has_support() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                if ( ! isset( static::$theme_has_support ) ) {
-                       static::$theme_has_support = (
-                               static::get_file_path_from_theme( 'theme.json' ) !== '' ||
-                               static::get_file_path_from_theme( 'theme.json', true ) !== ''
-                       );
-               }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         _deprecated_function( __METHOD__, '6.2.0', 'wp_theme_has_theme_json()' );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                return static::$theme_has_support;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         return wp_theme_has_theme_json();
</ins><span class="cx" style="display: block; padding: 0 10px">         }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -656,7 +644,6 @@
</span><span class="cx" style="display: block; padding: 0 10px">                static::$theme                    = null;
</span><span class="cx" style="display: block; padding: 0 10px">                static::$user                     = null;
</span><span class="cx" style="display: block; padding: 0 10px">                static::$user_custom_post_type_id = null;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                static::$theme_has_support        = null;
</del><span class="cx" style="display: block; padding: 0 10px">                 static::$i18n_schema              = null;
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span></span></pre></div>
<a id="trunksrcwpincludesdefaultfiltersphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/default-filters.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/default-filters.php 2023-01-18 11:18:36 UTC (rev 55085)
+++ trunk/src/wp-includes/default-filters.php   2023-01-18 11:38:16 UTC (rev 55086)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -346,8 +346,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> add_action( 'init', '_register_core_block_patterns_and_categories' );
</span><span class="cx" style="display: block; padding: 0 10px"> add_action( 'init', 'check_theme_switched', 99 );
</span><span class="cx" style="display: block; padding: 0 10px"> add_action( 'init', array( 'WP_Block_Supports', 'init' ), 22 );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-add_action( 'switch_theme', array( 'WP_Theme_JSON_Resolver', 'clean_cached_data' ) );
-add_action( 'start_previewing_theme', array( 'WP_Theme_JSON_Resolver', 'clean_cached_data' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+add_action( 'switch_theme', 'wp_clean_theme_json_cache' );
+add_action( 'start_previewing_theme', 'wp_clean_theme_json_cache' );
</ins><span class="cx" style="display: block; padding: 0 10px"> add_action( 'after_switch_theme', '_wp_menus_changed' );
</span><span class="cx" style="display: block; padding: 0 10px"> add_action( 'after_switch_theme', '_wp_sidebars_changed' );
</span><span class="cx" style="display: block; padding: 0 10px"> add_action( 'wp_print_styles', 'print_emoji_styles' );
</span></span></pre></div>
<a id="trunksrcwpincludesglobalstylesandsettingsphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/global-styles-and-settings.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/global-styles-and-settings.php      2023-01-18 11:18:36 UTC (rev 55085)
+++ trunk/src/wp-includes/global-styles-and-settings.php        2023-01-18 11:38:16 UTC (rev 55086)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -102,7 +102,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        $tree = WP_Theme_JSON_Resolver::get_merged_data();
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        $supports_theme_json = WP_Theme_JSON_Resolver::theme_has_support();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $supports_theme_json = wp_theme_has_theme_json();
</ins><span class="cx" style="display: block; padding: 0 10px">         if ( empty( $types ) && ! $supports_theme_json ) {
</span><span class="cx" style="display: block; padding: 0 10px">                $types = array( 'variables', 'presets', 'base-layout-styles' );
</span><span class="cx" style="display: block; padding: 0 10px">        } elseif ( empty( $types ) ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -184,7 +184,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                }
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        $supports_theme_json = WP_Theme_JSON_Resolver::theme_has_support();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $supports_theme_json = wp_theme_has_theme_json();
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        $origins = array( 'default', 'theme', 'custom' );
</span><span class="cx" style="display: block; padding: 0 10px">        if ( ! $supports_theme_json ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -255,3 +255,72 @@
</span><span class="cx" style="display: block; padding: 0 10px">                }
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+/**
+ * Checks whether a theme or its parent has a theme.json file.
+ *
+ * @since 6.2.0
+ *
+ * @return bool Returns true if theme or its parent has a theme.json file, false otherwise.
+ */
+function wp_theme_has_theme_json() {
+       /*
+        * By using the 'theme_json' group, this data is marked to be non-persistent across requests.
+        * @see `wp_cache_add_non_persistent_groups()`.
+        *
+        * The rationale for this is to make sure 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.).
+        * For some of the existing hooks to modify theme.json behavior:
+        * @see https://make.wordpress.org/core/2022/10/10/filters-for-theme-json-data/
+        *
+        * A different alternative considered was to invalidate the cache upon certain
+        * events such as options add/update/delete, user meta, etc.
+        * It was judged not enough, hence this approach.
+        * @see https://github.com/WordPress/gutenberg/pull/45372
+        */
+       $cache_group       = 'theme_json';
+       $cache_key         = 'wp_theme_has_theme_json';
+       $theme_has_support = wp_cache_get( $cache_key, $cache_group );
+
+       /*
+        * $theme_has_support is stored as an int in the cache.
+        *
+        * The reason not to store it as a boolean is to avoid working
+        * with the $found parameter which apparently had some issues in some implementations
+        * @see https://developer.wordpress.org/reference/functions/wp_cache_get/
+        *
+        * Ignore cache when `WP_DEBUG` is enabled, so it doesn't interfere with the theme
+        * developer's workflow.
+        *
+        * @todo Replace `WP_DEBUG` once an "in development mode" check is available in Core.
+        */
+       if ( ! WP_DEBUG && is_int( $theme_has_support ) ) {
+               return (bool) $theme_has_support;
+       }
+
+       // Does the theme have its own theme.json?
+       $theme_has_support = is_readable( get_stylesheet_directory() . '/theme.json' );
+
+       // Look up the parent if the child does not have a theme.json.
+       if ( ! $theme_has_support ) {
+               $theme_has_support = is_readable( get_template_directory() . '/theme.json' );
+       }
+
+       $theme_has_support = $theme_has_support ? 1 : 0;
+
+       wp_cache_set( $cache_key, $theme_has_support, $cache_group );
+
+       return (bool) $theme_has_support;
+}
+
+/**
+ * Cleans the caches under the theme_json group.
+ *
+ * @since 6.2.0
+ */
+function wp_clean_theme_json_cache() {
+       wp_cache_delete( 'wp_theme_has_theme_json', 'theme_json' );
+       WP_Theme_JSON_Resolver::clean_cached_data();
+}
</ins></span></pre></div>
<a id="trunksrcwpincludesloadphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/load.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/load.php    2023-01-18 11:18:36 UTC (rev 55085)
+++ trunk/src/wp-includes/load.php      2023-01-18 11:38:16 UTC (rev 55086)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -753,7 +753,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        )
</span><span class="cx" style="display: block; padding: 0 10px">                );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                wp_cache_add_non_persistent_groups( array( 'counts', 'plugins' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         wp_cache_add_non_persistent_groups( array( 'counts', 'plugins', 'theme_json' ) );
</ins><span class="cx" style="display: block; padding: 0 10px">         }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        $first_init = false;
</span></span></pre></div>
<a id="trunksrcwpincludesmsblogsphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/ms-blogs.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/ms-blogs.php        2023-01-18 11:18:36 UTC (rev 55085)
+++ trunk/src/wp-includes/ms-blogs.php  2023-01-18 11:38:16 UTC (rev 55086)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -575,7 +575,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                                );
</span><span class="cx" style="display: block; padding: 0 10px">                        }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        wp_cache_add_non_persistent_groups( array( 'counts', 'plugins' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 wp_cache_add_non_persistent_groups( array( 'counts', 'plugins', 'theme_json' ) );
</ins><span class="cx" style="display: block; padding: 0 10px">                 }
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -666,7 +666,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                                );
</span><span class="cx" style="display: block; padding: 0 10px">                        }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        wp_cache_add_non_persistent_groups( array( 'counts', 'plugins' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 wp_cache_add_non_persistent_groups( array( 'counts', 'plugins', 'theme_json' ) );
</ins><span class="cx" style="display: block; padding: 0 10px">                 }
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span></span></pre></div>
<a id="trunksrcwpincludesscriptloaderphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/script-loader.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/script-loader.php   2023-01-18 11:18:36 UTC (rev 55085)
+++ trunk/src/wp-includes/script-loader.php     2023-01-18 11:38:16 UTC (rev 55086)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1620,7 +1620,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">        );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        // Only load the default layout and margin styles for themes without theme.json file.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        if ( ! WP_Theme_JSON_Resolver::theme_has_support() ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( ! wp_theme_has_theme_json() ) {
</ins><span class="cx" style="display: block; padding: 0 10px">                 $wp_edit_blocks_dependencies[] = 'wp-editor-classic-layout-styles';
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3667,7 +3667,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">  * @since 6.1.0
</span><span class="cx" style="display: block; padding: 0 10px">  */
</span><span class="cx" style="display: block; padding: 0 10px"> function wp_enqueue_classic_theme_styles() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        if ( ! WP_Theme_JSON_Resolver::theme_has_support() ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( ! wp_theme_has_theme_json() ) {
</ins><span class="cx" style="display: block; padding: 0 10px">                 $suffix = wp_scripts_get_suffix();
</span><span class="cx" style="display: block; padding: 0 10px">                wp_register_style( 'classic-theme-styles', '/' . WPINC . "/css/classic-themes$suffix.css", array(), true );
</span><span class="cx" style="display: block; padding: 0 10px">                wp_enqueue_style( 'classic-theme-styles' );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3685,7 +3685,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">  * @return array A filtered array of editor settings.
</span><span class="cx" style="display: block; padding: 0 10px">  */
</span><span class="cx" style="display: block; padding: 0 10px"> function wp_add_editor_classic_theme_styles( $editor_settings ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        if ( WP_Theme_JSON_Resolver::theme_has_support() ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( wp_theme_has_theme_json() ) {
</ins><span class="cx" style="display: block; padding: 0 10px">                 return $editor_settings;
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span></span></pre></div>
<a id="trunksrcwpincludesthemetemplatesphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/theme-templates.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/theme-templates.php 2023-01-18 11:18:36 UTC (rev 55085)
+++ trunk/src/wp-includes/theme-templates.php   2023-01-18 11:38:16 UTC (rev 55086)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -209,7 +209,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">  * @since 5.8.0
</span><span class="cx" style="display: block; padding: 0 10px">  */
</span><span class="cx" style="display: block; padding: 0 10px"> function wp_enable_block_templates() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        if ( wp_is_block_theme() || WP_Theme_JSON_Resolver::theme_has_support() ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( wp_is_block_theme() || wp_theme_has_theme_json() ) {
</ins><span class="cx" style="display: block; padding: 0 10px">                 add_theme_support( 'block-templates' );
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre></div>
<a id="trunktestsphpunitdatathemedir1blockthemechildnothemejsonstylecss"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: trunk/tests/phpunit/data/themedir1/block-theme-child-no-theme-json/style.css</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/data/themedir1/block-theme-child-no-theme-json/style.css                              (rev 0)
+++ trunk/tests/phpunit/data/themedir1/block-theme-child-no-theme-json/style.css        2023-01-18 11:38:16 UTC (rev 55086)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,8 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+/*
+Theme Name: Block Theme Child with no theme.json
+Theme URI: https://wordpress.org/
+Description: For testing purposes only.
+Template: block-theme
+Version: 1.0.0
+Text Domain: block-theme-child-no-theme-json
+*/
</ins><span class="cx" style="display: block; padding: 0 10px">Property changes on: trunk/tests/phpunit/data/themedir1/block-theme-child-no-theme-json/style.css
</span><span class="cx" style="display: block; padding: 0 10px">___________________________________________________________________
</span></span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: svn:eol-style</h4></div>
<ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+native
</ins><span class="cx" style="display: block; padding: 0 10px">\ No newline at end of property
</span><a id="trunktestsphpunitdatathemedir1defaultchildnothemejsonstylecss"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: trunk/tests/phpunit/data/themedir1/default-child-no-theme-json/style.css</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/data/themedir1/default-child-no-theme-json/style.css                          (rev 0)
+++ trunk/tests/phpunit/data/themedir1/default-child-no-theme-json/style.css    2023-01-18 11:38:16 UTC (rev 55086)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,8 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+/*
+Theme Name: Default Child Theme with no theme.json
+Theme URI: https://wordpress.org/
+Description: For testing purposes only.
+Template: default
+Version: 1.0.0
+Text Domain: default-child-no-theme-json
+*/
</ins><span class="cx" style="display: block; padding: 0 10px">Property changes on: trunk/tests/phpunit/data/themedir1/default-child-no-theme-json/style.css
</span><span class="cx" style="display: block; padding: 0 10px">___________________________________________________________________
</span></span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: svn:eol-style</h4></div>
<ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+native
</ins><span class="cx" style="display: block; padding: 0 10px">\ No newline at end of property
</span><a id="trunktestsphpunitincludesabstracttestcasephp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/includes/abstract-testcase.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/includes/abstract-testcase.php        2023-01-18 11:18:36 UTC (rev 55085)
+++ trunk/tests/phpunit/includes/abstract-testcase.php  2023-01-18 11:38:16 UTC (rev 55086)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -401,7 +401,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        )
</span><span class="cx" style="display: block; padding: 0 10px">                );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                wp_cache_add_non_persistent_groups( array( 'counts', 'plugins' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         wp_cache_add_non_persistent_groups( array( 'counts', 'plugins', 'theme_json' ) );
</ins><span class="cx" style="display: block; padding: 0 10px">         }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        /**
</span></span></pre></div>
<a id="trunktestsphpunitteststhemethemeDirphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/theme/themeDir.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/theme/themeDir.php      2023-01-18 11:18:36 UTC (rev 55085)
+++ trunk/tests/phpunit/tests/theme/themeDir.php        2023-01-18 11:38:16 UTC (rev 55086)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -163,6 +163,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                $theme_names = array_keys( $themes );
</span><span class="cx" style="display: block; padding: 0 10px">                $expected    = array(
</span><span class="cx" style="display: block; padding: 0 10px">                        'WordPress Default',
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                        'Default Child Theme with no theme.json',
</ins><span class="cx" style="display: block; padding: 0 10px">                         'Sandbox',
</span><span class="cx" style="display: block; padding: 0 10px">                        'Stylesheet Only',
</span><span class="cx" style="display: block; padding: 0 10px">                        'My Theme',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -177,6 +178,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        'REST Theme',
</span><span class="cx" style="display: block; padding: 0 10px">                        'Block Theme',
</span><span class="cx" style="display: block; padding: 0 10px">                        'Block Theme Child Theme',
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                        'Block Theme Child with no theme.json',
</ins><span class="cx" style="display: block; padding: 0 10px">                         'Block Theme Child Theme With Fluid Typography',
</span><span class="cx" style="display: block; padding: 0 10px">                        'Block Theme [0.4.0]',
</span><span class="cx" style="display: block; padding: 0 10px">                        'Block Theme [1.0.0] in subdirectory',
</span></span></pre></div>
<a id="trunktestsphpunitteststhemewpThemeHasThemeJsonphp"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: trunk/tests/phpunit/tests/theme/wpThemeHasThemeJson.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/theme/wpThemeHasThemeJson.php                           (rev 0)
+++ trunk/tests/phpunit/tests/theme/wpThemeHasThemeJson.php     2023-01-18 11:38:16 UTC (rev 55086)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,72 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<?php
+
+require_once __DIR__ . '/base.php';
+
+/**
+ * Tests wp_theme_has_theme_json().
+ *
+ * @group theme_json
+ *
+ * @covers ::wp_theme_has_theme_json
+ */
+class Tests_Theme_WpThemeHasThemeJson extends WP_Theme_UnitTestCase {
+
+       /**
+        * @ticket 56975
+        *
+        * @dataProvider data_theme_has_theme_json_reports_correctly
+        *
+        * @param string $theme    The slug of the theme to switch to.
+        * @param bool   $expected The expected result.
+        */
+       public function test_theme_has_theme_json_reports_correctly( $theme, $expected ) {
+               switch_theme( $theme );
+               $this->assertSame( $expected, wp_theme_has_theme_json() );
+       }
+
+       /**
+        * Data provider.
+        *
+        * @return array[]
+        */
+       public function data_theme_has_theme_json_reports_correctly() {
+               return array(
+                       'a theme with theme.json'       => array(
+                               'theme'    => 'block-theme',
+                               'expected' => true,
+                       ),
+                       'a theme without theme.json'    => array(
+                               'theme'    => 'default',
+                               'expected' => false,
+                       ),
+                       'a child theme with theme.json' => array(
+                               'theme'    => 'block-theme-child',
+                               'expected' => true,
+                       ),
+                       'a child theme without theme.json and parent theme with theme.json' => array(
+                               'theme'    => 'block-theme-child-no-theme-json',
+                               'expected' => true,
+                       ),
+                       'a child theme without theme.json and parent theme without theme.json' => array(
+                               'theme'    => 'default-child-no-theme-json',
+                               'expected' => false,
+                       ),
+               );
+       }
+
+       /**
+        * @ticket 52991
+        */
+       public function test_switching_themes_recalculates_support() {
+               // The "default" theme doesn't have theme.json support.
+               switch_theme( 'default' );
+               $default = wp_theme_has_theme_json();
+
+               // Switch to a theme that does have support.
+               switch_theme( 'block-theme' );
+               $block_theme = wp_theme_has_theme_json();
+
+               $this->assertFalse( $default, 'The "default" theme should not report theme.json support.' );
+               $this->assertTrue( $block_theme, 'The block theme should report theme.json support.' );
+       }
+}
</ins><span class="cx" style="display: block; padding: 0 10px">Property changes on: trunk/tests/phpunit/tests/theme/wpThemeHasThemeJson.php
</span><span class="cx" style="display: block; padding: 0 10px">___________________________________________________________________
</span></span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: svn:eol-style</h4></div>
<ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+native
</ins><span class="cx" style="display: block; padding: 0 10px">\ No newline at end of property
</span><a id="trunktestsphpunitteststhemewpThemeJsonResolverphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/theme/wpThemeJsonResolver.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/theme/wpThemeJsonResolver.php   2023-01-18 11:18:36 UTC (rev 55085)
+++ trunk/tests/phpunit/tests/theme/wpThemeJsonResolver.php     2023-01-18 11:38:16 UTC (rev 55086)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -110,7 +110,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                unset( $GLOBALS['wp_themes'] );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                // Reset data between tests.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                WP_Theme_JSON_Resolver::clean_cached_data();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         wp_clean_theme_json_cache();
</ins><span class="cx" style="display: block; padding: 0 10px">                 parent::tear_down();
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -376,7 +376,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">         * @ticket 56467
</span><span class="cx" style="display: block; padding: 0 10px">         */
</span><span class="cx" style="display: block; padding: 0 10px">        public function test_get_core_data( $should_fire_filter, $core_is_cached, $blocks_are_cached ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                WP_Theme_JSON_Resolver::clean_cached_data();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         wp_clean_theme_json_cache();
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                // If should cache core, then fire the method to cache it before running the tests.
</span><span class="cx" style="display: block; padding: 0 10px">                if ( $core_is_cached ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -432,22 +432,6 @@
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-         * @ticket 52991
-        */
-       public function test_switching_themes_recalculates_data() {
-               // The "default" theme doesn't have theme.json support.
-               switch_theme( 'default' );
-               $default = WP_Theme_JSON_Resolver::theme_has_support();
-
-               // Switch to a theme that does have support.
-               switch_theme( 'block-theme' );
-               $has_theme_json_support = WP_Theme_JSON_Resolver::theme_has_support();
-
-               $this->assertFalse( $default );
-               $this->assertTrue( $has_theme_json_support );
-       }
-
-       /**
</del><span class="cx" style="display: block; padding: 0 10px">          * @ticket 54336
</span><span class="cx" style="display: block; padding: 0 10px">         * @ticket 56467
</span><span class="cx" style="display: block; padding: 0 10px">         *
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -482,7 +466,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                remove_theme_support( 'editor-color-palette' );
</span><span class="cx" style="display: block; padding: 0 10px">                remove_theme_support( 'appearance-tools' );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $this->assertFalse( WP_Theme_JSON_Resolver::theme_has_support() );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $this->assertFalse( wp_theme_has_theme_json() );
</ins><span class="cx" style="display: block; padding: 0 10px">                 $this->assertTrue( $settings['typography']['lineHeight'] );
</span><span class="cx" style="display: block; padding: 0 10px">                $this->assertSame( $color_palette, $settings['color']['palette']['theme'] );
</span><span class="cx" style="display: block; padding: 0 10px">                $this->assertTrue( $settings['border']['color'], 'Support for appearance-tools was not added.' );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -643,7 +627,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                );
</span><span class="cx" style="display: block; padding: 0 10px">                for ( $i = 0; $i < 3; $i++ ) {
</span><span class="cx" style="display: block; padding: 0 10px">                        WP_Theme_JSON_Resolver::get_user_data_from_wp_global_styles( $theme );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        WP_Theme_JSON_Resolver::clean_cached_data();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 wp_clean_theme_json_cache();
</ins><span class="cx" style="display: block; padding: 0 10px">                 }
</span><span class="cx" style="display: block; padding: 0 10px">                $this->assertSame( 0, $global_styles_query_count, 'Unexpected SQL queries detected for the wp_global_style post type prior to creation.' );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -656,7 +640,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                $global_styles_query_count = 0;
</span><span class="cx" style="display: block; padding: 0 10px">                for ( $i = 0; $i < 3; $i++ ) {
</span><span class="cx" style="display: block; padding: 0 10px">                        $new_user_cpt = WP_Theme_JSON_Resolver::get_user_data_from_wp_global_styles( $theme );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        WP_Theme_JSON_Resolver::clean_cached_data();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 wp_clean_theme_json_cache();
</ins><span class="cx" style="display: block; padding: 0 10px">                         $this->assertSameSets( $user_cpt, $new_user_cpt, "User CPTs do not match on run {$i}." );
</span><span class="cx" style="display: block; padding: 0 10px">                }
</span><span class="cx" style="display: block; padding: 0 10px">                $this->assertSame( 1, $global_styles_query_count, 'Unexpected SQL queries detected for the wp_global_style post type after creation.' );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -673,7 +657,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                $query_count = get_num_queries();
</span><span class="cx" style="display: block; padding: 0 10px">                for ( $i = 0; $i < 3; $i++ ) {
</span><span class="cx" style="display: block; padding: 0 10px">                        WP_Theme_JSON_Resolver::get_user_data_from_wp_global_styles( $theme );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        WP_Theme_JSON_Resolver::clean_cached_data();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 wp_clean_theme_json_cache();
</ins><span class="cx" style="display: block; padding: 0 10px">                 }
</span><span class="cx" style="display: block; padding: 0 10px">                $query_count = get_num_queries() - $query_count;
</span><span class="cx" style="display: block; padding: 0 10px">                $this->assertSame( 0, $query_count, 'Unexpected SQL queries detected for the wp_global_style post type prior to creation.' );
</span></span></pre></div>
<a id="trunktestsphpunittestswebfontswpThemeJsonWebfontsHandlerphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/webfonts/wpThemeJsonWebfontsHandler.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/webfonts/wpThemeJsonWebfontsHandler.php 2023-01-18 11:18:36 UTC (rev 55085)
+++ trunk/tests/phpunit/tests/webfonts/wpThemeJsonWebfontsHandler.php   2023-01-18 11:38:16 UTC (rev 55086)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -129,7 +129,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">        private function setup_theme_and_test( $theme_name ) {
</span><span class="cx" style="display: block; padding: 0 10px">                switch_theme( $theme_name );
</span><span class="cx" style="display: block; padding: 0 10px">                do_action( 'after_setup_theme' );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                WP_Theme_JSON_Resolver::clean_cached_data();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         wp_clean_theme_json_cache();
</ins><span class="cx" style="display: block; padding: 0 10px">                 do_action( 'wp_loaded' );
</span><span class="cx" style="display: block; padding: 0 10px">                do_action( 'wp_enqueue_scripts' );
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span></span></pre>
</div>
</div>

</body>
</html>