File tree Expand file tree Collapse file tree
src/wp-includes/block-supports Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -474,6 +474,23 @@ function wp_register_block_style_variations_from_theme_json_data( $variations )
474474 * @access private
475475 */
476476function wp_register_block_style_variations_from_theme () {
477+ /*
478+ * Skip any registration of styles if no theme.json or variation partials are present.
479+ *
480+ * Given the possibility of hybrid themes, this check can't rely on if the theme
481+ * is a block theme or not. Instead:
482+ * - If there is a primary theme.json, continue.
483+ * - If there is a partials directory, continue.
484+ * - The only variations to be registered from the global styles user origin,
485+ * are those that have been copied in from the selected theme style variation.
486+ * For a theme style variation to be selected it would have to have a partial
487+ * theme.json file covered by the previous check.
488+ */
489+ $ has_partials_directory = is_dir ( get_stylesheet_directory () . '/styles ' ) || is_dir ( get_template_directory () . '/styles ' );
490+ if ( ! wp_theme_has_theme_json () && ! $ has_partials_directory ) {
491+ return ;
492+ }
493+
477494 // Partials from `/styles`.
478495 $ variations_partials = WP_Theme_JSON_Resolver::get_style_variations ( 'block ' );
479496 wp_register_block_style_variations_from_theme_json_data ( $ variations_partials );
You can’t perform that action at this time.
0 commit comments