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.

Built from https://develop.svn.wordpress.org/trunk@34552


git-svn-id: http://core.svn.wordpress.org/trunk@34516 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Drew Jaynes 2015-09-25 19:21:24 +00:00
parent a729efa688
commit 54d5888688
2 changed files with 9 additions and 4 deletions

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.4-alpha-34551';
$wp_version = '4.4-alpha-34552';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.

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