Make WordPress Core


Ignore:
Timestamp:
02/06/2020 06:31:22 AM (7 years ago)
Author:
SergeyBiryukov
Message:

Code Modernization: Replace dirname( __FILE__ ) calls with __DIR__ magic constant.

This avoids the performance overhead of the function call every time dirname( __FILE__ ) was used instead of __DIR__.

This commit also includes:

  • Removing unnecessary parentheses from include/require statements. These are language constructs, not function calls.
  • Replacing include statements for several files with require_once, for consistency:
    • wp-admin/admin-header.php
    • wp-admin/admin-footer.php
    • wp-includes/version.php

Props ayeshrajans, desrosj, valentinbora, jrf, joostdevalk, netweb.
Fixes #48082.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/load.php

    r47156 r47198  
    140140
    141141        if ( ! extension_loaded( 'mysql' ) && ! extension_loaded( 'mysqli' ) && ! extension_loaded( 'mysqlnd' ) && ! file_exists( WP_CONTENT_DIR . '/db.php' ) ) {
    142                 require_once( ABSPATH . WPINC . '/functions.php' );
     142                require_once ABSPATH . WPINC . '/functions.php';
    143143                wp_load_translations_early();
    144144                $args = array(
     
    193193        global $upgrading;
    194194
    195         include( ABSPATH . '.maintenance' );
     195        require ABSPATH . '.maintenance';
    196196        // If the $upgrading timestamp is older than 10 minutes, don't die.
    197197        if ( ( time() - $upgrading ) >= 600 ) {
     
    217217
    218218        if ( file_exists( WP_CONTENT_DIR . '/maintenance.php' ) ) {
    219                 require_once( WP_CONTENT_DIR . '/maintenance.php' );
     219                require_once WP_CONTENT_DIR . '/maintenance.php';
    220220                die();
    221221        }
    222222
    223         require_once( ABSPATH . WPINC . '/functions.php' );
     223        require_once ABSPATH . WPINC . '/functions.php';
    224224        wp_load_translations_early();
    225225
     
    410410        global $wpdb;
    411411
    412         require_once( ABSPATH . WPINC . '/wp-db.php' );
     412        require_once ABSPATH . WPINC . '/wp-db.php';
    413413        if ( file_exists( WP_CONTENT_DIR . '/db.php' ) ) {
    414                 require_once( WP_CONTENT_DIR . '/db.php' );
     414                require_once WP_CONTENT_DIR . '/db.php';
    415415        }
    416416
     
    545545                         */
    546546                        if ( file_exists( WP_CONTENT_DIR . '/object-cache.php' ) ) {
    547                                 require_once( WP_CONTENT_DIR . '/object-cache.php' );
     547                                require_once WP_CONTENT_DIR . '/object-cache.php';
    548548                                if ( function_exists( 'wp_cache_init' ) ) {
    549549                                        wp_using_ext_object_cache( true );
     
    567567
    568568        if ( ! wp_using_ext_object_cache() ) {
    569                 require_once( ABSPATH . WPINC . '/cache.php' );
     569                require_once ABSPATH . WPINC . '/cache.php';
    570570        }
    571571
     
    607607                nocache_headers();
    608608
    609                 require( ABSPATH . WPINC . '/kses.php' );
    610                 require( ABSPATH . WPINC . '/pluggable.php' );
     609                require ABSPATH . WPINC . '/kses.php';
     610                require ABSPATH . WPINC . '/pluggable.php';
    611611
    612612                $link = wp_guess_url() . '/wp-admin/install.php';
Note: See TracChangeset for help on using the changeset viewer.