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. Built from https://develop.svn.wordpress.org/trunk@55641 git-svn-id: http://core.svn.wordpress.org/trunk@55153 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
2193d75aa1
commit
0008d8df06
|
@ -245,7 +245,7 @@ function wp_ajax_imgedit_preview() {
|
|||
|
||||
check_ajax_referer( "image_editor-$post_id" );
|
||||
|
||||
include_once ABSPATH . 'wp-admin/includes/image-edit.php';
|
||||
require_once ABSPATH . 'wp-admin/includes/image-edit.php';
|
||||
|
||||
if ( ! stream_preview_image( $post_id ) ) {
|
||||
wp_die( -1 );
|
||||
|
@ -2649,7 +2649,7 @@ function wp_ajax_image_editor() {
|
|||
}
|
||||
|
||||
check_ajax_referer( "image_editor-$attachment_id" );
|
||||
include_once ABSPATH . 'wp-admin/includes/image-edit.php';
|
||||
require_once ABSPATH . 'wp-admin/includes/image-edit.php';
|
||||
|
||||
$msg = false;
|
||||
|
||||
|
@ -4157,7 +4157,7 @@ function wp_ajax_install_theme() {
|
|||
}
|
||||
|
||||
require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
|
||||
include_once ABSPATH . 'wp-admin/includes/theme.php';
|
||||
require_once ABSPATH . 'wp-admin/includes/theme.php';
|
||||
|
||||
$api = themes_api(
|
||||
'theme_information',
|
||||
|
@ -4402,7 +4402,7 @@ function wp_ajax_delete_theme() {
|
|||
wp_send_json_error( $status );
|
||||
}
|
||||
|
||||
include_once ABSPATH . 'wp-admin/includes/theme.php';
|
||||
require_once ABSPATH . 'wp-admin/includes/theme.php';
|
||||
|
||||
$result = delete_theme( $stylesheet );
|
||||
|
||||
|
@ -4450,7 +4450,7 @@ function wp_ajax_install_plugin() {
|
|||
}
|
||||
|
||||
require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
|
||||
include_once ABSPATH . 'wp-admin/includes/plugin-install.php';
|
||||
require_once ABSPATH . 'wp-admin/includes/plugin-install.php';
|
||||
|
||||
$api = plugins_api(
|
||||
'plugin_information',
|
||||
|
|
|
@ -33,7 +33,7 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
|
|||
$this->errors = new WP_Error();
|
||||
|
||||
// Check if possible to use ftp functions.
|
||||
if ( ! include_once ABSPATH . 'wp-admin/includes/class-ftp.php' ) {
|
||||
if ( ! require_once ABSPATH . 'wp-admin/includes/class-ftp.php' ) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -88,7 +88,7 @@ class WP_Plugin_Install_List_Table extends WP_List_Table {
|
|||
* @global string $term
|
||||
*/
|
||||
public function prepare_items() {
|
||||
include_once ABSPATH . 'wp-admin/includes/plugin-install.php';
|
||||
require_once ABSPATH . 'wp-admin/includes/plugin-install.php';
|
||||
|
||||
global $tabs, $tab, $paged, $type, $term;
|
||||
|
||||
|
|
|
@ -351,7 +351,7 @@ Commenter avatars come from <a href="%s">Gravatar</a>.'
|
|||
$privacy_policy_content = get_site_option( 'default_privacy_policy_content' );
|
||||
} else {
|
||||
if ( ! class_exists( 'WP_Privacy_Policy_Content' ) ) {
|
||||
include_once ABSPATH . 'wp-admin/includes/class-wp-privacy-policy-content.php';
|
||||
require_once ABSPATH . 'wp-admin/includes/class-wp-privacy-policy-content.php';
|
||||
}
|
||||
|
||||
$privacy_policy_content = WP_Privacy_Policy_Content::get_default_content();
|
||||
|
|
|
@ -14,7 +14,7 @@ if ( ! current_user_can( 'manage_privacy_options' ) ) {
|
|||
}
|
||||
|
||||
if ( ! class_exists( 'WP_Privacy_Policy_Content' ) ) {
|
||||
include_once ABSPATH . 'wp-admin/includes/class-wp-privacy-policy-content.php';
|
||||
require_once ABSPATH . 'wp-admin/includes/class-wp-privacy-policy-content.php';
|
||||
}
|
||||
|
||||
// Used in the HTML title tag.
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -318,7 +318,7 @@ function register_block_type_from_metadata( $file_or_folder, $args = array() ) {
|
|||
*/
|
||||
static $core_blocks_meta;
|
||||
if ( ! $core_blocks_meta ) {
|
||||
$core_blocks_meta = include_once ABSPATH . WPINC . '/blocks/blocks-json.php';
|
||||
$core_blocks_meta = require_once ABSPATH . WPINC . '/blocks/blocks-json.php';
|
||||
}
|
||||
|
||||
$metadata_file = ( ! str_ends_with( $file_or_folder, 'block.json' ) ) ?
|
||||
|
|
|
@ -3051,8 +3051,8 @@ function generic_ping( $post_id = 0 ) {
|
|||
* @param int|WP_Post $post Post ID or object.
|
||||
*/
|
||||
function pingback( $content, $post ) {
|
||||
include_once ABSPATH . WPINC . '/class-IXR.php';
|
||||
include_once ABSPATH . WPINC . '/class-wp-http-ixr-client.php';
|
||||
require_once ABSPATH . WPINC . '/class-IXR.php';
|
||||
require_once ABSPATH . WPINC . '/class-wp-http-ixr-client.php';
|
||||
|
||||
// Original code by Mort (http://mort.mine.nu:8080).
|
||||
$post_links = array();
|
||||
|
@ -3218,8 +3218,8 @@ function trackback( $trackback_url, $title, $excerpt, $ID ) {
|
|||
* @param string $path Path to send the ping.
|
||||
*/
|
||||
function weblog_ping( $server = '', $path = '' ) {
|
||||
include_once ABSPATH . WPINC . '/class-IXR.php';
|
||||
include_once ABSPATH . WPINC . '/class-wp-http-ixr-client.php';
|
||||
require_once ABSPATH . WPINC . '/class-IXR.php';
|
||||
require_once ABSPATH . WPINC . '/class-wp-http-ixr-client.php';
|
||||
|
||||
// Using a timeout of 3 seconds should be enough to cover slow servers.
|
||||
$client = new WP_HTTP_IXR_Client( $server, ( ( ! strlen( trim( $path ) ) || ( '/' === $path ) ) ? false : $path ) );
|
||||
|
|
|
@ -883,7 +883,7 @@ function spawn_cron( $gmt_time = 0 ) {
|
|||
wp_ob_end_flush_all();
|
||||
flush();
|
||||
|
||||
include_once ABSPATH . 'wp-cron.php';
|
||||
require_once ABSPATH . 'wp-cron.php';
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -882,7 +882,7 @@ function do_enclose( $content, $post ) {
|
|||
global $wpdb;
|
||||
|
||||
// @todo Tidy this code and make the debug code optional.
|
||||
include_once ABSPATH . WPINC . '/class-IXR.php';
|
||||
require_once ABSPATH . WPINC . '/class-IXR.php';
|
||||
|
||||
$post = get_post( $post );
|
||||
if ( ! $post ) {
|
||||
|
|
|
@ -843,7 +843,7 @@ function wp_update_themes( $extra_stats = array() ) {
|
|||
* @since 3.7.0
|
||||
*/
|
||||
function wp_maybe_auto_update() {
|
||||
include_once ABSPATH . 'wp-admin/includes/admin.php';
|
||||
require_once ABSPATH . 'wp-admin/includes/admin.php';
|
||||
require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
|
||||
|
||||
$upgrader = new WP_Automatic_Updater();
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '6.3-alpha-55637';
|
||||
$wp_version = '6.3-alpha-55641';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue