Skip to content

Update theme_has_theme_json to reflect WP 6.3 changes #7582

Closed
@westonruter

Description

@westonruter
  1. Update theme_has_theme_json method to reflect what was actually committed.
  2. Uncomment the call to wp_theme_has_theme_json() if defined.

private function theme_has_theme_json() {
// @TODO: Uncomment this once `wp_theme_has_theme_json()` caching is fixed.
// if ( function_exists( 'wp_theme_has_theme_json' ) ) {
// return wp_theme_has_theme_json();
// }
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 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;
}
// 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';
} else {
$path = $template_directory . '/theme.json';
}
/** This filter is documented in wp-includes/link-template.php */
$path = apply_filters( 'theme_file_path', $path, 'theme.json' );
$theme_has_support = file_exists( $path );
return $theme_has_support;
}

Metadata

Metadata

Assignees

Labels

ChangeloggedWhether the issue/PR has been added to release notes.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions