[wp-trac] [WordPress Trac] #40188: Filter button should not appear when no comments are available in list

WordPress Trac noreply at wordpress.org
Thu Apr 13 07:18:48 UTC 2017


#40188: Filter button should not appear when no comments are available in list
--------------------------------------+---------------------------------
 Reporter:  swissspidy                |       Owner:
     Type:  defect (bug)              |      Status:  new
 Priority:  normal                    |   Milestone:  Awaiting Review
Component:  Comments                  |     Version:
 Severity:  normal                    |  Resolution:
 Keywords:  good-first-bug has-patch  |     Focuses:  ui, administration
--------------------------------------+---------------------------------

Comment (by swissspidy):

 It's really not needed though.

 {{{
 $comments = get_comments( array(
   'number' => 1,
 ) );
 if( $comments ) {
   return true;
 } else {
   return false;
 }
 }}}

 is a worse version of

 {{{
 return get_comments( array(
   'number' => 1,
 ) );
 }}}

 This means you can just as well use

 {{{
 if ( 'top' === $which && get_comments( array( 'number' => 1 ) ) ) { … }
 }}}

 which is way cleaner.

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


More information about the wp-trac mailing list