钩子文档

wp_php_error_message

💡 云策文档标注

概述

wp_php_error_message 是一个 WordPress 过滤器,用于修改默认 PHP 错误模板中显示的错误消息。它允许开发者自定义错误信息的输出内容。

关键要点

  • 这是一个过滤器 Hook,名称为 wp_php_error_message。
  • 它接收两个参数:$message(HTML 错误消息字符串)和 $error(从 error_get_last() 获取的错误信息数组)。
  • 主要用于 WP_Fatal_Error_Handler::display_default_error_template() 方法中,以控制错误模板的显示。
  • 自 WordPress 5.2.0 版本引入。

📄 原文内容

Filters the message that the default PHP error template displays.

Parameters

$messagestring
HTML error message to display.
$errorarray
Error information retrieved from error_get_last().

Source

$message = apply_filters( 'wp_php_error_message', $message, $error );

Changelog

Version Description
5.2.0 Introduced.