widget_text_content хук-фильтрWP 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.

Использование

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(строка)
The widget content.
$instance(массив)
Array of settings for the current widget.
$widget(WP_Widget_Text)
Current Text widget instance.

Список изменений

С версии 4.8.0 Введена.

Где вызывается хук

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

Где используется хук в WordPress

wp-includes/class-wp-embed.php 34
add_filter( 'widget_text_content', array( $this, 'run_shortcode' ), 8 );
wp-includes/class-wp-embed.php 42
add_filter( 'widget_text_content', array( $this, 'autoembed' ), 8 );
wp-includes/default-filters.php 229
add_filter( 'widget_text_content', 'capital_P_dangit', 11 );
wp-includes/default-filters.php 230
add_filter( 'widget_text_content', 'wptexturize' );
wp-includes/default-filters.php 231
add_filter( 'widget_text_content', 'convert_smilies', 20 );
wp-includes/default-filters.php 232
add_filter( 'widget_text_content', 'wpautop' );
wp-includes/default-filters.php 233
add_filter( 'widget_text_content', 'shortcode_unautop' );
wp-includes/default-filters.php 234
add_filter( 'widget_text_content', 'wp_replace_insecure_home_url' );
wp-includes/default-filters.php 235
add_filter( 'widget_text_content', 'do_shortcode', 11 ); // Runs after wpautop(); note that $post global will be null when shortcodes run.
wp-includes/default-filters.php 236
add_filter( 'widget_text_content', 'wp_filter_content_tags', 12 ); // Runs after do_shortcode().