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-admin/update-core.php

    r47122 r47198  
    88
    99/** WordPress Administration Bootstrap */
    10 require_once( dirname( __FILE__ ) . '/admin.php' );
     10require_once __DIR__ . '/admin.php';
    1111
    1212wp_enqueue_style( 'plugin-install' );
     
    298298    $cur_wp_version = preg_replace( '/-.*$/', '', $wp_version );
    299299
    300     require_once( ABSPATH . 'wp-admin/includes/plugin-install.php' );
     300    require_once ABSPATH . 'wp-admin/includes/plugin-install.php';
    301301    $plugins = get_plugin_updates();
    302302    if ( empty( $plugins ) ) {
     
    560560    global $wp_filesystem;
    561561
    562     include_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' );
     562    require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
    563563
    564564    if ( $reinstall ) {
     
    737737    wp_version_check( array(), $force_check );
    738738
    739     require_once( ABSPATH . 'wp-admin/admin-header.php' );
     739    require_once ABSPATH . 'wp-admin/admin-header.php';
    740740    ?>
    741741    <div class="wrap">
     
    794794    );
    795795
    796     include( ABSPATH . 'wp-admin/admin-footer.php' );
     796    require_once ABSPATH . 'wp-admin/admin-footer.php';
    797797
    798798} elseif ( 'do-core-upgrade' == $action || 'do-core-reinstall' == $action ) {
     
    811811    }
    812812
    813     require_once( ABSPATH . 'wp-admin/admin-header.php' );
     813    require_once ABSPATH . 'wp-admin/admin-header.php';
    814814    if ( 'do-core-reinstall' == $action ) {
    815815        $reinstall = true;
     
    830830    );
    831831
    832     include( ABSPATH . 'wp-admin/admin-footer.php' );
     832    require_once ABSPATH . 'wp-admin/admin-footer.php';
    833833
    834834} elseif ( 'do-plugin-upgrade' == $action ) {
     
    854854    $title = __( 'Update Plugins' );
    855855
    856     require_once( ABSPATH . 'wp-admin/admin-header.php' );
     856    require_once ABSPATH . 'wp-admin/admin-header.php';
    857857    echo '<div class="wrap">';
    858858    echo '<h1>' . __( 'Update Plugins' ) . '</h1>';
     
    868868    );
    869869
    870     include( ABSPATH . 'wp-admin/admin-footer.php' );
     870    require_once ABSPATH . 'wp-admin/admin-footer.php';
    871871
    872872} elseif ( 'do-theme-upgrade' == $action ) {
     
    892892    $title = __( 'Update Themes' );
    893893
    894     require_once( ABSPATH . 'wp-admin/admin-header.php' );
     894    require_once ABSPATH . 'wp-admin/admin-header.php';
    895895    ?>
    896896    <div class="wrap">
     
    908908    );
    909909
    910     include( ABSPATH . 'wp-admin/admin-footer.php' );
     910    require_once ABSPATH . 'wp-admin/admin-footer.php';
    911911
    912912} elseif ( 'do-translation-upgrade' == $action ) {
     
    918918    check_admin_referer( 'upgrade-translations' );
    919919
    920     require_once( ABSPATH . 'wp-admin/admin-header.php' );
    921     include_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' );
     920    require_once ABSPATH . 'wp-admin/admin-header.php';
     921    require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
    922922
    923923    $url     = 'update-core.php?action=do-translation-upgrade';
     
    937937    );
    938938
    939     require_once( ABSPATH . 'wp-admin/admin-footer.php' );
     939    require_once ABSPATH . 'wp-admin/admin-footer.php';
    940940
    941941} else {
Note: See TracChangeset for help on using the changeset viewer.