Skip to content

Commit

Permalink
Avoid enqueuing global styles twice when running on WordPress 5.8 (#3…
Browse files Browse the repository at this point in the history
  • Loading branch information
nosolosw authored Jun 1, 2021
1 parent 2f3e74e commit 28b66d7
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lib/global-styles.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,13 @@ function gutenberg_experimental_global_styles_enqueue_assets() {
return;
}

wp_register_style( 'global-styles', false, array(), true, true );
wp_add_inline_style( 'global-styles', $stylesheet );
wp_enqueue_style( 'global-styles' );
if ( isset( wp_styles()->registered['global-styles'] ) ) {
wp_styles()->registered['global-styles']->extra['after'][0] = $stylesheet;
} else {
wp_register_style( 'global-styles', false, array(), true, true );
wp_add_inline_style( 'global-styles', $stylesheet );
wp_enqueue_style( 'global-styles' );
}
}

/**
Expand Down

0 comments on commit 28b66d7

Please sign in to comment.