[wp-trac] [WordPress Trac] #52694: Twenty Twenty-One: Primary menu toggle filter adds toggles to third party menu locations

WordPress Trac noreply at wordpress.org
Mon Jun 3 09:34:48 UTC 2024


#52694: Twenty Twenty-One: Primary menu toggle filter adds toggles to third party
menu locations
-------------------------------------+---------------------
 Reporter:  domainsupport            |       Owner:  (none)
     Type:  defect (bug)             |      Status:  new
 Priority:  normal                   |   Milestone:  6.6
Component:  Bundled Theme            |     Version:
 Severity:  normal                   |  Resolution:
 Keywords:  has-patch needs-testing  |     Focuses:
-------------------------------------+---------------------

Comment (by SergeyBiryukov):

 Replying to [comment:15 poena]:
 > Personally, I prefer wrapping this long line in two, it is easier for me
 to read.

 Yes, there's no official rule about line length as far as I remember, but
 I prefer shorter lines too, otherwise it increases cognitive load for me.

 There was a “Complex control structure conditions” section in
 [https://make.wordpress.org/core/2020/03/20/updating-the-coding-standards-
 for-modern-php/ this proposal]:
 > A control structure statement with multiple conditions can make for very
 long lines making code harder to read.
 >
 > It is encouraged (but not enforced) that these long conditions are split
 into multiple lines.
 >
 > When a long condition statement is split over multiple lines, the
 following (new) rules are proposed in addition to the existing rules for
 control structure formatting:
 > 1. The first condition should be on the same line as the control
 structure keyword.
 > 2. The closing parenthesis for the control structure should be on a new
 line, indented the same as the control structure keyword and followed by a
 space and the opening curly brace of the control structure.
 > 3. When splitting the conditions into multiple lines, the
 boolean/logical operators separating the statements should always be
 placed at the start of the new line. This makes for smaller change-sets
 and improves readability.
 >
 > Note: even with conditions spread out over multiple lines, multiple
 conditions per line will still be allowed as long as the condition
 grouping makes sense.

 So I would rewrite the code in question like this:
 {{{
 if ( isset( $args->theme_location ) && 'primary' === $args->theme_location
         && 0 === $depth && in_array( 'menu-item-has-children',
 $item->classes, true )
 ) {
 }}}

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


More information about the wp-trac mailing list