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/network/themes.php

    r47122 r47198  
    99
    1010/** Load WordPress Administration Bootstrap */
    11 require_once( dirname( __FILE__ ) . '/admin.php' );
     11require_once __DIR__ . '/admin.php';
    1212
    1313if ( ! current_user_can( 'manage_network_themes' ) ) {
     
    7777            $parent_file = 'themes.php';
    7878
    79             require_once( ABSPATH . 'wp-admin/admin-header.php' );
     79            require_once ABSPATH . 'wp-admin/admin-header.php';
    8080
    8181            echo '<div class="wrap">';
     
    8787            echo "<iframe src='$url' style='width: 100%; height:100%; min-height:850px;'></iframe>";
    8888            echo '</div>';
    89             require_once( ABSPATH . 'wp-admin/admin-footer.php' );
     89            require_once ABSPATH . 'wp-admin/admin-footer.php';
    9090            exit;
    9191        case 'delete-selected':
     
    115115            }
    116116
    117             include( ABSPATH . 'wp-admin/update.php' );
     117            require ABSPATH . 'wp-admin/update.php';
    118118
    119119            $parent_file = 'themes.php';
     
    121121            if ( ! isset( $_REQUEST['verify-delete'] ) ) {
    122122                wp_enqueue_script( 'jquery' );
    123                 require_once( ABSPATH . 'wp-admin/admin-header.php' );
     123                require_once ABSPATH . 'wp-admin/admin-header.php';
    124124                $themes_to_delete = count( $themes );
    125125                ?>
     
    176176            </div>
    177177                <?php
    178                 require_once( ABSPATH . 'wp-admin/admin-footer.php' );
     178                require_once ABSPATH . 'wp-admin/admin-footer.php';
    179179                exit;
    180180            } // End if verify-delete.
     
    262262wp_enqueue_script( 'theme-preview' );
    263263
    264 require_once( ABSPATH . 'wp-admin/admin-header.php' );
     264require_once ABSPATH . 'wp-admin/admin-header.php';
    265265
    266266?>
     
    344344wp_print_update_row_templates();
    345345
    346 include( ABSPATH . 'wp-admin/admin-footer.php' );
     346require_once ABSPATH . 'wp-admin/admin-footer.php';
Note: See TracChangeset for help on using the changeset viewer.