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
This commit is contained in:
Drew Jaynes 2015-09-25 19:20:37 +00:00
parent a6a00a3625
commit 5a6a34fa95

View File

@ -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 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'];