Skip to content

Commit

Permalink
Add more detailed explanatory comment
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronrobertshaw committed Jun 17, 2024
1 parent 303e91f commit 34f4768
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions lib/block-supports/block-style-variations.php
Original file line number Diff line number Diff line change
Expand Up @@ -486,9 +486,19 @@ function gutenberg_register_block_style_variations_from_theme_json_data( $variat
* @access private
*/
function gutenberg_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' );

// Skip any registration of styles if no theme.json or variation partials.
if ( ! wp_theme_has_theme_json() && ! $has_partials_directory ) {
return;
}
Expand Down

0 comments on commit 34f4768

Please sign in to comment.