widget_text
Filters the content of the Text widget.
Usage
add_filter( 'widget_text', 'wp_kama_widget_text_filter', 10, 3 ); /** * Function for `widget_text` filter-hook. * * @param string $text The widget content. * @param array $instance Array of settings for the current widget. * @param WP_Widget_Text|WP_Widget_Custom_HTML $widget Current text or HTML widget instance. * * @return string */ function wp_kama_widget_text_filter( $text, $instance, $widget ){ // filter... return $text; }
- $text(string)
- The widget content.
- $instance(array)
- Array of settings for the current widget.
- $widget(WP_Widget_Text|WP_Widget_Custom_HTML)
- Current text or HTML widget instance.
Changelog
Since 2.3.0 | Introduced. |
Since 4.4.0 | Added the $widget parameter. |
Since 4.8.1 | The $widget param may now be a WP_Widget_Custom_HTML object in addition to a WP_Widget_Text object. |
Where the hook is called
wp-includes/widgets/class-wp-widget-text.php 283
$text = apply_filters( 'widget_text', $text, $instance, $this );
wp-includes/widgets/class-wp-widget-custom-html.php 150
$content = apply_filters( 'widget_text', $instance['content'], $simulated_text_widget_instance, $this );
Where the hook is used in WordPress
wp-includes/default-filters.php 228
add_filter( 'widget_text', 'balanceTags' );
wp-includes/widgets/class-wp-widget-text.php 256
remove_filter( 'widget_text', 'do_shortcode', $widget_text_do_shortcode_priority );
wp-includes/widgets/class-wp-widget-text.php 327
add_filter( 'widget_text', 'do_shortcode', $widget_text_do_shortcode_priority );