Coding Standards: Replace include_once with require_once for required files.

Per [https://developer.wordpress.org/coding-standards/wordpress-coding-standards/php/#writing-include-require-statements WordPress PHP coding standards], it is ''strongly recommended'' to use `require[_once]` for unconditional includes. When using `include[_once]`, PHP will throw a warning when the file is not found but will continue execution, which will almost certainly lead to other errors/warnings/notices being thrown if your application depends on the file loaded, potentially leading to security leaks. For that reason, `require[_once]` is generally the better choice as it will throw a `Fatal Error` if the file cannot be found.

Follow-up to [1674], [1812], [1964], [6779], [8540], [10521], [11005], [11911], [16065], [16149], [25421], [25466], [25823], [37714], [42981], [45448], [47198], [54276], [55633].

Props kausaralm, SergeyBiryukov.
See #57839.

git-svn-id: https://develop.svn.wordpress.org/trunk@55641 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov
2023-04-09 11:55:37 +00:00
parent 2ff42bcb5b
commit ba2f30e4dc
11 changed files with 19 additions and 19 deletions

View File

@@ -107,7 +107,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().
require_once ABSPATH . 'wp-admin/includes/plugin-install.php'; // For plugins_api().
check_admin_referer( 'install-plugin_' . $plugin );
$api = plugins_api(
@@ -258,7 +258,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().
require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; // For themes_api().
check_admin_referer( 'install-theme_' . $theme );
$api = themes_api(