diff --git a/packages/style-engine/class-wp-style-engine.php b/packages/style-engine/class-wp-style-engine.php index 02186fecdcea26..3c692719030053 100644 --- a/packages/style-engine/class-wp-style-engine.php +++ b/packages/style-engine/class-wp-style-engine.php @@ -424,8 +424,15 @@ public static function parse_block_styles( $block_styles, $options ) { continue; } - $parsed_styles['classnames'] = array_merge( $parsed_styles['classnames'], static::get_classnames( $style_value, $style_definition ) ); - $parsed_styles['declarations'] = array_merge( $parsed_styles['declarations'], static::get_css_declarations( $style_value, $style_definition, $options ) ); + $classnames = static::get_classnames( $style_value, $style_definition ); + if ( ! empty( $classnames ) ) { + $parsed_styles['classnames'] = array_merge( $parsed_styles['classnames'], $classnames ); + } + + $css_declarations = static::get_css_declarations( $style_value, $style_definition, $options ); + if ( ! empty( $css_declarations ) ) { + $parsed_styles['declarations'] = array_merge( $parsed_styles['declarations'], $css_declarations ); + } } }