12 * |
12 * |
13 * @return string The HTTP protocol. Default: HTTP/1.0. |
13 * @return string The HTTP protocol. Default: HTTP/1.0. |
14 */ |
14 */ |
15 function wp_get_server_protocol() { |
15 function wp_get_server_protocol() { |
16 $protocol = isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : ''; |
16 $protocol = isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : ''; |
17 if ( ! in_array( $protocol, array( 'HTTP/1.1', 'HTTP/2', 'HTTP/2.0' ), true ) ) { |
17 if ( ! in_array( $protocol, array( 'HTTP/1.1', 'HTTP/2', 'HTTP/2.0', 'HTTP/3' ), true ) ) { |
18 $protocol = 'HTTP/1.0'; |
18 $protocol = 'HTTP/1.0'; |
19 } |
19 } |
20 return $protocol; |
20 return $protocol; |
21 } |
21 } |
22 |
22 |
74 if ( isset( $_SERVER['SCRIPT_FILENAME'] ) && ( strpos( $_SERVER['SCRIPT_FILENAME'], 'php.cgi' ) == strlen( $_SERVER['SCRIPT_FILENAME'] ) - 7 ) ) { |
74 if ( isset( $_SERVER['SCRIPT_FILENAME'] ) && ( strpos( $_SERVER['SCRIPT_FILENAME'], 'php.cgi' ) == strlen( $_SERVER['SCRIPT_FILENAME'] ) - 7 ) ) { |
75 $_SERVER['SCRIPT_FILENAME'] = $_SERVER['PATH_TRANSLATED']; |
75 $_SERVER['SCRIPT_FILENAME'] = $_SERVER['PATH_TRANSLATED']; |
76 } |
76 } |
77 |
77 |
78 // Fix for Dreamhost and other PHP as CGI hosts. |
78 // Fix for Dreamhost and other PHP as CGI hosts. |
79 if ( strpos( $_SERVER['SCRIPT_NAME'], 'php.cgi' ) !== false ) { |
79 if ( isset( $_SERVER['SCRIPT_NAME'] ) && ( strpos( $_SERVER['SCRIPT_NAME'], 'php.cgi' ) !== false ) ) { |
80 unset( $_SERVER['PATH_INFO'] ); |
80 unset( $_SERVER['PATH_INFO'] ); |
81 } |
81 } |
82 |
82 |
83 // Fix empty PHP_SELF. |
83 // Fix empty PHP_SELF. |
84 $PHP_SELF = $_SERVER['PHP_SELF']; |
84 $PHP_SELF = $_SERVER['PHP_SELF']; |
189 * @return string The current environment type. |
189 * @return string The current environment type. |
190 */ |
190 */ |
191 function wp_get_environment_type() { |
191 function wp_get_environment_type() { |
192 static $current_env = ''; |
192 static $current_env = ''; |
193 |
193 |
194 if ( $current_env ) { |
194 if ( ! defined( 'WP_RUN_CORE_TESTS' ) && $current_env ) { |
195 return $current_env; |
195 return $current_env; |
196 } |
196 } |
197 |
197 |
198 $wp_environments = array( |
198 $wp_environments = array( |
199 'local', |
199 'local', |
413 * as false will force errors to be hidden. |
413 * as false will force errors to be hidden. |
414 * |
414 * |
415 * When `WP_DEBUG_LOG` is true, errors will be logged to `wp-content/debug.log`. |
415 * When `WP_DEBUG_LOG` is true, errors will be logged to `wp-content/debug.log`. |
416 * When `WP_DEBUG_LOG` is a valid path, errors will be logged to the specified file. |
416 * When `WP_DEBUG_LOG` is a valid path, errors will be logged to the specified file. |
417 * |
417 * |
418 * Errors are never displayed for XML-RPC, REST, and Ajax requests. |
418 * Errors are never displayed for XML-RPC, REST, `ms-files.php`, and Ajax requests. |
419 * |
419 * |
420 * @since 3.0.0 |
420 * @since 3.0.0 |
421 * @since 5.1.0 `WP_DEBUG_LOG` can be a file path. |
421 * @since 5.1.0 `WP_DEBUG_LOG` can be a file path. |
422 * @access private |
422 * @access private |
423 */ |
423 */ |
424 function wp_debug_mode() { |
424 function wp_debug_mode() { |
425 /** |
425 /** |
426 * Filters whether to allow the debug mode check to occur. |
426 * Filters whether to allow the debug mode check to occur. |
427 * |
427 * |
428 * This filter runs before it can be used by plugins. It is designed for |
428 * This filter runs before it can be used by plugins. It is designed for |
429 * non-web run-times. Returning false causes the `WP_DEBUG` and related |
429 * non-web runtimes. Returning false causes the `WP_DEBUG` and related |
430 * constants to not be checked and the default PHP values for errors |
430 * constants to not be checked and the default PHP values for errors |
431 * will be used unless you take care to update them yourself. |
431 * will be used unless you take care to update them yourself. |
432 * |
432 * |
433 * To use this filter you must define a `$wp_filter` global before |
433 * To use this filter you must define a `$wp_filter` global before |
434 * WordPress loads, usually in `wp-config.php`. |
434 * WordPress loads, usually in `wp-config.php`. |
479 } |
479 } |
480 } else { |
480 } else { |
481 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 ); |
481 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 ); |
482 } |
482 } |
483 |
483 |
484 if ( defined( 'XMLRPC_REQUEST' ) || defined( 'REST_REQUEST' ) || ( defined( 'WP_INSTALLING' ) && WP_INSTALLING ) || wp_doing_ajax() || wp_is_json_request() ) { |
484 if ( |
|
485 defined( 'XMLRPC_REQUEST' ) || defined( 'REST_REQUEST' ) || defined( 'MS_FILES_REQUEST' ) || |
|
486 ( defined( 'WP_INSTALLING' ) && WP_INSTALLING ) || |
|
487 wp_doing_ajax() || wp_is_json_request() ) { |
485 ini_set( 'display_errors', 0 ); |
488 ini_set( 'display_errors', 0 ); |
486 } |
489 } |
487 } |
490 } |
488 |
491 |
489 /** |
492 /** |
668 |
671 |
669 /** |
672 /** |
670 * Filters whether to enable loading of the object-cache.php drop-in. |
673 * Filters whether to enable loading of the object-cache.php drop-in. |
671 * |
674 * |
672 * This filter runs before it can be used by plugins. It is designed for non-web |
675 * This filter runs before it can be used by plugins. It is designed for non-web |
673 * run-times. If false is returned, object-cache.php will never be loaded. |
676 * runtimes. If false is returned, object-cache.php will never be loaded. |
674 * |
677 * |
675 * @since 5.8.0 |
678 * @since 5.8.0 |
676 * |
679 * |
677 * @param bool $enable_object_cache Whether to enable loading object-cache.php (if present). |
680 * @param bool $enable_object_cache Whether to enable loading object-cache.php (if present). |
678 * Default true. |
681 * Default true. |
679 */ |
682 */ |
680 if ( $first_init && apply_filters( 'enable_loading_object_cache_dropin', true ) ) { |
683 if ( $first_init && apply_filters( 'enable_loading_object_cache_dropin', true ) ) { |
681 if ( ! function_exists( 'wp_cache_init' ) ) { |
684 if ( ! function_exists( 'wp_cache_init' ) ) { |
682 /* |
685 /* |
683 * This is the normal situation. First-run of this function. No |
686 * This is the normal situation. First-run of this function. No |
961 /** |
966 /** |
962 * Determines whether we are currently on an endpoint that should be protected against WSODs. |
967 * Determines whether we are currently on an endpoint that should be protected against WSODs. |
963 * |
968 * |
964 * @since 5.2.0 |
969 * @since 5.2.0 |
965 * |
970 * |
966 * @global string $pagenow |
971 * @global string $pagenow The filename of the current screen. |
967 * |
972 * |
968 * @return bool True if the current endpoint should be protected. |
973 * @return bool True if the current endpoint should be protected. |
969 */ |
974 */ |
970 function is_protected_endpoint() { |
975 function is_protected_endpoint() { |
971 // Protect login pages. |
976 // Protect login pages. |
1741 * Currently, this is only used by Application Passwords to prevent a conflict since it also utilizes |
1746 * Currently, this is only used by Application Passwords to prevent a conflict since it also utilizes |
1742 * Basic Auth. |
1747 * Basic Auth. |
1743 * |
1748 * |
1744 * @since 5.6.1 |
1749 * @since 5.6.1 |
1745 * |
1750 * |
1746 * @global string $pagenow The current page. |
1751 * @global string $pagenow The filename of the current screen. |
1747 * |
1752 * |
1748 * @param string $context The context to check for protection. Accepts 'login', 'admin', and 'front'. |
1753 * @param string $context The context to check for protection. Accepts 'login', 'admin', and 'front'. |
1749 * Defaults to the current context. |
1754 * Defaults to the current context. |
1750 * @return bool Whether the site is protected by Basic Auth. |
1755 * @return bool Whether the site is protected by Basic Auth. |
1751 */ |
1756 */ |