[wp-trac] [WordPress Trac] #62809: Optimize conditional checks and require_once logic for wp-load.php inclusion

WordPress Trac noreply at wordpress.org
Thu Jan 16 09:53:08 UTC 2025


#62809: Optimize conditional checks and require_once logic for wp-load.php
inclusion
-----------------------------------------+------------------------------
 Reporter:  hussain896                   |       Owner:  (none)
     Type:  enhancement                  |      Status:  assigned
 Priority:  normal                       |   Milestone:  Awaiting Review
Component:  Upload                       |     Version:  6.7.1
 Severity:  normal                       |  Resolution:
 Keywords:  has-patch 2nd-opinion close  |     Focuses:  administration
-----------------------------------------+------------------------------

Comment (by knutsp):

 I can see the small enhanced consistency, as current code repeats the
 statement `require_once` the and filename string `wp-load.php` in both
 conditional (one line) code blocks, by making it a bit more DRY.

 But the proposed code doesn't follow the DRY principle consistently when
 not also avoiding the common `wp-load.php` from being repeated. Being
 really consistent and DRY, the code should become:
 {{{
 require_once ( defined( 'ABSPATH' )
     ? ABSPATH
     : dirname( __DIR__ ) . '/'
     ) . 'wp-load.php';
 }}}

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


More information about the wp-trac mailing list