Skip to content

Commit

Permalink
Style engine: wrap array_merge in conditionals to prevent unnecessary…
Browse files Browse the repository at this point in the history
… merging (WordPress#66661)

Wrap array_merge in a conditional to prevent unnecessary firing.

Co-authored-by: ramonjd <[email protected]>
Co-authored-by: aaronrobertshaw <[email protected]>
  • Loading branch information
3 people authored Nov 1, 2024
1 parent 0fa9ca0 commit 160a45a
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions packages/style-engine/class-wp-style-engine.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}
}
}

Expand Down

0 comments on commit 160a45a

Please sign in to comment.