Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 3 additions & 0 deletions backport-changelog/7.1/12461.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
https://github.com/WordPress/wordpress-develop/pull/12461

* https://github.com/WordPress/gutenberg/pull/80062
10 changes: 5 additions & 5 deletions lib/block-supports/custom-css.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,14 @@ function gutenberg_render_custom_css_support_styles( $parsed_block ) {

if ( ! empty( $processed_css ) ) {
/**
* Skip CSS that has already been added. Blocks with identical attributes
* share the same class name and processed CSS via {@see wp_unique_id_from_values()},
* so the same style would otherwise be enqueued more than once (e.g. inside
* a Query Loop or when blocks share identical custom CSS).
* Reuse one handle so identical custom CSS is enqueued only once via
* {@see wp_unique_id_from_values()}. Explicitly declare the `wp-block-library`
* dependency so `global-styles` is guaranteed to print after it, preventing
* block default styles from unintentionally overriding global styles.
*/
$handle = 'wp-block-custom-css';
if ( ! wp_style_is( $handle, 'registered' ) ) {
wp_register_style( $handle, false, array( 'global-styles' ) );
wp_register_style( $handle, false, array( 'wp-block-library', 'global-styles' ) );
}
$after_styles = wp_styles()->get_data( $handle, 'after' );
if ( ! is_array( $after_styles ) ) {
Expand Down
Loading