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

    r47122 r47198  
    1212
    1313/** WordPress Administration Bootstrap */
    14 require_once( dirname( __FILE__ ) . '/admin.php' );
    15 
    16 include_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' );
     14require_once __DIR__ . '/admin.php';
     15
     16require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
    1717
    1818if ( isset( $_GET['action'] ) ) {
     
    6161
    6262        wp_enqueue_script( 'updates' );
    63         require_once( ABSPATH . 'wp-admin/admin-header.php' );
     63        require_once ABSPATH . 'wp-admin/admin-header.php';
    6464
    6565        $nonce = 'upgrade-plugin_' . $plugin;
     
    6969        $upgrader->upgrade( $plugin );
    7070
    71         include( ABSPATH . 'wp-admin/admin-footer.php' );
     71        require_once ABSPATH . 'wp-admin/admin-footer.php';
    7272
    7373    } elseif ( 'activate-plugin' == $action ) {
     
    9494            ini_set( 'display_errors', true ); // Ensure that fatal errors are displayed.
    9595            wp_register_plugin_realpath( WP_PLUGIN_DIR . '/' . $plugin );
    96             include( WP_PLUGIN_DIR . '/' . $plugin );
     96            include WP_PLUGIN_DIR . '/' . $plugin;
    9797        }
    9898        iframe_footer();
     
    103103        }
    104104
    105         include_once( ABSPATH . 'wp-admin/includes/plugin-install.php' ); // For plugins_api().
     105        include_once ABSPATH . 'wp-admin/includes/plugin-install.php'; // For plugins_api().
    106106
    107107        check_admin_referer( 'install-plugin_' . $plugin );
     
    123123        $parent_file  = 'plugins.php';
    124124        $submenu_file = 'plugin-install.php';
    125         require_once( ABSPATH . 'wp-admin/admin-header.php' );
     125        require_once ABSPATH . 'wp-admin/admin-header.php';
    126126
    127127        /* translators: %s: Plugin name and version. */
     
    138138        $upgrader->install( $api->download_link );
    139139
    140         include( ABSPATH . 'wp-admin/admin-footer.php' );
     140        require_once ABSPATH . 'wp-admin/admin-footer.php';
    141141
    142142    } elseif ( 'upload-plugin' == $action ) {
     
    153153        $parent_file  = 'plugins.php';
    154154        $submenu_file = 'plugin-install.php';
    155         require_once( ABSPATH . 'wp-admin/admin-header.php' );
     155        require_once ABSPATH . 'wp-admin/admin-header.php';
    156156
    157157        /* translators: %s: File name. */
     
    168168        }
    169169
    170         include( ABSPATH . 'wp-admin/admin-footer.php' );
     170        require_once ABSPATH . 'wp-admin/admin-footer.php';
    171171
    172172    } elseif ( 'upgrade-theme' == $action ) {
     
    183183        $parent_file  = 'themes.php';
    184184        $submenu_file = 'themes.php';
    185         require_once( ABSPATH . 'wp-admin/admin-header.php' );
     185        require_once ABSPATH . 'wp-admin/admin-header.php';
    186186
    187187        $nonce = 'upgrade-theme_' . $theme;
     
    191191        $upgrader->upgrade( $theme );
    192192
    193         include( ABSPATH . 'wp-admin/admin-footer.php' );
     193        require_once ABSPATH . 'wp-admin/admin-footer.php';
    194194    } elseif ( 'update-selected-themes' == $action ) {
    195195        if ( ! current_user_can( 'update_themes' ) ) {
     
    225225        }
    226226
    227         include_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' ); // For themes_api().
     227        include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; // For themes_api().
    228228
    229229        check_admin_referer( 'install-theme_' . $theme );
     
    246246        $parent_file  = 'themes.php';
    247247        $submenu_file = 'themes.php';
    248         require_once( ABSPATH . 'wp-admin/admin-header.php' );
     248        require_once ABSPATH . 'wp-admin/admin-header.php';
    249249
    250250        /* translators: %s: Theme name and version. */
     
    257257        $upgrader->install( $api->download_link );
    258258
    259         include( ABSPATH . 'wp-admin/admin-footer.php' );
     259        require_once ABSPATH . 'wp-admin/admin-footer.php';
    260260
    261261    } elseif ( 'upload-theme' == $action ) {
     
    273273        $submenu_file = 'theme-install.php';
    274274
    275         require_once( ABSPATH . 'wp-admin/admin-header.php' );
     275        require_once ABSPATH . 'wp-admin/admin-header.php';
    276276
    277277        /* translators: %s: File name. */
     
    288288        }
    289289
    290         include( ABSPATH . 'wp-admin/admin-footer.php' );
     290        require_once ABSPATH . 'wp-admin/admin-footer.php';
    291291
    292292    } else {
Note: See TracChangeset for help on using the changeset viewer.