Skip to content

Commit 96f1893

Browse files
authored
Merge branch 'WordPress:trunk' into trunk
2 parents 942eaa1 + e533437 commit 96f1893

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

src/wp-includes/block-supports/custom-css.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,14 @@ function wp_render_custom_css_support_styles( $parsed_block ) {
6969

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

0 commit comments

Comments
 (0)