[wp-trac] [WordPress Trac] #23089: Rewrite a confusing condition in default-widgets.php

WordPress Trac noreply at wordpress.org
Mon Dec 31 18:56:44 UTC 2012


#23089: Rewrite a confusing condition in default-widgets.php
-------------------------+-----------------------
 Reporter:  alexvorn2    |       Owner:
     Type:  enhancement  |      Status:  reopened
 Priority:  lowest       |   Milestone:  3.6
Component:  Widgets      |     Version:
 Severity:  minor        |  Resolution:
 Keywords:  has-patch    |
-------------------------+-----------------------

Comment (by azaozz):

 Replying to [comment:3 scribu]:
 > A more readable version...

 +1. I think we had something about not doing assignments inside of `if (
 ... )` in the [http://codex.wordpress.org/WordPress_Coding_Standards
 coding standards], not seeing it now.

 Replying to [comment:6 SergeyBiryukov]:

 Yeah, that is far better:

 {{{
 $number = isset( $instance['number'] ) ? absint( $instance['number'] ) :
 5;
 }}}

 Perhaps the `isset()` has to be `!empty()` so it doesn't allow `$number`
 to be 0 (zero).

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/23089#comment:8>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list