钩子文档

deprecated_argument_trigger_error

💡 云策文档标注

概述

deprecated_argument_trigger_error 是一个 WordPress 过滤器,用于控制是否在参数被弃用时触发错误。它通常与 WP_DEBUG 配合使用,以帮助开发者识别和更新过时的代码。

关键要点

  • 这是一个过滤器,用于决定是否触发弃用参数的错误。
  • 默认值为 true,表示默认会触发错误。
  • 常与 WP_DEBUG 常量结合使用,仅在调试模式下生效。
  • 与 _deprecated_argument() 函数相关,用于标记弃用的函数参数。

代码示例

if ( WP_DEBUG && apply_filters( 'deprecated_argument_trigger_error', true ) ) {
    // 触发错误的代码逻辑
}

注意事项

  • 此过滤器在 WordPress 3.0.0 版本中引入。
  • 仅在 WP_DEBUG 为 true 时,过滤器才会生效,避免在生产环境中显示错误。
  • 开发者可以通过添加过滤器回调来修改触发错误的行为,例如设置为 false 以禁用错误。

📄 原文内容

Filters whether to trigger an error for deprecated arguments.

Parameters

$triggerbool
Whether to trigger the error for deprecated arguments. Default true.

Source

if ( WP_DEBUG && apply_filters( 'deprecated_argument_trigger_error', true ) ) {

Changelog

Version Description
3.0.0 Introduced.