mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-04-07 22:24:36 +00:00
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:
@@ -11,9 +11,9 @@ if ( ! defined( 'IFRAME_REQUEST' ) && isset( $_GET['action'] ) && in_array( $_GE
|
||||
}
|
||||
|
||||
/** WordPress Administration Bootstrap */
|
||||
require_once( dirname( __FILE__ ) . '/admin.php' );
|
||||
require_once __DIR__ . '/admin.php';
|
||||
|
||||
include_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' );
|
||||
require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
|
||||
|
||||
if ( isset( $_GET['action'] ) ) {
|
||||
$plugin = isset( $_REQUEST['plugin'] ) ? trim( $_REQUEST['plugin'] ) : '';
|
||||
@@ -60,7 +60,7 @@ if ( isset( $_GET['action'] ) ) {
|
||||
$submenu_file = 'plugins.php';
|
||||
|
||||
wp_enqueue_script( 'updates' );
|
||||
require_once( ABSPATH . 'wp-admin/admin-header.php' );
|
||||
require_once ABSPATH . 'wp-admin/admin-header.php';
|
||||
|
||||
$nonce = 'upgrade-plugin_' . $plugin;
|
||||
$url = 'update.php?action=upgrade-plugin&plugin=' . urlencode( $plugin );
|
||||
@@ -68,7 +68,7 @@ if ( isset( $_GET['action'] ) ) {
|
||||
$upgrader = new Plugin_Upgrader( new Plugin_Upgrader_Skin( compact( 'title', 'nonce', 'url', 'plugin' ) ) );
|
||||
$upgrader->upgrade( $plugin );
|
||||
|
||||
include( ABSPATH . 'wp-admin/admin-footer.php' );
|
||||
require_once ABSPATH . 'wp-admin/admin-footer.php';
|
||||
|
||||
} elseif ( 'activate-plugin' == $action ) {
|
||||
if ( ! current_user_can( 'update_plugins' ) ) {
|
||||
@@ -93,7 +93,7 @@ if ( isset( $_GET['action'] ) ) {
|
||||
error_reporting( E_CORE_ERROR | E_CORE_WARNING | E_COMPILE_ERROR | E_ERROR | E_WARNING | E_PARSE | E_USER_ERROR | E_USER_WARNING | E_RECOVERABLE_ERROR );
|
||||
ini_set( 'display_errors', true ); // Ensure that fatal errors are displayed.
|
||||
wp_register_plugin_realpath( WP_PLUGIN_DIR . '/' . $plugin );
|
||||
include( WP_PLUGIN_DIR . '/' . $plugin );
|
||||
include WP_PLUGIN_DIR . '/' . $plugin;
|
||||
}
|
||||
iframe_footer();
|
||||
} elseif ( 'install-plugin' == $action ) {
|
||||
@@ -102,7 +102,7 @@ if ( isset( $_GET['action'] ) ) {
|
||||
wp_die( __( 'Sorry, you are not allowed to install plugins on this site.' ) );
|
||||
}
|
||||
|
||||
include_once( ABSPATH . 'wp-admin/includes/plugin-install.php' ); // For plugins_api().
|
||||
include_once ABSPATH . 'wp-admin/includes/plugin-install.php'; // For plugins_api().
|
||||
|
||||
check_admin_referer( 'install-plugin_' . $plugin );
|
||||
$api = plugins_api(
|
||||
@@ -122,7 +122,7 @@ if ( isset( $_GET['action'] ) ) {
|
||||
$title = __( 'Plugin Installation' );
|
||||
$parent_file = 'plugins.php';
|
||||
$submenu_file = 'plugin-install.php';
|
||||
require_once( ABSPATH . 'wp-admin/admin-header.php' );
|
||||
require_once ABSPATH . 'wp-admin/admin-header.php';
|
||||
|
||||
/* translators: %s: Plugin name and version. */
|
||||
$title = sprintf( __( 'Installing Plugin: %s' ), $api->name . ' ' . $api->version );
|
||||
@@ -137,7 +137,7 @@ if ( isset( $_GET['action'] ) ) {
|
||||
$upgrader = new Plugin_Upgrader( new Plugin_Installer_Skin( compact( 'title', 'url', 'nonce', 'plugin', 'api' ) ) );
|
||||
$upgrader->install( $api->download_link );
|
||||
|
||||
include( ABSPATH . 'wp-admin/admin-footer.php' );
|
||||
require_once ABSPATH . 'wp-admin/admin-footer.php';
|
||||
|
||||
} elseif ( 'upload-plugin' == $action ) {
|
||||
|
||||
@@ -152,7 +152,7 @@ if ( isset( $_GET['action'] ) ) {
|
||||
$title = __( 'Upload Plugin' );
|
||||
$parent_file = 'plugins.php';
|
||||
$submenu_file = 'plugin-install.php';
|
||||
require_once( ABSPATH . 'wp-admin/admin-header.php' );
|
||||
require_once ABSPATH . 'wp-admin/admin-header.php';
|
||||
|
||||
/* translators: %s: File name. */
|
||||
$title = sprintf( __( 'Installing Plugin from uploaded file: %s' ), esc_html( basename( $file_upload->filename ) ) );
|
||||
@@ -167,7 +167,7 @@ if ( isset( $_GET['action'] ) ) {
|
||||
$file_upload->cleanup();
|
||||
}
|
||||
|
||||
include( ABSPATH . 'wp-admin/admin-footer.php' );
|
||||
require_once ABSPATH . 'wp-admin/admin-footer.php';
|
||||
|
||||
} elseif ( 'upgrade-theme' == $action ) {
|
||||
|
||||
@@ -182,7 +182,7 @@ if ( isset( $_GET['action'] ) ) {
|
||||
$title = __( 'Update Theme' );
|
||||
$parent_file = 'themes.php';
|
||||
$submenu_file = 'themes.php';
|
||||
require_once( ABSPATH . 'wp-admin/admin-header.php' );
|
||||
require_once ABSPATH . 'wp-admin/admin-header.php';
|
||||
|
||||
$nonce = 'upgrade-theme_' . $theme;
|
||||
$url = 'update.php?action=upgrade-theme&theme=' . urlencode( $theme );
|
||||
@@ -190,7 +190,7 @@ if ( isset( $_GET['action'] ) ) {
|
||||
$upgrader = new Theme_Upgrader( new Theme_Upgrader_Skin( compact( 'title', 'nonce', 'url', 'theme' ) ) );
|
||||
$upgrader->upgrade( $theme );
|
||||
|
||||
include( ABSPATH . 'wp-admin/admin-footer.php' );
|
||||
require_once ABSPATH . 'wp-admin/admin-footer.php';
|
||||
} elseif ( 'update-selected-themes' == $action ) {
|
||||
if ( ! current_user_can( 'update_themes' ) ) {
|
||||
wp_die( __( 'Sorry, you are not allowed to update themes for this site.' ) );
|
||||
@@ -224,7 +224,7 @@ if ( isset( $_GET['action'] ) ) {
|
||||
wp_die( __( 'Sorry, you are not allowed to install themes on this site.' ) );
|
||||
}
|
||||
|
||||
include_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' ); // For themes_api().
|
||||
include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; // For themes_api().
|
||||
|
||||
check_admin_referer( 'install-theme_' . $theme );
|
||||
$api = themes_api(
|
||||
@@ -245,7 +245,7 @@ if ( isset( $_GET['action'] ) ) {
|
||||
$title = __( 'Install Themes' );
|
||||
$parent_file = 'themes.php';
|
||||
$submenu_file = 'themes.php';
|
||||
require_once( ABSPATH . 'wp-admin/admin-header.php' );
|
||||
require_once ABSPATH . 'wp-admin/admin-header.php';
|
||||
|
||||
/* translators: %s: Theme name and version. */
|
||||
$title = sprintf( __( 'Installing Theme: %s' ), $api->name . ' ' . $api->version );
|
||||
@@ -256,7 +256,7 @@ if ( isset( $_GET['action'] ) ) {
|
||||
$upgrader = new Theme_Upgrader( new Theme_Installer_Skin( compact( 'title', 'url', 'nonce', 'plugin', 'api' ) ) );
|
||||
$upgrader->install( $api->download_link );
|
||||
|
||||
include( ABSPATH . 'wp-admin/admin-footer.php' );
|
||||
require_once ABSPATH . 'wp-admin/admin-footer.php';
|
||||
|
||||
} elseif ( 'upload-theme' == $action ) {
|
||||
|
||||
@@ -272,7 +272,7 @@ if ( isset( $_GET['action'] ) ) {
|
||||
$parent_file = 'themes.php';
|
||||
$submenu_file = 'theme-install.php';
|
||||
|
||||
require_once( ABSPATH . 'wp-admin/admin-header.php' );
|
||||
require_once ABSPATH . 'wp-admin/admin-header.php';
|
||||
|
||||
/* translators: %s: File name. */
|
||||
$title = sprintf( __( 'Installing Theme from uploaded file: %s' ), esc_html( basename( $file_upload->filename ) ) );
|
||||
@@ -287,7 +287,7 @@ if ( isset( $_GET['action'] ) ) {
|
||||
$file_upload->cleanup();
|
||||
}
|
||||
|
||||
include( ABSPATH . 'wp-admin/admin-footer.php' );
|
||||
require_once ABSPATH . 'wp-admin/admin-footer.php';
|
||||
|
||||
} else {
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user