Edit File by line
/home/barbar84/public_h.../wp-inclu...
File: error-protection.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* Error Protection API: Functions
[2] Fix | Delete
*
[3] Fix | Delete
* @package WordPress
[4] Fix | Delete
* @since 5.2.0
[5] Fix | Delete
*/
[6] Fix | Delete
[7] Fix | Delete
/**
[8] Fix | Delete
* Get the instance for storing paused plugins.
[9] Fix | Delete
*
[10] Fix | Delete
* @return WP_Paused_Extensions_Storage
[11] Fix | Delete
*/
[12] Fix | Delete
function wp_paused_plugins() {
[13] Fix | Delete
static $storage = null;
[14] Fix | Delete
[15] Fix | Delete
if ( null === $storage ) {
[16] Fix | Delete
$storage = new WP_Paused_Extensions_Storage( 'plugin' );
[17] Fix | Delete
}
[18] Fix | Delete
[19] Fix | Delete
return $storage;
[20] Fix | Delete
}
[21] Fix | Delete
[22] Fix | Delete
/**
[23] Fix | Delete
* Get the instance for storing paused extensions.
[24] Fix | Delete
*
[25] Fix | Delete
* @return WP_Paused_Extensions_Storage
[26] Fix | Delete
*/
[27] Fix | Delete
function wp_paused_themes() {
[28] Fix | Delete
static $storage = null;
[29] Fix | Delete
[30] Fix | Delete
if ( null === $storage ) {
[31] Fix | Delete
$storage = new WP_Paused_Extensions_Storage( 'theme' );
[32] Fix | Delete
}
[33] Fix | Delete
[34] Fix | Delete
return $storage;
[35] Fix | Delete
}
[36] Fix | Delete
[37] Fix | Delete
/**
[38] Fix | Delete
* Get a human readable description of an extension's error.
[39] Fix | Delete
*
[40] Fix | Delete
* @since 5.2.0
[41] Fix | Delete
*
[42] Fix | Delete
* @param array $error Error details {@see error_get_last()}
[43] Fix | Delete
* @return string Formatted error description.
[44] Fix | Delete
*/
[45] Fix | Delete
function wp_get_extension_error_description( $error ) {
[46] Fix | Delete
$constants = get_defined_constants( true );
[47] Fix | Delete
$constants = isset( $constants['Core'] ) ? $constants['Core'] : $constants['internal'];
[48] Fix | Delete
$core_errors = array();
[49] Fix | Delete
[50] Fix | Delete
foreach ( $constants as $constant => $value ) {
[51] Fix | Delete
if ( 0 === strpos( $constant, 'E_' ) ) {
[52] Fix | Delete
$core_errors[ $value ] = $constant;
[53] Fix | Delete
}
[54] Fix | Delete
}
[55] Fix | Delete
[56] Fix | Delete
if ( isset( $core_errors[ $error['type'] ] ) ) {
[57] Fix | Delete
$error['type'] = $core_errors[ $error['type'] ];
[58] Fix | Delete
}
[59] Fix | Delete
[60] Fix | Delete
/* translators: 1: Error type, 2: Error line number, 3: Error file name, 4: Error message. */
[61] Fix | Delete
$error_message = __( 'An error of type %1$s was caused in line %2$s of the file %3$s. Error message: %4$s' );
[62] Fix | Delete
[63] Fix | Delete
return sprintf(
[64] Fix | Delete
$error_message,
[65] Fix | Delete
"<code>{$error['type']}</code>",
[66] Fix | Delete
"<code>{$error['line']}</code>",
[67] Fix | Delete
"<code>{$error['file']}</code>",
[68] Fix | Delete
"<code>{$error['message']}</code>"
[69] Fix | Delete
);
[70] Fix | Delete
}
[71] Fix | Delete
[72] Fix | Delete
/**
[73] Fix | Delete
* Registers the shutdown handler for fatal errors.
[74] Fix | Delete
*
[75] Fix | Delete
* The handler will only be registered if {@see wp_is_fatal_error_handler_enabled()} returns true.
[76] Fix | Delete
*
[77] Fix | Delete
* @since 5.2.0
[78] Fix | Delete
*/
[79] Fix | Delete
function wp_register_fatal_error_handler() {
[80] Fix | Delete
if ( ! wp_is_fatal_error_handler_enabled() ) {
[81] Fix | Delete
return;
[82] Fix | Delete
}
[83] Fix | Delete
[84] Fix | Delete
$handler = null;
[85] Fix | Delete
if ( defined( 'WP_CONTENT_DIR' ) && is_readable( WP_CONTENT_DIR . '/fatal-error-handler.php' ) ) {
[86] Fix | Delete
$handler = include WP_CONTENT_DIR . '/fatal-error-handler.php';
[87] Fix | Delete
}
[88] Fix | Delete
[89] Fix | Delete
if ( ! is_object( $handler ) || ! is_callable( array( $handler, 'handle' ) ) ) {
[90] Fix | Delete
$handler = new WP_Fatal_Error_Handler();
[91] Fix | Delete
}
[92] Fix | Delete
[93] Fix | Delete
register_shutdown_function( array( $handler, 'handle' ) );
[94] Fix | Delete
}
[95] Fix | Delete
[96] Fix | Delete
/**
[97] Fix | Delete
* Checks whether the fatal error handler is enabled.
[98] Fix | Delete
*
[99] Fix | Delete
* A constant `WP_DISABLE_FATAL_ERROR_HANDLER` can be set in `wp-config.php` to disable it, or alternatively the
[100] Fix | Delete
* {@see 'wp_fatal_error_handler_enabled'} filter can be used to modify the return value.
[101] Fix | Delete
*
[102] Fix | Delete
* @since 5.2.0
[103] Fix | Delete
*
[104] Fix | Delete
* @return bool True if the fatal error handler is enabled, false otherwise.
[105] Fix | Delete
*/
[106] Fix | Delete
function wp_is_fatal_error_handler_enabled() {
[107] Fix | Delete
$enabled = ! defined( 'WP_DISABLE_FATAL_ERROR_HANDLER' ) || ! WP_DISABLE_FATAL_ERROR_HANDLER;
[108] Fix | Delete
[109] Fix | Delete
/**
[110] Fix | Delete
* Filters whether the fatal error handler is enabled.
[111] Fix | Delete
*
[112] Fix | Delete
* **Important:** This filter runs before it can be used by plugins. It cannot
[113] Fix | Delete
* be used by plugins, mu-plugins, or themes. To use this filter you must define
[114] Fix | Delete
* a `$wp_filter` global before WordPress loads, usually in `wp-config.php`.
[115] Fix | Delete
*
[116] Fix | Delete
* Example:
[117] Fix | Delete
*
[118] Fix | Delete
* $GLOBALS['wp_filter'] = array(
[119] Fix | Delete
* 'wp_fatal_error_handler_enabled' => array(
[120] Fix | Delete
* 10 => array(
[121] Fix | Delete
* array(
[122] Fix | Delete
* 'accepted_args' => 0,
[123] Fix | Delete
* 'function' => function() {
[124] Fix | Delete
* return false;
[125] Fix | Delete
* },
[126] Fix | Delete
* ),
[127] Fix | Delete
* ),
[128] Fix | Delete
* ),
[129] Fix | Delete
* );
[130] Fix | Delete
*
[131] Fix | Delete
* Alternatively you can use the `WP_DISABLE_FATAL_ERROR_HANDLER` constant.
[132] Fix | Delete
*
[133] Fix | Delete
* @since 5.2.0
[134] Fix | Delete
*
[135] Fix | Delete
* @param bool $enabled True if the fatal error handler is enabled, false otherwise.
[136] Fix | Delete
*/
[137] Fix | Delete
return apply_filters( 'wp_fatal_error_handler_enabled', $enabled );
[138] Fix | Delete
}
[139] Fix | Delete
[140] Fix | Delete
/**
[141] Fix | Delete
* Access the WordPress Recovery Mode instance.
[142] Fix | Delete
*
[143] Fix | Delete
* @since 5.2.0
[144] Fix | Delete
*
[145] Fix | Delete
* @return WP_Recovery_Mode
[146] Fix | Delete
*/
[147] Fix | Delete
function wp_recovery_mode() {
[148] Fix | Delete
static $wp_recovery_mode;
[149] Fix | Delete
[150] Fix | Delete
if ( ! $wp_recovery_mode ) {
[151] Fix | Delete
$wp_recovery_mode = new WP_Recovery_Mode();
[152] Fix | Delete
}
[153] Fix | Delete
[154] Fix | Delete
return $wp_recovery_mode;
[155] Fix | Delete
}
[156] Fix | Delete
[157] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function