[wp-trac] [WordPress Trac] #53306: Cleaner Code admin-footer.php ln 109

WordPress Trac noreply at wordpress.org
Mon May 31 11:03:06 UTC 2021


#53306: Cleaner Code admin-footer.php ln 109
----------------------------+-------------------------------
 Reporter:  jamil95         |       Owner:  (none)
     Type:  enhancement     |      Status:  new
 Priority:  normal          |   Milestone:  Awaiting Review
Component:  Administration  |     Version:  trunk
 Severity:  minor           |  Resolution:
 Keywords:  has-patch       |     Focuses:  coding-standards
----------------------------+-------------------------------
Changes (by SergeyBiryukov):

 * component:  General => Administration


Comment:

 Hi there, welcome to WordPress Trac! Thanks for the ticket and the PR.

 The existing code seems fine as is to me, it makes it clear that the
 comment only applies to the `function_exists()` check and not to the whole
 conditional.

 Personally, I find separate conditions on their own lines (where
 appropriate) easier to read than a longer line with multiple conditions.

 It also looks like the proposed code does not pass the WordPress Coding
 Standards check:
 https://github.com/WordPress/wordpress-
 develop/runs/2709582165?check_suite_focus=true

 Another option would be something like this, which is consistent with the
 pattern suggested in the "Complex control structure conditions" example in
 [https://make.wordpress.org/core/2020/03/20/updating-the-coding-standards-
 for-modern-php/ Updating the Coding standards for modern PHP] proposal,
 and used since then in many other places in core:
 {{{
 // get_site_option() won't exist when auto upgrading from <= 2.7.
 if ( function_exists( 'get_site_option' )
         && false === get_site_option( 'can_compress_scripts' )
 ) {
         compression_test();
 }
 }}}

 I'm not sure it offers any significant improvement over the current code
 either, but if the goal is to use a single `if` condition here, this would
 be my preference :)

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


More information about the wp-trac mailing list