钩子文档

attribute_escape

💡 云策文档标注

概述

attribute_escape 是一个 WordPress 过滤器钩子,用于在字符串经过 esc_attr() 函数清理和转义后,输出到 HTML 属性之前进行过滤。它允许开发者修改已转义或原始文本。

关键要点

  • 这是一个过滤器钩子,用于处理 HTML 属性输出中的字符串。
  • 它接收两个参数:$safe_text(已转义的文本)和 $text(原始文本)。
  • 常用于自定义 esc_attr() 函数的行为或添加额外处理。
  • 在 WordPress 2.0.6 版本中引入。

📄 原文内容

Filters a string cleaned and escaped for output in an HTML attribute.

Description

Text passed to esc_attr() is stripped of invalid or special characters before output.

Parameters

$safe_textstring
The text after it has been escaped.
$textstring
The text prior to being escaped.

Source

return apply_filters( 'attribute_escape', $safe_text, $text );

Changelog

Version Description
2.0.6 Introduced.