Edit File by line
/home/barbar84/public_h.../wp-inclu...
File: load.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* These functions are needed to load WordPress.
[2] Fix | Delete
*
[3] Fix | Delete
* @package WordPress
[4] Fix | Delete
*/
[5] Fix | Delete
[6] Fix | Delete
/**
[7] Fix | Delete
* Return the HTTP protocol sent by the server.
[8] Fix | Delete
*
[9] Fix | Delete
* @since 4.4.0
[10] Fix | Delete
*
[11] Fix | Delete
* @return string The HTTP protocol. Default: HTTP/1.0.
[12] Fix | Delete
*/
[13] Fix | Delete
function wp_get_server_protocol() {
[14] Fix | Delete
$protocol = isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : '';
[15] Fix | Delete
if ( ! in_array( $protocol, array( 'HTTP/1.1', 'HTTP/2', 'HTTP/2.0' ), true ) ) {
[16] Fix | Delete
$protocol = 'HTTP/1.0';
[17] Fix | Delete
}
[18] Fix | Delete
return $protocol;
[19] Fix | Delete
}
[20] Fix | Delete
[21] Fix | Delete
/**
[22] Fix | Delete
* Fix `$_SERVER` variables for various setups.
[23] Fix | Delete
*
[24] Fix | Delete
* @since 3.0.0
[25] Fix | Delete
* @access private
[26] Fix | Delete
*
[27] Fix | Delete
* @global string $PHP_SELF The filename of the currently executing script,
[28] Fix | Delete
* relative to the document root.
[29] Fix | Delete
*/
[30] Fix | Delete
function wp_fix_server_vars() {
[31] Fix | Delete
global $PHP_SELF;
[32] Fix | Delete
[33] Fix | Delete
$default_server_values = array(
[34] Fix | Delete
'SERVER_SOFTWARE' => '',
[35] Fix | Delete
'REQUEST_URI' => '',
[36] Fix | Delete
);
[37] Fix | Delete
[38] Fix | Delete
$_SERVER = array_merge( $default_server_values, $_SERVER );
[39] Fix | Delete
[40] Fix | Delete
// Fix for IIS when running with PHP ISAPI.
[41] Fix | Delete
if ( empty( $_SERVER['REQUEST_URI'] ) || ( 'cgi-fcgi' !== PHP_SAPI && preg_match( '/^Microsoft-IIS\//', $_SERVER['SERVER_SOFTWARE'] ) ) ) {
[42] Fix | Delete
[43] Fix | Delete
if ( isset( $_SERVER['HTTP_X_ORIGINAL_URL'] ) ) {
[44] Fix | Delete
// IIS Mod-Rewrite.
[45] Fix | Delete
$_SERVER['REQUEST_URI'] = $_SERVER['HTTP_X_ORIGINAL_URL'];
[46] Fix | Delete
} elseif ( isset( $_SERVER['HTTP_X_REWRITE_URL'] ) ) {
[47] Fix | Delete
// IIS Isapi_Rewrite.
[48] Fix | Delete
$_SERVER['REQUEST_URI'] = $_SERVER['HTTP_X_REWRITE_URL'];
[49] Fix | Delete
} else {
[50] Fix | Delete
// Use ORIG_PATH_INFO if there is no PATH_INFO.
[51] Fix | Delete
if ( ! isset( $_SERVER['PATH_INFO'] ) && isset( $_SERVER['ORIG_PATH_INFO'] ) ) {
[52] Fix | Delete
$_SERVER['PATH_INFO'] = $_SERVER['ORIG_PATH_INFO'];
[53] Fix | Delete
}
[54] Fix | Delete
[55] Fix | Delete
// Some IIS + PHP configurations put the script-name in the path-info (no need to append it twice).
[56] Fix | Delete
if ( isset( $_SERVER['PATH_INFO'] ) ) {
[57] Fix | Delete
if ( $_SERVER['PATH_INFO'] == $_SERVER['SCRIPT_NAME'] ) {
[58] Fix | Delete
$_SERVER['REQUEST_URI'] = $_SERVER['PATH_INFO'];
[59] Fix | Delete
} else {
[60] Fix | Delete
$_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'] . $_SERVER['PATH_INFO'];
[61] Fix | Delete
}
[62] Fix | Delete
}
[63] Fix | Delete
[64] Fix | Delete
// Append the query string if it exists and isn't null.
[65] Fix | Delete
if ( ! empty( $_SERVER['QUERY_STRING'] ) ) {
[66] Fix | Delete
$_SERVER['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING'];
[67] Fix | Delete
}
[68] Fix | Delete
}
[69] Fix | Delete
}
[70] Fix | Delete
[71] Fix | Delete
// Fix for PHP as CGI hosts that set SCRIPT_FILENAME to something ending in php.cgi for all requests.
[72] Fix | Delete
if ( isset( $_SERVER['SCRIPT_FILENAME'] ) && ( strpos( $_SERVER['SCRIPT_FILENAME'], 'php.cgi' ) == strlen( $_SERVER['SCRIPT_FILENAME'] ) - 7 ) ) {
[73] Fix | Delete
$_SERVER['SCRIPT_FILENAME'] = $_SERVER['PATH_TRANSLATED'];
[74] Fix | Delete
}
[75] Fix | Delete
[76] Fix | Delete
// Fix for Dreamhost and other PHP as CGI hosts.
[77] Fix | Delete
if ( strpos( $_SERVER['SCRIPT_NAME'], 'php.cgi' ) !== false ) {
[78] Fix | Delete
unset( $_SERVER['PATH_INFO'] );
[79] Fix | Delete
}
[80] Fix | Delete
[81] Fix | Delete
// Fix empty PHP_SELF.
[82] Fix | Delete
$PHP_SELF = $_SERVER['PHP_SELF'];
[83] Fix | Delete
if ( empty( $PHP_SELF ) ) {
[84] Fix | Delete
$_SERVER['PHP_SELF'] = preg_replace( '/(\?.*)?$/', '', $_SERVER['REQUEST_URI'] );
[85] Fix | Delete
$PHP_SELF = $_SERVER['PHP_SELF'];
[86] Fix | Delete
}
[87] Fix | Delete
[88] Fix | Delete
wp_populate_basic_auth_from_authorization_header();
[89] Fix | Delete
}
[90] Fix | Delete
[91] Fix | Delete
/**
[92] Fix | Delete
* Populates the Basic Auth server details from the Authorization header.
[93] Fix | Delete
*
[94] Fix | Delete
* Some servers running in CGI or FastCGI mode don't pass the Authorization
[95] Fix | Delete
* header on to WordPress. If it's been rewritten to the `HTTP_AUTHORIZATION` header,
[96] Fix | Delete
* fill in the proper $_SERVER variables instead.
[97] Fix | Delete
*
[98] Fix | Delete
* @since 5.6.0
[99] Fix | Delete
*/
[100] Fix | Delete
function wp_populate_basic_auth_from_authorization_header() {
[101] Fix | Delete
// If we don't have anything to pull from, return early.
[102] Fix | Delete
if ( ! isset( $_SERVER['HTTP_AUTHORIZATION'] ) && ! isset( $_SERVER['REDIRECT_HTTP_AUTHORIZATION'] ) ) {
[103] Fix | Delete
return;
[104] Fix | Delete
}
[105] Fix | Delete
[106] Fix | Delete
// If either PHP_AUTH key is already set, do nothing.
[107] Fix | Delete
if ( isset( $_SERVER['PHP_AUTH_USER'] ) || isset( $_SERVER['PHP_AUTH_PW'] ) ) {
[108] Fix | Delete
return;
[109] Fix | Delete
}
[110] Fix | Delete
[111] Fix | Delete
// From our prior conditional, one of these must be set.
[112] Fix | Delete
$header = isset( $_SERVER['HTTP_AUTHORIZATION'] ) ? $_SERVER['HTTP_AUTHORIZATION'] : $_SERVER['REDIRECT_HTTP_AUTHORIZATION'];
[113] Fix | Delete
[114] Fix | Delete
// Test to make sure the pattern matches expected.
[115] Fix | Delete
if ( ! preg_match( '%^Basic [a-z\d/+]*={0,2}$%i', $header ) ) {
[116] Fix | Delete
return;
[117] Fix | Delete
}
[118] Fix | Delete
[119] Fix | Delete
// Removing `Basic ` the token would start six characters in.
[120] Fix | Delete
$token = substr( $header, 6 );
[121] Fix | Delete
$userpass = base64_decode( $token );
[122] Fix | Delete
[123] Fix | Delete
list( $user, $pass ) = explode( ':', $userpass );
[124] Fix | Delete
[125] Fix | Delete
// Now shove them in the proper keys where we're expecting later on.
[126] Fix | Delete
$_SERVER['PHP_AUTH_USER'] = $user;
[127] Fix | Delete
$_SERVER['PHP_AUTH_PW'] = $pass;
[128] Fix | Delete
}
[129] Fix | Delete
[130] Fix | Delete
/**
[131] Fix | Delete
* Check for the required PHP version, and the MySQL extension or
[132] Fix | Delete
* a database drop-in.
[133] Fix | Delete
*
[134] Fix | Delete
* Dies if requirements are not met.
[135] Fix | Delete
*
[136] Fix | Delete
* @since 3.0.0
[137] Fix | Delete
* @access private
[138] Fix | Delete
*
[139] Fix | Delete
* @global string $required_php_version The required PHP version string.
[140] Fix | Delete
* @global string $wp_version The WordPress version string.
[141] Fix | Delete
*/
[142] Fix | Delete
function wp_check_php_mysql_versions() {
[143] Fix | Delete
global $required_php_version, $wp_version;
[144] Fix | Delete
$php_version = phpversion();
[145] Fix | Delete
[146] Fix | Delete
if ( version_compare( $required_php_version, $php_version, '>' ) ) {
[147] Fix | Delete
$protocol = wp_get_server_protocol();
[148] Fix | Delete
header( sprintf( '%s 500 Internal Server Error', $protocol ), true, 500 );
[149] Fix | Delete
header( 'Content-Type: text/html; charset=utf-8' );
[150] Fix | Delete
printf( 'Your server is running PHP version %1$s but WordPress %2$s requires at least %3$s.', $php_version, $wp_version, $required_php_version );
[151] Fix | Delete
exit( 1 );
[152] Fix | Delete
}
[153] Fix | Delete
[154] Fix | Delete
if ( ! extension_loaded( 'mysql' ) && ! extension_loaded( 'mysqli' ) && ! extension_loaded( 'mysqlnd' )
[155] Fix | Delete
// This runs before default constants are defined, so we can't assume WP_CONTENT_DIR is set yet.
[156] Fix | Delete
&& ( defined( 'WP_CONTENT_DIR' ) && ! file_exists( WP_CONTENT_DIR . '/db.php' )
[157] Fix | Delete
|| ! file_exists( ABSPATH . 'wp-content/db.php' ) )
[158] Fix | Delete
) {
[159] Fix | Delete
require_once ABSPATH . WPINC . '/functions.php';
[160] Fix | Delete
wp_load_translations_early();
[161] Fix | Delete
$args = array(
[162] Fix | Delete
'exit' => false,
[163] Fix | Delete
'code' => 'mysql_not_found',
[164] Fix | Delete
);
[165] Fix | Delete
wp_die(
[166] Fix | Delete
__( 'Your PHP installation appears to be missing the MySQL extension which is required by WordPress.' ),
[167] Fix | Delete
__( 'Requirements Not Met' ),
[168] Fix | Delete
$args
[169] Fix | Delete
);
[170] Fix | Delete
exit( 1 );
[171] Fix | Delete
}
[172] Fix | Delete
}
[173] Fix | Delete
[174] Fix | Delete
/**
[175] Fix | Delete
* Retrieves the current environment type.
[176] Fix | Delete
*
[177] Fix | Delete
* The type can be set via the `WP_ENVIRONMENT_TYPE` global system variable,
[178] Fix | Delete
* or a constant of the same name.
[179] Fix | Delete
*
[180] Fix | Delete
* Possible values are 'local', 'development', 'staging', and 'production'.
[181] Fix | Delete
* If not set, the type defaults to 'production'.
[182] Fix | Delete
*
[183] Fix | Delete
* @since 5.5.0
[184] Fix | Delete
* @since 5.5.1 Added the 'local' type.
[185] Fix | Delete
* @since 5.5.1 Removed the ability to alter the list of types.
[186] Fix | Delete
*
[187] Fix | Delete
* @return string The current environment type.
[188] Fix | Delete
*/
[189] Fix | Delete
function wp_get_environment_type() {
[190] Fix | Delete
static $current_env = '';
[191] Fix | Delete
[192] Fix | Delete
if ( $current_env ) {
[193] Fix | Delete
return $current_env;
[194] Fix | Delete
}
[195] Fix | Delete
[196] Fix | Delete
$wp_environments = array(
[197] Fix | Delete
'local',
[198] Fix | Delete
'development',
[199] Fix | Delete
'staging',
[200] Fix | Delete
'production',
[201] Fix | Delete
);
[202] Fix | Delete
[203] Fix | Delete
// Add a note about the deprecated WP_ENVIRONMENT_TYPES constant.
[204] Fix | Delete
if ( defined( 'WP_ENVIRONMENT_TYPES' ) && function_exists( '_deprecated_argument' ) ) {
[205] Fix | Delete
if ( function_exists( '__' ) ) {
[206] Fix | Delete
/* translators: %s: WP_ENVIRONMENT_TYPES */
[207] Fix | Delete
$message = sprintf( __( 'The %s constant is no longer supported.' ), 'WP_ENVIRONMENT_TYPES' );
[208] Fix | Delete
} else {
[209] Fix | Delete
$message = sprintf( 'The %s constant is no longer supported.', 'WP_ENVIRONMENT_TYPES' );
[210] Fix | Delete
}
[211] Fix | Delete
[212] Fix | Delete
_deprecated_argument(
[213] Fix | Delete
'define()',
[214] Fix | Delete
'5.5.1',
[215] Fix | Delete
$message
[216] Fix | Delete
);
[217] Fix | Delete
}
[218] Fix | Delete
[219] Fix | Delete
// Check if the environment variable has been set, if `getenv` is available on the system.
[220] Fix | Delete
if ( function_exists( 'getenv' ) ) {
[221] Fix | Delete
$has_env = getenv( 'WP_ENVIRONMENT_TYPE' );
[222] Fix | Delete
if ( false !== $has_env ) {
[223] Fix | Delete
$current_env = $has_env;
[224] Fix | Delete
}
[225] Fix | Delete
}
[226] Fix | Delete
[227] Fix | Delete
// Fetch the environment from a constant, this overrides the global system variable.
[228] Fix | Delete
if ( defined( 'WP_ENVIRONMENT_TYPE' ) ) {
[229] Fix | Delete
$current_env = WP_ENVIRONMENT_TYPE;
[230] Fix | Delete
}
[231] Fix | Delete
[232] Fix | Delete
// Make sure the environment is an allowed one, and not accidentally set to an invalid value.
[233] Fix | Delete
if ( ! in_array( $current_env, $wp_environments, true ) ) {
[234] Fix | Delete
$current_env = 'production';
[235] Fix | Delete
}
[236] Fix | Delete
[237] Fix | Delete
return $current_env;
[238] Fix | Delete
}
[239] Fix | Delete
[240] Fix | Delete
/**
[241] Fix | Delete
* Don't load all of WordPress when handling a favicon.ico request.
[242] Fix | Delete
*
[243] Fix | Delete
* Instead, send the headers for a zero-length favicon and bail.
[244] Fix | Delete
*
[245] Fix | Delete
* @since 3.0.0
[246] Fix | Delete
* @deprecated 5.4.0 Deprecated in favor of do_favicon().
[247] Fix | Delete
*/
[248] Fix | Delete
function wp_favicon_request() {
[249] Fix | Delete
if ( '/favicon.ico' === $_SERVER['REQUEST_URI'] ) {
[250] Fix | Delete
header( 'Content-Type: image/vnd.microsoft.icon' );
[251] Fix | Delete
exit;
[252] Fix | Delete
}
[253] Fix | Delete
}
[254] Fix | Delete
[255] Fix | Delete
/**
[256] Fix | Delete
* Die with a maintenance message when conditions are met.
[257] Fix | Delete
*
[258] Fix | Delete
* The default message can be replaced by using a drop-in (maintenance.php in
[259] Fix | Delete
* the wp-content directory).
[260] Fix | Delete
*
[261] Fix | Delete
* @since 3.0.0
[262] Fix | Delete
* @access private
[263] Fix | Delete
*/
[264] Fix | Delete
function wp_maintenance() {
[265] Fix | Delete
// Return if maintenance mode is disabled.
[266] Fix | Delete
if ( ! wp_is_maintenance_mode() ) {
[267] Fix | Delete
return;
[268] Fix | Delete
}
[269] Fix | Delete
[270] Fix | Delete
if ( file_exists( WP_CONTENT_DIR . '/maintenance.php' ) ) {
[271] Fix | Delete
require_once WP_CONTENT_DIR . '/maintenance.php';
[272] Fix | Delete
die();
[273] Fix | Delete
}
[274] Fix | Delete
[275] Fix | Delete
require_once ABSPATH . WPINC . '/functions.php';
[276] Fix | Delete
wp_load_translations_early();
[277] Fix | Delete
[278] Fix | Delete
header( 'Retry-After: 600' );
[279] Fix | Delete
[280] Fix | Delete
wp_die(
[281] Fix | Delete
__( 'Briefly unavailable for scheduled maintenance. Check back in a minute.' ),
[282] Fix | Delete
__( 'Maintenance' ),
[283] Fix | Delete
503
[284] Fix | Delete
);
[285] Fix | Delete
}
[286] Fix | Delete
[287] Fix | Delete
/**
[288] Fix | Delete
* Check if maintenance mode is enabled.
[289] Fix | Delete
*
[290] Fix | Delete
* Checks for a file in the WordPress root directory named ".maintenance".
[291] Fix | Delete
* This file will contain the variable $upgrading, set to the time the file
[292] Fix | Delete
* was created. If the file was created less than 10 minutes ago, WordPress
[293] Fix | Delete
* is in maintenance mode.
[294] Fix | Delete
*
[295] Fix | Delete
* @since 5.5.0
[296] Fix | Delete
*
[297] Fix | Delete
* @global int $upgrading The Unix timestamp marking when upgrading WordPress began.
[298] Fix | Delete
*
[299] Fix | Delete
* @return bool True if maintenance mode is enabled, false otherwise.
[300] Fix | Delete
*/
[301] Fix | Delete
function wp_is_maintenance_mode() {
[302] Fix | Delete
global $upgrading;
[303] Fix | Delete
[304] Fix | Delete
if ( ! file_exists( ABSPATH . '.maintenance' ) || wp_installing() ) {
[305] Fix | Delete
return false;
[306] Fix | Delete
}
[307] Fix | Delete
[308] Fix | Delete
require ABSPATH . '.maintenance';
[309] Fix | Delete
// If the $upgrading timestamp is older than 10 minutes, consider maintenance over.
[310] Fix | Delete
if ( ( time() - $upgrading ) >= 10 * MINUTE_IN_SECONDS ) {
[311] Fix | Delete
return false;
[312] Fix | Delete
}
[313] Fix | Delete
[314] Fix | Delete
/**
[315] Fix | Delete
* Filters whether to enable maintenance mode.
[316] Fix | Delete
*
[317] Fix | Delete
* This filter runs before it can be used by plugins. It is designed for
[318] Fix | Delete
* non-web runtimes. If this filter returns true, maintenance mode will be
[319] Fix | Delete
* active and the request will end. If false, the request will be allowed to
[320] Fix | Delete
* continue processing even if maintenance mode should be active.
[321] Fix | Delete
*
[322] Fix | Delete
* @since 4.6.0
[323] Fix | Delete
*
[324] Fix | Delete
* @param bool $enable_checks Whether to enable maintenance mode. Default true.
[325] Fix | Delete
* @param int $upgrading The timestamp set in the .maintenance file.
[326] Fix | Delete
*/
[327] Fix | Delete
if ( ! apply_filters( 'enable_maintenance_mode', true, $upgrading ) ) {
[328] Fix | Delete
return false;
[329] Fix | Delete
}
[330] Fix | Delete
[331] Fix | Delete
return true;
[332] Fix | Delete
}
[333] Fix | Delete
[334] Fix | Delete
/**
[335] Fix | Delete
* Start the WordPress micro-timer.
[336] Fix | Delete
*
[337] Fix | Delete
* @since 0.71
[338] Fix | Delete
* @access private
[339] Fix | Delete
*
[340] Fix | Delete
* @global float $timestart Unix timestamp set at the beginning of the page load.
[341] Fix | Delete
* @see timer_stop()
[342] Fix | Delete
*
[343] Fix | Delete
* @return bool Always returns true.
[344] Fix | Delete
*/
[345] Fix | Delete
function timer_start() {
[346] Fix | Delete
global $timestart;
[347] Fix | Delete
$timestart = microtime( true );
[348] Fix | Delete
return true;
[349] Fix | Delete
}
[350] Fix | Delete
[351] Fix | Delete
/**
[352] Fix | Delete
* Retrieve or display the time from the page start to when function is called.
[353] Fix | Delete
*
[354] Fix | Delete
* @since 0.71
[355] Fix | Delete
*
[356] Fix | Delete
* @global float $timestart Seconds from when timer_start() is called.
[357] Fix | Delete
* @global float $timeend Seconds from when function is called.
[358] Fix | Delete
*
[359] Fix | Delete
* @param int|bool $display Whether to echo or return the results. Accepts 0|false for return,
[360] Fix | Delete
* 1|true for echo. Default 0|false.
[361] Fix | Delete
* @param int $precision The number of digits from the right of the decimal to display.
[362] Fix | Delete
* Default 3.
[363] Fix | Delete
* @return string The "second.microsecond" finished time calculation. The number is formatted
[364] Fix | Delete
* for human consumption, both localized and rounded.
[365] Fix | Delete
*/
[366] Fix | Delete
function timer_stop( $display = 0, $precision = 3 ) {
[367] Fix | Delete
global $timestart, $timeend;
[368] Fix | Delete
$timeend = microtime( true );
[369] Fix | Delete
$timetotal = $timeend - $timestart;
[370] Fix | Delete
$r = ( function_exists( 'number_format_i18n' ) ) ? number_format_i18n( $timetotal, $precision ) : number_format( $timetotal, $precision );
[371] Fix | Delete
if ( $display ) {
[372] Fix | Delete
echo $r;
[373] Fix | Delete
}
[374] Fix | Delete
return $r;
[375] Fix | Delete
}
[376] Fix | Delete
[377] Fix | Delete
/**
[378] Fix | Delete
* Set PHP error reporting based on WordPress debug settings.
[379] Fix | Delete
*
[380] Fix | Delete
* Uses three constants: `WP_DEBUG`, `WP_DEBUG_DISPLAY`, and `WP_DEBUG_LOG`.
[381] Fix | Delete
* All three can be defined in wp-config.php. By default, `WP_DEBUG` and
[382] Fix | Delete
* `WP_DEBUG_LOG` are set to false, and `WP_DEBUG_DISPLAY` is set to true.
[383] Fix | Delete
*
[384] Fix | Delete
* When `WP_DEBUG` is true, all PHP notices are reported. WordPress will also
[385] Fix | Delete
* display internal notices: when a deprecated WordPress function, function
[386] Fix | Delete
* argument, or file is used. Deprecated code may be removed from a later
[387] Fix | Delete
* version.
[388] Fix | Delete
*
[389] Fix | Delete
* It is strongly recommended that plugin and theme developers use `WP_DEBUG`
[390] Fix | Delete
* in their development environments.
[391] Fix | Delete
*
[392] Fix | Delete
* `WP_DEBUG_DISPLAY` and `WP_DEBUG_LOG` perform no function unless `WP_DEBUG`
[393] Fix | Delete
* is true.
[394] Fix | Delete
*
[395] Fix | Delete
* When `WP_DEBUG_DISPLAY` is true, WordPress will force errors to be displayed.
[396] Fix | Delete
* `WP_DEBUG_DISPLAY` defaults to true. Defining it as null prevents WordPress
[397] Fix | Delete
* from changing the global configuration setting. Defining `WP_DEBUG_DISPLAY`
[398] Fix | Delete
* as false will force errors to be hidden.
[399] Fix | Delete
*
[400] Fix | Delete
* When `WP_DEBUG_LOG` is true, errors will be logged to `wp-content/debug.log`.
[401] Fix | Delete
* When `WP_DEBUG_LOG` is a valid path, errors will be logged to the specified file.
[402] Fix | Delete
*
[403] Fix | Delete
* Errors are never displayed for XML-RPC, REST, and Ajax requests.
[404] Fix | Delete
*
[405] Fix | Delete
* @since 3.0.0
[406] Fix | Delete
* @since 5.1.0 `WP_DEBUG_LOG` can be a file path.
[407] Fix | Delete
* @access private
[408] Fix | Delete
*/
[409] Fix | Delete
function wp_debug_mode() {
[410] Fix | Delete
/**
[411] Fix | Delete
* Filters whether to allow the debug mode check to occur.
[412] Fix | Delete
*
[413] Fix | Delete
* This filter runs before it can be used by plugins. It is designed for
[414] Fix | Delete
* non-web run-times. Returning false causes the `WP_DEBUG` and related
[415] Fix | Delete
* constants to not be checked and the default PHP values for errors
[416] Fix | Delete
* will be used unless you take care to update them yourself.
[417] Fix | Delete
*
[418] Fix | Delete
* To use this filter you must define a `$wp_filter` global before
[419] Fix | Delete
* WordPress loads, usually in `wp-config.php`.
[420] Fix | Delete
*
[421] Fix | Delete
* Example:
[422] Fix | Delete
*
[423] Fix | Delete
* $GLOBALS['wp_filter'] = array(
[424] Fix | Delete
* 'enable_wp_debug_mode_checks' => array(
[425] Fix | Delete
* 10 => array(
[426] Fix | Delete
* array(
[427] Fix | Delete
* 'accepted_args' => 0,
[428] Fix | Delete
* 'function' => function() {
[429] Fix | Delete
* return false;
[430] Fix | Delete
* },
[431] Fix | Delete
* ),
[432] Fix | Delete
* ),
[433] Fix | Delete
* ),
[434] Fix | Delete
* );
[435] Fix | Delete
*
[436] Fix | Delete
* @since 4.6.0
[437] Fix | Delete
*
[438] Fix | Delete
* @param bool $enable_debug_mode Whether to enable debug mode checks to occur. Default true.
[439] Fix | Delete
*/
[440] Fix | Delete
if ( ! apply_filters( 'enable_wp_debug_mode_checks', true ) ) {
[441] Fix | Delete
return;
[442] Fix | Delete
}
[443] Fix | Delete
[444] Fix | Delete
if ( WP_DEBUG ) {
[445] Fix | Delete
error_reporting( E_ALL );
[446] Fix | Delete
[447] Fix | Delete
if ( WP_DEBUG_DISPLAY ) {
[448] Fix | Delete
ini_set( 'display_errors', 1 );
[449] Fix | Delete
} elseif ( null !== WP_DEBUG_DISPLAY ) {
[450] Fix | Delete
ini_set( 'display_errors', 0 );
[451] Fix | Delete
}
[452] Fix | Delete
[453] Fix | Delete
if ( in_array( strtolower( (string) WP_DEBUG_LOG ), array( 'true', '1' ), true ) ) {
[454] Fix | Delete
$log_path = WP_CONTENT_DIR . '/debug.log';
[455] Fix | Delete
} elseif ( is_string( WP_DEBUG_LOG ) ) {
[456] Fix | Delete
$log_path = WP_DEBUG_LOG;
[457] Fix | Delete
} else {
[458] Fix | Delete
$log_path = false;
[459] Fix | Delete
}
[460] Fix | Delete
[461] Fix | Delete
if ( $log_path ) {
[462] Fix | Delete
ini_set( 'log_errors', 1 );
[463] Fix | Delete
ini_set( 'error_log', $log_path );
[464] Fix | Delete
}
[465] Fix | Delete
} else {
[466] Fix | Delete
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 );
[467] Fix | Delete
}
[468] Fix | Delete
[469] Fix | Delete
if ( defined( 'XMLRPC_REQUEST' ) || defined( 'REST_REQUEST' ) || ( defined( 'WP_INSTALLING' ) && WP_INSTALLING ) || wp_doing_ajax() || wp_is_json_request() ) {
[470] Fix | Delete
ini_set( 'display_errors', 0 );
[471] Fix | Delete
}
[472] Fix | Delete
}
[473] Fix | Delete
[474] Fix | Delete
/**
[475] Fix | Delete
* Set the location of the language directory.
[476] Fix | Delete
*
[477] Fix | Delete
* To set directory manually, define the `WP_LANG_DIR` constant
[478] Fix | Delete
* in wp-config.php.
[479] Fix | Delete
*
[480] Fix | Delete
* If the language directory exists within `WP_CONTENT_DIR`, it
[481] Fix | Delete
* is used. Otherwise the language directory is assumed to live
[482] Fix | Delete
* in `WPINC`.
[483] Fix | Delete
*
[484] Fix | Delete
* @since 3.0.0
[485] Fix | Delete
* @access private
[486] Fix | Delete
*/
[487] Fix | Delete
function wp_set_lang_dir() {
[488] Fix | Delete
if ( ! defined( 'WP_LANG_DIR' ) ) {
[489] Fix | Delete
if ( file_exists( WP_CONTENT_DIR . '/languages' ) && @is_dir( WP_CONTENT_DIR . '/languages' ) || ! @is_dir( ABSPATH . WPINC . '/languages' ) ) {
[490] Fix | Delete
/**
[491] Fix | Delete
* Server path of the language directory.
[492] Fix | Delete
*
[493] Fix | Delete
* No leading slash, no trailing slash, full path, not relative to ABSPATH
[494] Fix | Delete
*
[495] Fix | Delete
* @since 2.1.0
[496] Fix | Delete
*/
[497] Fix | Delete
define( 'WP_LANG_DIR', WP_CONTENT_DIR . '/languages' );
[498] Fix | Delete
if ( ! defined( 'LANGDIR' ) ) {
[499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function