Make WordPress Core

Changeset 59442


Ignore:
Timestamp:
11/20/2024 09:27:18 PM (15 months ago)
Author:
joemcgill
Message:

Editor: Avoid unnecessary array_merge in WP_Style_Engine::parse_block_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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/style-engine/class-wp-style-engine.php

    r59199 r59442  
    455455                }
    456456
    457                 $parsed_styles['classnames']   = array_merge( $parsed_styles['classnames'], static::get_classnames( $style_value, $style_definition ) );
    458                 $parsed_styles['declarations'] = array_merge( $parsed_styles['declarations'], static::get_css_declarations( $style_value, $style_definition, $options ) );
     457                $classnames = static::get_classnames( $style_value, $style_definition );
     458                if ( ! empty( $classnames ) ) {
     459                    $parsed_styles['classnames'] = array_merge( $parsed_styles['classnames'], $classnames );
     460                }
     461
     462                $css_declarations = static::get_css_declarations( $style_value, $style_definition, $options );
     463                if ( ! empty( $css_declarations ) ) {
     464                    $parsed_styles['declarations'] = array_merge( $parsed_styles['declarations'], $css_declarations );
     465                }
    459466            }
    460467        }
Note: See TracChangeset for help on using the changeset viewer.