Make WordPress Core


Ignore:
Timestamp:
06/12/2023 11:20:58 AM (10 months ago)
Author:
spacedmonkey
Message:

Editor: Improve the append_to_selector method.

Improve append_to_selector method in WP_Theme_JSON by checking to see if string contains a common before imploding / exploding string, which improves performance.

Originally developed and tested in [WordPress/gutenberg#47833 Gutenberg PR 47833].

Props spacedmonkey, flixos90, mukesh27, joemcgill, wildworks, oandregal, mamaduka.
Fixes #58231.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-theme-json.php

    r55727 r55907  
    790790     */
    791791    protected static function append_to_selector( $selector, $to_append, $position = 'right' ) {
     792        if ( ! str_contains( $selector, ',' ) ) {
     793            return 'right' === $position ? $selector . $to_append : $to_append . $selector;
     794        }
    792795        $new_selectors = array();
    793796        $selectors     = explode( ',', $selector );
Note: See TracChangeset for help on using the changeset viewer.