From 5a6a34fa957e8cd5f666fee8eb9890eb87b0734f Mon Sep 17 00:00:00 2001 From: Drew Jaynes Date: Fri, 25 Sep 2015 19:20:37 +0000 Subject: [PATCH] Widgets: Pass `$this` to the `widget_text` filter to make targeting specific widget instances easier. Also fixes docs errors in the type and description for the `$instance` parameter, introduced in [27697]. Fixes #24605. git-svn-id: https://develop.svn.wordpress.org/trunk@34552 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/widgets/class-wp-widget-text.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/wp-includes/widgets/class-wp-widget-text.php b/src/wp-includes/widgets/class-wp-widget-text.php index 962e5ed6d1..859b4ecdf1 100644 --- a/src/wp-includes/widgets/class-wp-widget-text.php +++ b/src/wp-includes/widgets/class-wp-widget-text.php @@ -30,15 +30,20 @@ class WP_Widget_Text extends WP_Widget { /** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */ $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance, $this->id_base ); + $widget_text = ! empty( $instance['text'] ) ? $instance['text'] : ''; + /** * Filter the content of the Text widget. * * @since 2.3.0 + * @since 4.4.0 Added the `$this` parameter. * - * @param string $widget_text The widget content. - * @param WP_Widget $instance WP_Widget instance. + * @param string $widget_text The widget content. + * @param array $instance Array of settings for the current widget. + * @param WP_Widget_Text $this Current Text widget instance. */ - $text = apply_filters( 'widget_text', empty( $instance['text'] ) ? '' : $instance['text'], $instance ); + $text = apply_filters( 'widget_text', $widget_text, $instance, $this ); + echo $args['before_widget']; if ( ! empty( $title ) ) { echo $args['before_title'] . $title . $args['after_title'];