Skip to content

Commit

Permalink
Global Styles: Avoid unnecessary processing of theme.json variation p…
Browse files Browse the repository at this point in the history
…artials.

Props aaronrobertshaw, oandregal, mukesh27.
See #61451.

Built from https://develop.svn.wordpress.org/trunk@58423


git-svn-id: http://core.svn.wordpress.org/trunk@57872 1a063a9b-81f0-0310-95a4-ce76da25c4cd
  • Loading branch information
oandregal committed Jun 17, 2024
1 parent c9fa3d2 commit 963175f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
17 changes: 17 additions & 0 deletions wp-includes/block-supports/block-style-variations.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
2 changes: 1 addition & 1 deletion wp-includes/version.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 963175f

Please sign in to comment.