钩子文档

no_texturize_tags

💡 云策文档标注

概述

no_texturize_tags 过滤器用于指定不应通过 wptexturize() 函数处理的 HTML 元素列表。默认情况下,WordPress 会自动对内容进行文本化处理,将普通引号替换为智能引号,但某些情况下(如短代码包含原始文本)需要避免此操作。

关键要点

  • 过滤器参数:$default_no_texturize_tags,一个 HTML 元素名称数组。
  • 功能:允许开发者自定义哪些 HTML 元素不进行文本化处理。
  • 默认行为:WordPress 自动文本化所有文章/页面内容,可能影响短代码等场景。
  • 相关函数:wptexturize() 用于替换普通文本字符为格式化实体。
  • 引入版本:WordPress 2.8.0。

代码示例

add_filter( 'no_texturize_tags', 'my_no_texturzie_tags' );

function my_no_texturzie_tags( $tags ) {
   $tags[] = 'blockquote';
   return $tags;
}

📄 原文内容

Filters the list of HTML elements not to texturize.

Parameters

$default_no_texturize_tagsstring[]
An array of HTML element names.

More Information

  • The ‘no_texturize_tags‘ filter allows you to specify which HTML elements should not run through the wptexturize() function.
  • By default, WordPress will automatically texturize all post/page content. The texturize process replaces “normal” quotes with “fancy” quotes (aka “smart” quotes or “curly” quotes). Sometimes this is NOT what you want… particularly if your shortcode must contain raw, preprocessed text.

Source

$no_texturize_tags = apply_filters( 'no_texturize_tags', $default_no_texturize_tags );

Changelog

Version Description
2.8.0 Introduced.

User Contributed Notes