widget_text_content filter-hookWP 4.8.0

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.

Usage

add_filter( 'widget_text_content', 'wp_kama_widget_text_content_filter', 10, 3 );

/**
 * Function for `widget_text_content` filter-hook.
 * 
 * @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.
 *
 * @return string
 */
function wp_kama_widget_text_content_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)
Current Text widget instance.

Changelog

Since 4.8.0 Introduced.

Where the hook is called

WP_Widget_Text::widget()
widget_text_content
wp-includes/widgets/class-wp-widget-text.php 296
$text = apply_filters( 'widget_text_content', $text, $instance, $this );

Where the hook is used in WordPress

wp-includes/class-wp-embed.php 33
add_filter( 'widget_text_content', array( $this, 'run_shortcode' ), 8 );
wp-includes/class-wp-embed.php 41
add_filter( 'widget_text_content', array( $this, 'autoembed' ), 8 );
wp-includes/default-filters.php 220
add_filter( 'widget_text_content', 'capital_P_dangit', 11 );
wp-includes/default-filters.php 221
add_filter( 'widget_text_content', 'wptexturize' );
wp-includes/default-filters.php 222
add_filter( 'widget_text_content', 'convert_smilies', 20 );
wp-includes/default-filters.php 223
add_filter( 'widget_text_content', 'wpautop' );
wp-includes/default-filters.php 224
add_filter( 'widget_text_content', 'shortcode_unautop' );
wp-includes/default-filters.php 225
add_filter( 'widget_text_content', 'wp_filter_content_tags' );
wp-includes/default-filters.php 226
add_filter( 'widget_text_content', 'wp_replace_insecure_home_url' );
wp-includes/default-filters.php 227
add_filter( 'widget_text_content', 'do_shortcode', 11 ); // Runs after wpautop(); note that $post global will be null when shortcodes run.