钩子文档

widget_custom_html_content

💡 云策文档标注

概述

本文档介绍了 widget_custom_html_content 过滤器,用于过滤 Custom HTML 小部件的内容。它允许开发者在输出前修改小部件的内容、设置或实例。

关键要点

  • widget_custom_html_content 是一个 WordPress 过滤器,应用于 Custom HTML 小部件的内容。
  • 过滤器接受三个参数:$content(小部件内容字符串)、$instance(当前小部件设置数组)和 $widget(当前 Custom HTML 小部件实例)。
  • 该过滤器在 WP_Widget_Custom_HTML::widget() 方法中被调用,用于输出小部件内容。
  • 从 WordPress 4.8.1 版本开始引入此过滤器。

代码示例

$content = apply_filters( 'widget_custom_html_content', $content, $instance, $this );

📄 原文内容

Filters the content of the Custom HTML widget.

Parameters

$contentstring
The widget content.
$instancearray
Array of settings for the current widget.
$widgetWP_Widget_Custom_HTML
Current Custom HTML widget instance.

Source

$content = apply_filters( 'widget_custom_html_content', $content, $instance, $this );

Changelog

Version Description
4.8.1 Introduced.