[wp-trac] [WordPress Trac] #58193: Introduce `WP_Theme_JSON::prepend_to_selector()` in favor of parameter to conditionally modify `append_to_selector()` behavior

WordPress Trac noreply at wordpress.org
Tue Jun 20 17:52:47 UTC 2023


#58193: Introduce `WP_Theme_JSON::prepend_to_selector()` in favor of parameter to
conditionally modify `append_to_selector()` behavior
----------------------------------------------+--------------------------
 Reporter:  flixos90                          |       Owner:  flixos90
     Type:  enhancement                       |      Status:  closed
 Priority:  normal                            |   Milestone:  6.3
Component:  Editor                            |     Version:  5.8
 Severity:  normal                            |  Resolution:  fixed
 Keywords:  has-patch gutenberg-merge commit  |     Focuses:  performance
----------------------------------------------+--------------------------
Changes (by flixos90):

 * status:  assigned => closed
 * resolution:   => fixed


Comment:

 In [changeset:"55950" 55950]:
 {{{
 #!CommitTicketReference repository="" revision="55950"
 Editor: Introduce `WP_Theme_JSON::prepend_to_selector()` to improve code
 quality and performance.

 The `WP_Theme_JSON::append_to_selector()` method was previously used for
 both appending and prepending which violated the single responsibility
 principle. It resulted in additional conditionals which also came at a
 performance cost, particularly because the method is called over 1,000
 times during a regular WordPress request.

 With the new `WP_Theme_JSON::prepend_to_selector()` method, there are now
 two distinct methods for the two distinct purposes. The now useless third
 parameter on `WP_Theme_JSON::append_to_selector()` has been removed
 (rather than deprecated), which is acceptable given that it is a protected
 method on a class that is not intended for extensions.

 Props bor0, costdev, flixos90, isabel_brison, oandregal, spacedmonkey.
 Fixes #58193.
 See #58457.
 }}}

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/58193#comment:13>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list