Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update theme_has_theme_json to reflect WP 6.3 changes #7582

Closed
westonruter opened this issue Jul 10, 2023 · 1 comment · Fixed by #7583
Closed

Update theme_has_theme_json to reflect WP 6.3 changes #7582

westonruter opened this issue Jul 10, 2023 · 1 comment · Fixed by #7583
Assignees
Labels
Changelogged Whether the issue/PR has been added to release notes.
Milestone

Comments

@westonruter
Copy link
Member

  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;
}

@pooja-muchandikar
Copy link

QA Passed ✅

Checked the issue, and verified it on WP6.1 and WP6.2 and WP6.3 beta versions and the 2023 theme with the legacy mode appears to be working fine.

@thelovekesh thelovekesh added Bug Something isn't working Enhancement New feature or improvement of an existing one P2 Low priority Reader Mode WS:Core Work stream for Plugin core and removed Bug Something isn't working Enhancement New feature or improvement of an existing one P2 Low priority Reader Mode WS:Core Work stream for Plugin core labels Jul 13, 2023
@westonruter westonruter added the Changelogged Whether the issue/PR has been added to release notes. label Jul 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Changelogged Whether the issue/PR has been added to release notes.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants