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

theme.json: Fix theme_has_support() #30479

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions lib/class-wp-theme-json-resolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class WP_Theme_JSON_Resolver {
*
* @var boolean
*/
private static $theme_has_support = null;
private static $theme_has_support = array();

/**
* Container for data coming from the user.
Expand Down Expand Up @@ -503,11 +503,12 @@ public static function get_user_custom_post_type_id() {
* @return boolean
*/
public static function theme_has_support() {
if ( ! isset( self::$theme_has_support ) ) {
self::$theme_has_support = (bool) self::get_file_path_from_theme( 'experimental-theme.json' );
$theme_slug = get_stylesheet();
if ( ! isset( self::$theme_has_support[ $theme_slug ] ) ) {
self::$theme_has_support[ $theme_slug ] = (bool) self::get_file_path_from_theme( 'experimental-theme.json' );
}

return self::$theme_has_support;
return self::$theme_has_support[ $theme_slug ];
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/full-site-editing/block-templates.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ function _gutenberg_get_template_files( $template_type ) {
* @return array Template.
*/
function _gutenberg_add_template_part_area_info( $template_info ) {
if ( WP_Theme_JSON_Resolver::theme_has_support() ) {
if ( WP_Theme_JSON_Resolver::theme_has_support( $template_info['slug'] ) ) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function doesn't accept any arguments.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Leftover from a previous iteration. I'll remove it.

$theme_data = WP_Theme_JSON_Resolver::get_theme_data()->get_template_parts();
}

Expand Down