Make WordPress Core


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

    r47164 r47198  
    1818
    1919/** WordPress Dependency Class */
    20 require( ABSPATH . WPINC . '/class-wp-dependency.php' );
     20require ABSPATH . WPINC . '/class-wp-dependency.php';
    2121
    2222/** WordPress Dependencies Class */
    23 require( ABSPATH . WPINC . '/class.wp-dependencies.php' );
     23require ABSPATH . WPINC . '/class.wp-dependencies.php';
    2424
    2525/** WordPress Scripts Class */
    26 require( ABSPATH . WPINC . '/class.wp-scripts.php' );
     26require ABSPATH . WPINC . '/class.wp-scripts.php';
    2727
    2828/** WordPress Scripts Functions */
    29 require( ABSPATH . WPINC . '/functions.wp-scripts.php' );
     29require ABSPATH . WPINC . '/functions.wp-scripts.php';
    3030
    3131/** WordPress Styles Class */
    32 require( ABSPATH . WPINC . '/class.wp-styles.php' );
     32require ABSPATH . WPINC . '/class.wp-styles.php';
    3333
    3434/** WordPress Styles Functions */
    35 require( ABSPATH . WPINC . '/functions.wp-styles.php' );
     35require ABSPATH . WPINC . '/functions.wp-styles.php';
    3636
    3737/**
     
    255255        'i18n',
    256256        'is-shallow-equal',
    257         'keyboard-shortcuts',
    258257        'keycodes',
    259258        'list-reusable-blocks',
     
    296295        }
    297296
    298         $asset_file   = include ABSPATH . WPINC . "/assets/dist/$package$suffix.asset.php";
     297        $asset_file   = require ABSPATH . WPINC . "/assets/dist/$package$suffix.asset.php";
    299298        $dependencies = $asset_file['dependencies'];
    300299
     
    597596    if ( $suffixes === null ) {
    598597        // Include an unmodified $wp_version.
    599         include( ABSPATH . WPINC . '/version.php' );
     598        require ABSPATH . WPINC . '/version.php';
    600599
    601600        $develop_src = false !== strpos( $wp_version, '-src' );
     
    16671666function wp_default_styles( &$styles ) {
    16681667    // Include an unmodified $wp_version.
    1669     include( ABSPATH . WPINC . '/version.php' );
     1668    require ABSPATH . WPINC . '/version.php';
    16701669
    16711670    if ( ! defined( 'SCRIPT_DEBUG' ) ) {
     
    20432042    }
    20442043
    2045     require_once( ABSPATH . 'wp-admin/includes/class-wp-community-events.php' );
     2044    require_once ABSPATH . 'wp-admin/includes/class-wp-community-events.php';
    20462045
    20472046    $user_id            = get_current_user_id();
Note: See TracChangeset for help on using the changeset viewer.