Make WordPress Core


Ignore:
Timestamp:
02/06/2020 06:31:22 AM (5 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-load.php

    r47122 r47198  
    1919/** Define ABSPATH as this file's directory */
    2020if ( ! defined( 'ABSPATH' ) ) {
    21     define( 'ABSPATH', dirname( __FILE__ ) . '/' );
     21    define( 'ABSPATH', __DIR__ . '/' );
    2222}
    2323
     
    3535
    3636    /** The config file resides in ABSPATH */
    37     require_once( ABSPATH . 'wp-config.php' );
     37    require_once ABSPATH . 'wp-config.php';
    3838
    3939} elseif ( @file_exists( dirname( ABSPATH ) . '/wp-config.php' ) && ! @file_exists( dirname( ABSPATH ) . '/wp-settings.php' ) ) {
    4040
    4141    /** The config file resides one level above ABSPATH but is not part of another installation */
    42     require_once( dirname( ABSPATH ) . '/wp-config.php' );
     42    require_once dirname( ABSPATH ) . '/wp-config.php';
    4343
    4444} else {
     
    4747
    4848    define( 'WPINC', 'wp-includes' );
    49     require_once( ABSPATH . WPINC . '/load.php' );
     49    require_once ABSPATH . WPINC . '/load.php';
    5050
    5151    // Standardize $_SERVER variables across setups.
    5252    wp_fix_server_vars();
    5353
    54     require_once( ABSPATH . WPINC . '/functions.php' );
     54    require_once ABSPATH . WPINC . '/functions.php';
    5555
    5656    $path = wp_guess_url() . '/wp-admin/setup-config.php';
     
    6767
    6868    define( 'WP_CONTENT_DIR', ABSPATH . 'wp-content' );
    69     require_once( ABSPATH . WPINC . '/version.php' );
     69    require_once ABSPATH . WPINC . '/version.php';
    7070
    7171    wp_check_php_mysql_versions();
Note: See TracChangeset for help on using the changeset viewer.