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-includes/functions.php

    r47156 r47198  
    66 */
    77
    8 require( ABSPATH . WPINC . '/option.php' );
     8require ABSPATH . WPINC . '/option.php';
    99
    1010/**
     
    836836
    837837    // @todo Tidy this code and make the debug code optional.
    838     include_once( ABSPATH . WPINC . '/class-IXR.php' );
     838    include_once ABSPATH . WPINC . '/class-IXR.php';
    839839
    840840    $post = get_post( $post );
     
    45734573    }
    45744574
    4575     require_once( ABSPATH . WPINC . '/default-widgets.php' );
     4575    require_once ABSPATH . WPINC . '/default-widgets.php';
    45764576
    45774577    add_action( '_admin_menu', 'wp_widgets_add_menu' );
     
    46354635    // Load custom DB error template, if present.
    46364636    if ( file_exists( WP_CONTENT_DIR . '/db-error.php' ) ) {
    4637         require_once( WP_CONTENT_DIR . '/db-error.php' );
     4637        require_once WP_CONTENT_DIR . '/db-error.php';
    46384638        die();
    46394639    }
     
    72607260    }
    72617261
    7262     require_once( ABSPATH . 'wp-admin/includes/file.php' );
     7262    require_once ABSPATH . 'wp-admin/includes/file.php';
    72637263    $export_files = list_files( $exports_dir, 100, array( 'index.html' ) );
    72647264
Note: See TracChangeset for help on using the changeset viewer.