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

    r47119 r47198  
    657657            define( 'WP_SANDBOX_SCRAPING', true );
    658658        }
    659         include_once( WP_PLUGIN_DIR . '/' . $plugin );
     659        include_once WP_PLUGIN_DIR . '/' . $plugin;
    660660        $plugin = $_wp_plugin_file; // Avoid stomping of the $plugin variable in a plugin.
    661661
     
    908908    if ( false === $credentials ) {
    909909        if ( ! empty( $data ) ) {
    910             include_once( ABSPATH . 'wp-admin/admin-header.php' );
     910            require_once ABSPATH . 'wp-admin/admin-header.php';
    911911            echo $data;
    912             include( ABSPATH . 'wp-admin/admin-footer.php' );
     912            require_once ABSPATH . 'wp-admin/admin-footer.php';
    913913            exit;
    914914        }
     
    923923
    924924        if ( ! empty( $data ) ) {
    925             include_once( ABSPATH . 'wp-admin/admin-header.php' );
     925            require_once ABSPATH . 'wp-admin/admin-header.php';
    926926            echo $data;
    927             include( ABSPATH . 'wp-admin/admin-footer.php' );
     927            require_once ABSPATH . 'wp-admin/admin-footer.php';
    928928            exit;
    929929        }
     
    12201220        define( 'WP_UNINSTALL_PLUGIN', $file );
    12211221        wp_register_plugin_realpath( WP_PLUGIN_DIR . '/' . $file );
    1222         include( WP_PLUGIN_DIR . '/' . dirname( $file ) . '/uninstall.php' );
     1222        include WP_PLUGIN_DIR . '/' . dirname( $file ) . '/uninstall.php';
    12231223
    12241224        return true;
     
    12321232
    12331233        wp_register_plugin_realpath( WP_PLUGIN_DIR . '/' . $file );
    1234         include( WP_PLUGIN_DIR . '/' . $file );
     1234        include WP_PLUGIN_DIR . '/' . $file;
    12351235
    12361236        add_action( "uninstall_{$file}", $callable );
     
    22532253    }
    22542254    wp_register_plugin_realpath( WP_PLUGIN_DIR . '/' . $plugin );
    2255     include( WP_PLUGIN_DIR . '/' . $plugin );
     2255    include WP_PLUGIN_DIR . '/' . $plugin;
    22562256}
    22572257
     
    23082308
    23092309    if ( ! class_exists( 'WP_Privacy_Policy_Content' ) ) {
    2310         require_once( ABSPATH . 'wp-admin/includes/class-wp-privacy-policy-content.php' );
     2310        require_once ABSPATH . 'wp-admin/includes/class-wp-privacy-policy-content.php';
    23112311    }
    23122312
Note: See TracChangeset for help on using the changeset viewer.