diff --git a/wp-includes/block-supports/block-style-variations.php b/wp-includes/block-supports/block-style-variations.php index b85ab6aad6..43a50f1fe6 100644 --- a/wp-includes/block-supports/block-style-variations.php +++ b/wp-includes/block-supports/block-style-variations.php @@ -474,6 +474,23 @@ function wp_register_block_style_variations_from_theme_json_data( $variations ) * @access private */ function wp_register_block_style_variations_from_theme() { + /* + * Skip any registration of styles if no theme.json or variation partials are present. + * + * Given the possibility of hybrid themes, this check can't rely on if the theme + * is a block theme or not. Instead: + * - If there is a primary theme.json, continue. + * - If there is a partials directory, continue. + * - The only variations to be registered from the global styles user origin, + * are those that have been copied in from the selected theme style variation. + * For a theme style variation to be selected it would have to have a partial + * theme.json file covered by the previous check. + */ + $has_partials_directory = is_dir( get_stylesheet_directory() . '/styles' ) || is_dir( get_template_directory() . '/styles' ); + if ( ! wp_theme_has_theme_json() && ! $has_partials_directory ) { + return; + } + // Partials from `/styles`. $variations_partials = WP_Theme_JSON_Resolver::get_style_variations( 'block' ); wp_register_block_style_variations_from_theme_json_data( $variations_partials ); diff --git a/wp-includes/version.php b/wp-includes/version.php index 96517a1f06..d22e0ead83 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.6-beta2-58422'; +$wp_version = '6.6-beta2-58423'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.