Filter hook 'widget_text_content'

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

View Source

widget_text_content

Filter Hook
Description
Filters the content of the Text widget to apply changes expected from the visual (TinyMCE) editor. By default a subset of the_content filters are applied, including wpautop and wptexturize.

Hook Information

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

Hook Parameters

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

Usage Examples

Basic Usage
<?php
// Hook into widget_text_content
add_filter('widget_text_content', '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:298 - How this hook is used in WordPress core
<?php
 293  			 *
 294  			 * @param string         $text     The widget content.
 295  			 * @param array          $instance Array of settings for the current widget.
 296  			 * @param WP_Widget_Text $widget   Current Text widget instance.
 297  			 */
 298  			$text = apply_filters( 'widget_text_content', $text, $instance, $this );
 299  		} else {
 300  			// Now in legacy mode, add paragraphs and line breaks when checkbox is checked.
 301  			if ( ! empty( $instance['filter'] ) ) {
 302  				$text = wpautop( $text );
 303  			}

PHP Documentation

<?php
/**
			 * Filters the content of the Text widget to apply changes expected from the visual (TinyMCE) editor.
			 *
			 * By default a subset of the_content filters are applied, including wpautop and wptexturize.
			 *
			 * @since 4.8.0
			 *
			 * @param string         $text     The widget content.
			 * @param array          $instance Array of settings for the current widget.
			 * @param WP_Widget_Text $widget   Current Text 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.