Skip to content

Commit

Permalink
Update theme_has_theme_json to match core-patched version
Browse files Browse the repository at this point in the history
  • Loading branch information
westonruter committed Jul 7, 2023
1 parent be8c3fb commit 892fa93
Showing 1 changed file with 19 additions and 18 deletions.
37 changes: 19 additions & 18 deletions src/ReaderThemeSupportFeatures.php
Original file line number Diff line number Diff line change
Expand Up @@ -584,31 +584,32 @@ private function theme_has_theme_json() {
// return wp_theme_has_theme_json();
// }

static $theme_has_support = null;
static $theme_has_support = null;
static $prev_stylesheet_directory = null;
static $prev_template_directory = null;

$stylesheet_directory = get_stylesheet_directory();
$template_directory = get_template_directory();

// Make sure that the cached $theme_has_support value is reset when the theme changes.
if ( null !== $theme_has_support && (
$stylesheet_directory !== $prev_stylesheet_directory ||
$template_directory !== $prev_template_directory
) ) {
$theme_has_support = null;
}
$prev_stylesheet_directory = $stylesheet_directory;
$prev_template_directory = $template_directory;

if (
null !== $theme_has_support &&

/*
* Ignore static cache when `WP_DEBUG` is enabled. Why? To avoid interfering with
* the theme developer's workflow.
*
* @todo Replace `WP_DEBUG` once an "in development mode" check is available in Core.
*/
! ( defined( 'WP_DEBUG' ) && WP_DEBUG ) &&

/*
* Ignore cache when automated test suites are running. Why? To ensure
* the static cache is reset between each test.
*/
! ( defined( 'WP_RUN_CORE_TESTS' ) && WP_RUN_CORE_TESTS )
// Ignore static cache when the development mode is set to 'theme', to avoid interfering with
// the theme developer's workflow.
( function_exists( 'wp_get_development_mode' ) && wp_get_development_mode() !== 'theme' )
) {
return $theme_has_support;
}

$stylesheet_directory = get_stylesheet_directory();
$template_directory = get_template_directory();

// This is the same as get_theme_file_path(), which isn't available in load-styles.php context.
if ( $stylesheet_directory !== $template_directory && file_exists( $stylesheet_directory . '/theme.json' ) ) {
$path = $stylesheet_directory . '/theme.json';
Expand Down

0 comments on commit 892fa93

Please sign in to comment.