forked from WordPress/gutenberg
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Preload: fix multiple regressions around global styles (WordPress#66468)
Co-authored-by: ellatrix <[email protected]> Co-authored-by: ramonjd <[email protected]> Co-authored-by: aaronrobertshaw <[email protected]>
- Loading branch information
1 parent
3975cff
commit d3606ad
Showing
5 changed files
with
55 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
https://github.com/WordPress/wordpress-develop/pull/7661 | ||
|
||
* https://github.com/WordPress/gutenberg/pull/66468 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
/** | ||
* Preload theme and global styles paths to avoid flash of variation styles in | ||
* post editor. | ||
* | ||
* @param array $paths REST API paths to preload. | ||
* @param WP_Block_Editor_Context $context Current block editor context. | ||
* @return array Filtered preload paths. | ||
*/ | ||
function gutenberg_block_editor_preload_paths_6_8( $paths, $context ) { | ||
$excluded_paths = array(); | ||
if ( 'core/edit-site' === $context->name || 'core/edit-post' === $context->name ) { | ||
$stylesheet = get_stylesheet(); | ||
$global_styles_id = WP_Theme_JSON_Resolver_Gutenberg::get_user_global_styles_post_id(); | ||
$paths[] = '/wp/v2/global-styles/themes/' . $stylesheet . '?context=view'; | ||
$paths[] = '/wp/v2/global-styles/themes/' . $stylesheet . '/variations?context=view'; | ||
$paths[] = array( '/wp/v2/global-styles/' . $global_styles_id, 'OPTIONS' ); | ||
$excluded_paths[] = '/wp/v2/global-styles/themes/' . $stylesheet; | ||
$excluded_paths[] = '/wp/v2/global-styles/' . $global_styles_id; | ||
} | ||
foreach ( $paths as $key => $path ) { | ||
if ( in_array( $path, $excluded_paths, true ) ) { | ||
unset( $paths[ $key ] ); | ||
} | ||
} | ||
return $paths; | ||
} | ||
add_filter( 'block_editor_rest_api_preload_paths', 'gutenberg_block_editor_preload_paths_6_8', 10, 2 ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters