wp_should_handle_php_error
云策文档标注
概述
wp_should_handle_php_error 是一个 WordPress 过滤器,用于控制是否由致命错误处理器处理特定的 PHP 错误。它允许开发者添加额外的规则来决定哪些错误应被处理,但不能移除 WordPress 核心已配置的处理规则。
关键要点
- 此过滤器仅在错误未被 WordPress 核心配置处理时触发,专门用于添加处理规则,而非移除现有规则。
- 参数包括 $should_handle_error(布尔值,指示是否应处理错误)和 $error(数组,来自 error_get_last() 的错误信息)。
- 在 WP_Fatal_Error_Handler::should_handle_error() 中使用,以保护后台免受白屏死机(WSOD)影响。
- 自 WordPress 5.2.0 版本引入。
原文内容
Filters whether a given thrown error should be handled by the fatal error handler.
Description
This filter is only fired if the error is not already configured to be handled by WordPress core. As such, it exclusively allows adding further rules for which errors should be handled, but not removing existing ones.
Parameters
$should_handle_errorbool-
Whether the error should be handled by the fatal error handler.
$errorarray-
Error information retrieved from
error_get_last().
Source
return (bool) apply_filters( 'wp_should_handle_php_error', false, $error );
Changelog
| Version | Description |
|---|---|
| 5.2.0 | Introduced. |