钩子文档

widget_text_content

💡 云策文档标注

概述

widget_text_content 是一个 WordPress 过滤器,用于修改 Text 小部件的内容,以应用视觉编辑器(TinyMCE)预期的更改。默认情况下,它会应用 wpautop 和 wptexturize 等部分 the_content 过滤器。

关键要点

  • 过滤器名称:widget_text_content
  • 作用:过滤 Text 小部件的内容,支持视觉编辑器功能
  • 参数:$text(字符串,小部件内容)、$instance(数组,当前小部件设置)、$widget(WP_Widget_Text 实例)
  • 默认应用:wpautop 和 wptexturize 等 the_content 过滤器子集
  • 引入版本:4.8.0
  • 相关函数:在 WP_Widget_Text::widget() 中使用

代码示例

$text = apply_filters( 'widget_text_content', $text, $instance, $this );

📄 原文内容

Filters the content of the Text widget to apply changes expected from the visual (TinyMCE) editor.

Description

By default a subset of the_content filters are applied, including wpautop and wptexturize.

Parameters

$textstring
The widget content.
$instancearray
Array of settings for the current widget.
$widgetWP_Widget_Text
Current Text widget instance.

Source

$text = apply_filters( 'widget_text_content', $text, $instance, $this );

Changelog

Version Description
4.8.0 Introduced.