Skip to content

Commit

Permalink
[Fix] Inlined core block styles should not override user-added inline…
Browse files Browse the repository at this point in the history
… styles (#31268)

* Make sure inlined styles are the 1st item in the array

* make sure it's an array
  • Loading branch information
aristath authored Apr 28, 2021
1 parent 2bf257a commit 6fbb4ab
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -253,8 +253,11 @@ function( $a, $b ) {
$style['css'] = file_get_contents( $style['path'] );

// Set `src` to `false` and add styles inline.
$wp_styles->registered[ $style['handle'] ]->src = false;
$wp_styles->registered[ $style['handle'] ]->extra['after'][] = $style['css'];
$wp_styles->registered[ $style['handle'] ]->src = false;
if ( empty( $wp_styles->registered[ $style['handle'] ]->extra['after'] ) ) {
$wp_styles->registered[ $style['handle'] ]->extra['after'] = array();
}
array_unshift( $wp_styles->registered[ $style['handle'] ]->extra['after'], $style['css'] );

// Add the styles size to the $total_inline_size var.
$total_inline_size += (int) $style['size'];
Expand Down

0 comments on commit 6fbb4ab

Please sign in to comment.