Skip to content

Commit

Permalink
Editor: Avoid unnecessary array_merge in WP_Style_Engine::parse_block…
Browse files Browse the repository at this point in the history
…_styles().

This adds an `! empty()` check for classnames and declarations to avoid calling array_merge() with an empty value.

Props mukesh27, ramonopoly, aaronrobertshaw.
Fixes #62317.


git-svn-id: https://develop.svn.wordpress.org/trunk@59442 602fd350-edb4-49c9-b593-d223f7449a82
  • Loading branch information
joemcgill committed Nov 20, 2024
1 parent 4a03ebe commit b2c8d8d
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/wp-includes/style-engine/class-wp-style-engine.php
Original file line number Diff line number Diff line change
Expand Up @@ -454,8 +454,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 );
}
}
}

Expand Down

0 comments on commit b2c8d8d

Please sign in to comment.