From 6fbb4abc12c2f44d39bd2de88335339a9c9b002e Mon Sep 17 00:00:00 2001 From: Ari Stathopoulos Date: Wed, 28 Apr 2021 11:24:58 +0300 Subject: [PATCH] [Fix] Inlined core block styles should not override user-added inline styles (#31268) * Make sure inlined styles are the 1st item in the array * make sure it's an array --- lib/blocks.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/blocks.php b/lib/blocks.php index f902cef724119..2800e4df6b238 100644 --- a/lib/blocks.php +++ b/lib/blocks.php @@ -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'];