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/tests/phpunit/wp-mail-real-test.php

    r47122 r47198  
    1111    $opts = getopt( $options );
    1212} else {
    13     include( dirname( __FILE__ ) . '/wp-testlib/getopt.php' );
     13    require __DIR__ . '/wp-testlib/getopt.php';
    1414    $opts = getoptParser::getopt( $options );
    1515}
    1616
    17 define( 'DIR_TESTROOT', realpath( dirname( __FILE__ ) ) );
     17define( 'DIR_TESTROOT', realpath( __DIR__ ) );
    1818
    1919define( 'TEST_WP', true );
     
    3232ini_set( 'display_errors', true );
    3333
    34 require_once( DIR_TESTROOT . '/wp-testlib/utils.php' );
     34require_once DIR_TESTROOT . '/wp-testlib/utils.php';
    3535
    3636// Configure WP.
    37 require_once( DIR_TESTROOT . '/wp-config.php' );
     37require_once DIR_TESTROOT . '/wp-config.php';
    3838define( 'ABSPATH', realpath( DIR_WP ) . '/' );
    3939
     
    4646define( 'WP_INSTALLING', 1 );
    4747$_SERVER['PATH_INFO'] = $_SERVER['SCRIPT_NAME']; // Prevent a warning from some sloppy code in wp-settings.php.
    48 require_once( ABSPATH . 'wp-settings.php' );
     48require_once ABSPATH . 'wp-settings.php';
    4949
    5050drop_tables();
    5151
    52 require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
     52require_once ABSPATH . 'wp-admin/includes/upgrade.php';
    5353wp_install( WP_BLOG_TITLE, WP_USER_NAME, WP_USER_EMAIL, true );
    5454
Note: See TracChangeset for help on using the changeset viewer.