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.

git-svn-id: https://develop.svn.wordpress.org/trunk@47198 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov
2020-02-06 06:31:22 +00:00
parent b02e49c2e8
commit e72fff9cef
304 changed files with 1068 additions and 1063 deletions
+8 -8
View File
@@ -8,7 +8,7 @@
*/
/** Load WordPress Administration Bootstrap */
require_once( dirname( __FILE__ ) . '/admin.php' );
require_once __DIR__ . '/admin.php';
if ( ! current_user_can( 'manage_network_themes' ) ) {
wp_die( __( 'Sorry, you are not allowed to manage network themes.' ) );
@@ -76,7 +76,7 @@ if ( $action ) {
$title = __( 'Update Themes' );
$parent_file = 'themes.php';
require_once( ABSPATH . 'wp-admin/admin-header.php' );
require_once ABSPATH . 'wp-admin/admin-header.php';
echo '<div class="wrap">';
echo '<h1>' . esc_html( $title ) . '</h1>';
@@ -86,7 +86,7 @@ if ( $action ) {
echo "<iframe src='$url' style='width: 100%; height:100%; min-height:850px;'></iframe>";
echo '</div>';
require_once( ABSPATH . 'wp-admin/admin-footer.php' );
require_once ABSPATH . 'wp-admin/admin-footer.php';
exit;
case 'delete-selected':
if ( ! current_user_can( 'delete_themes' ) ) {
@@ -114,13 +114,13 @@ if ( $action ) {
$theme_info[ $theme ] = wp_get_theme( $theme );
}
include( ABSPATH . 'wp-admin/update.php' );
require ABSPATH . 'wp-admin/update.php';
$parent_file = 'themes.php';
if ( ! isset( $_REQUEST['verify-delete'] ) ) {
wp_enqueue_script( 'jquery' );
require_once( ABSPATH . 'wp-admin/admin-header.php' );
require_once ABSPATH . 'wp-admin/admin-header.php';
$themes_to_delete = count( $themes );
?>
<div class="wrap">
@@ -175,7 +175,7 @@ if ( $action ) {
</form>
</div>
<?php
require_once( ABSPATH . 'wp-admin/admin-footer.php' );
require_once ABSPATH . 'wp-admin/admin-footer.php';
exit;
} // End if verify-delete.
@@ -261,7 +261,7 @@ $parent_file = 'themes.php';
wp_enqueue_script( 'updates' );
wp_enqueue_script( 'theme-preview' );
require_once( ABSPATH . 'wp-admin/admin-header.php' );
require_once ABSPATH . 'wp-admin/admin-header.php';
?>
@@ -343,4 +343,4 @@ wp_print_request_filesystem_credentials_modal();
wp_print_admin_notice_templates();
wp_print_update_row_templates();
include( ABSPATH . 'wp-admin/admin-footer.php' );
require_once ABSPATH . 'wp-admin/admin-footer.php';