Filter hook 'widget_text'

in WP Core File wp-includes/widgets/class-wp-widget-text.php at line 283

View Source

widget_text

Filter Hook
Description
Filters the content of the Text widget.

Hook Information

File Location wp-includes/widgets/class-wp-widget-text.php View on GitHub
Hook Type Filter
Line Number 283

Hook Parameters

Type Name Description
string $text The widget content.
array $instance Array of settings for the current widget.
WP_Widget_Text|WP_Widget_Custom_HTML $widget Current text or HTML widget instance.

Usage Examples

Basic Usage
<?php
// Hook into widget_text
add_filter('widget_text', 'my_custom_filter', 10, 3);

function my_custom_filter($text, $instance, $widget) {
    // Your custom filtering logic here
    return $text;
}

Source Code Context

wp-includes/widgets/class-wp-widget-text.php:283 - How this hook is used in WordPress core
<?php
 278  		 *
 279  		 * @param string                               $text     The widget content.
 280  		 * @param array                                $instance Array of settings for the current widget.
 281  		 * @param WP_Widget_Text|WP_Widget_Custom_HTML $widget   Current text or HTML widget instance.
 282  		 */
 283  		$text = apply_filters( 'widget_text', $text, $instance, $this );
 284  
 285  		if ( $is_visual_text_widget ) {
 286  
 287  			/**
 288  			 * Filters the content of the Text widget to apply changes expected from the visual (TinyMCE) editor.

PHP Documentation

<?php
/**
		 * Filters the content of the Text widget.
		 *
		 * @since 2.3.0
		 * @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.
		 *
		 * @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.
		 */
Quick Info
  • Hook Type: Filter
  • Parameters: 3
  • File: wp-includes/widgets/class-wp-widget-text.php
Related Hooks

Related hooks will be displayed here in future updates.