no_texturize_shortcodes
云策文档标注
概述
no_texturize_shortcodes 是一个 WordPress 过滤器,用于管理不进行文本化处理的短代码列表。它允许开发者指定哪些短代码的内容应避免被 wptexturize() 函数自动转换引号等字符。
关键要点
- no_texturize_shortcodes 过滤器控制短代码是否被文本化处理,防止原始文本被意外修改。
- 参数 $default_no_texturize_shortcodes 是一个字符串数组,包含默认不文本化的短代码名称。
- 通过 add_filter() 添加自定义短代码到列表中,以保护其内容不被 wptexturize() 影响。
代码示例
add_filter( 'no_texturize_shortcodes', 'shortcodes_to_exempt_from_wptexturize' );
function shortcodes_to_exempt_from_wptexturize( $shortcodes ) {
$shortcodes[] = 'myshortcode';
return $shortcodes;
}
原文内容
Filters the list of shortcodes not to texturize.
Parameters
$default_no_texturize_shortcodesstring[]-
An array of shortcode names.
Source
$no_texturize_shortcodes = apply_filters( 'no_texturize_shortcodes', $default_no_texturize_shortcodes );
Changelog
| Version | Description |
|---|---|
| 2.8.0 | Introduced. |
Skip to note 2 content
Steven Lin
Example Migrated from Codex:
The example below adds the shortcode “myshortcode” to the list of shortcodes not to texturize.
add_filter( 'no_texturize_shortcodes', 'shortcodes_to_exempt_from_wptexturize' ); function shortcodes_to_exempt_from_wptexturize( $shortcodes ) { $shortcodes[] = 'myshortcode'; return $shortcodes; }