diff --git a/lib/block-supports/block-style-variations.php b/lib/block-supports/block-style-variations.php index e078b50b19d5a3..6bb55e20beac9d 100644 --- a/lib/block-supports/block-style-variations.php +++ b/lib/block-supports/block-style-variations.php @@ -486,6 +486,13 @@ function gutenberg_register_block_style_variations_from_theme_json_data( $variat * @access private */ function gutenberg_register_block_style_variations_from_theme() { + $has_partials_directory = is_dir( get_stylesheet_directory() . '/styles' ) || is_dir( get_template_directory() . '/styles' ); + + // Skip any registration of styles if no theme.json or variation partials. + if ( ! wp_theme_has_theme_json() && ! $has_partials_directory ) { + return; + } + // Partials from `/styles`. $variations_partials = WP_Theme_JSON_Resolver_Gutenberg::get_style_variations( 'block' ); gutenberg_register_block_style_variations_from_theme_json_data( $variations_partials );