mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-11 20:30:23 +00:00
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:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user