Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Section Styles: improve performance and conceptual consistency #62712

Merged
merged 35 commits into from
Jun 24, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
6b10584
Remove variation style registration from theme json and theme style v…
aaronrobertshaw Jun 21, 2024
fbb6775
Make variation style registration specific to partials
aaronrobertshaw Jun 21, 2024
e00fbfd
Inject partial theme.json variations before filters
aaronrobertshaw Jun 21, 2024
87b5be2
Remove existing filters that resolve shared definitions
aaronrobertshaw Jun 21, 2024
6001757
Unwrap shared variation definitions within theme json constructor
aaronrobertshaw Jun 21, 2024
82efc17
Remove retrieval of user origin data in block style variations test
aaronrobertshaw Jun 21, 2024
18c0636
Remove styles.blocks.variations from internal schema
aaronrobertshaw Jun 21, 2024
b738360
Add unit test for unwrapping shared definitions
aaronrobertshaw Jun 21, 2024
28ce75e
Fix injection of variation partials data
aaronrobertshaw Jun 21, 2024
9b41371
Fix block style registry variations
aaronrobertshaw Jun 21, 2024
ffe3db8
Make registry variations be overridden by partials again
aaronrobertshaw Jun 21, 2024
0242883
Fix global styles API test
aaronrobertshaw Jun 21, 2024
e980752
Fix copy paste docblock
aaronrobertshaw Jun 21, 2024
0d86f4b
Switch to directly registering variations from partials
aaronrobertshaw Jun 21, 2024
77e9f50
Fix typo
aaronrobertshaw Jun 21, 2024
eb78e91
Try removing blockTypes from shared variation definitions
aaronrobertshaw Jun 21, 2024
39920cc
Update testing grounds
oandregal Jun 21, 2024
5f146c8
Merge top & block level data instead of block registry data
oandregal Jun 21, 2024
d8b0335
Make linter happy
oandregal Jun 21, 2024
20f2754
Update PHP docblock
oandregal Jun 21, 2024
016f7ba
Process variations from block styles registry.
oandregal Jun 21, 2024
7b9a2fe
Make linter happy
oandregal Jun 21, 2024
4d56029
Add backport
oandregal Jun 21, 2024
2e04467
Fix minor nits
aaronrobertshaw Jun 22, 2024
681741f
Remove extraneous whitespace
aaronrobertshaw Jun 22, 2024
7626433
Add test for variation styles merge order
aaronrobertshaw Jun 22, 2024
d77a6b0
Prevent partial styles overriding registered variation for different …
aaronrobertshaw Jun 22, 2024
d781aed
Fix test_add_registered_block_styles_to_theme_data
aaronrobertshaw Jun 22, 2024
e33638f
Update unwrapping to include variations for core blocks not in registry
aaronrobertshaw Jun 22, 2024
ba38fa3
Fix typo
aaronrobertshaw Jun 23, 2024
37f6865
Add since comment for change to theme json constructor
aaronrobertshaw Jun 23, 2024
e90b542
Try relocating variations in theme.json schema
aaronrobertshaw Jun 23, 2024
af5b180
Remove title and block types from shared definitions
aaronrobertshaw Jun 24, 2024
b7013f8
Remove title from translatable theme.json schema
aaronrobertshaw Jun 24, 2024
1e0065e
Ensure block style variations are registered when retrieving theme st…
aaronrobertshaw Jun 24, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Remove variation style registration from theme json and theme style v…
…ariations
  • Loading branch information
aaronrobertshaw committed Jun 24, 2024
commit 6b105847bd7ee352a88d8a3af60d2bf747d4ccef
7 changes: 1 addition & 6 deletions lib/class-wp-rest-global-styles-controller-gutenberg.php
Original file line number Diff line number Diff line change
Expand Up @@ -331,14 +331,9 @@ protected function prepare_item_for_database( $request ) {
$config['styles'] = $existing_config['styles'];
}

// Register theme-defined variations.
// Register theme-defined variations e.g. from block style variation partials under `/styles`.
WP_Theme_JSON_Resolver_Gutenberg::get_theme_data();

// Register user-defined variations.
if ( isset( $request['styles']['blocks']['variations'] ) && ! empty( $config['styles']['blocks']['variations'] ) ) {
gutenberg_register_block_style_variations_from_theme_json_data( $config['styles']['blocks']['variations'] );
}

if ( isset( $request['settings'] ) ) {
$config['settings'] = $request['settings'];
} elseif ( isset( $existing_config['settings'] ) ) {
Expand Down
8 changes: 0 additions & 8 deletions lib/class-wp-theme-json-resolver-gutenberg.php
Original file line number Diff line number Diff line change
Expand Up @@ -247,10 +247,6 @@ public static function get_theme_data( $deprecated = array(), $options = array()
$theme_json_data = array( 'version' => WP_Theme_JSON_Gutenberg::LATEST_SCHEMA );
}

// Register variations defined by the theme.
$variations = $theme_json_data['styles']['blocks']['variations'] ?? array();
gutenberg_register_block_style_variations_from_theme_json_data( $variations );

// Register variations defined by theme partials (theme.json files in the styles directory).
$variations = static::get_style_variations( 'block' );
gutenberg_register_block_style_variations_from_theme_json_data( $variations );
Expand Down Expand Up @@ -547,10 +543,6 @@ public static function get_user_data() {
}
}

// Register variations defined by the user.
$variations = $config['styles']['blocks']['variations'] ?? array();
gutenberg_register_block_style_variations_from_theme_json_data( $variations );

/** This filter is documented in wp-includes/class-wp-theme-json-resolver.php */
$theme_json = apply_filters( 'wp_theme_json_data_user', new WP_Theme_JSON_Data_Gutenberg( $config, 'custom' ) );
static::$user = $theme_json->get_theme_json();
Expand Down