[wp-trac] [WordPress Trac] #33646: #a11y-headings - the Screen Options h5

WordPress Trac noreply at wordpress.org
Wed Sep 23 05:59:45 UTC 2015


#33646: #a11y-headings - the Screen Options h5
-------------------------------------+----------------------------
 Reporter:  afercia                  |       Owner:  joedolson
     Type:  defect (bug)             |      Status:  accepted
 Priority:  normal                   |   Milestone:  4.4
Component:  Administration           |     Version:  4.3
 Severity:  normal                   |  Resolution:
 Keywords:  has-patch needs-testing  |     Focuses:  accessibility
-------------------------------------+----------------------------

Comment (by westonruter):

 Instead of duplicating the conditional logic, having two instances each
 of:

 {{{#!php
 if ( isset( $wp_meta_boxes[ $this->id ] ) || $this->get_option( 'per_page'
 ) || ( $columns && empty( $columns['_title'] ) ) ) :
 }}}
 and
 {{{#!php
 if ( ! empty( $columns['_title'] ) ) :
 }}}

 I suggest storing the value for the conditional in a variable:

 {{{#!php
 $do_outer_fieldset_wrap = (
     isset( $wp_meta_boxes[ $this->id ] )
     ||
     $this->get_option( 'per_page' )
     ||
     ( $columns && empty( $columns['_title'] ) )
 );
 $do_inner_fieldset_wrap = ( ! empty( $columns['_title'] ) );
 }}}

 And then use these bare variables in the `if` conditions.

 This will keep the code DRYer and less prone to error when/if the
 conditions change.

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


More information about the wp-trac mailing list