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:
parent
a6a00a3625
commit
5a6a34fa95
@ -30,15 +30,20 @@ class WP_Widget_Text extends WP_Widget {
|
|||||||
/** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */
|
/** 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 );
|
$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.
|
* Filter the content of the Text widget.
|
||||||
*
|
*
|
||||||
* @since 2.3.0
|
* @since 2.3.0
|
||||||
|
* @since 4.4.0 Added the `$this` parameter.
|
||||||
*
|
*
|
||||||
* @param string $widget_text The widget content.
|
* @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'];
|
echo $args['before_widget'];
|
||||||
if ( ! empty( $title ) ) {
|
if ( ! empty( $title ) ) {
|
||||||
echo $args['before_title'] . $title . $args['after_title'];
|
echo $args['before_title'] . $title . $args['after_title'];
|
||||||
|
Loading…
Reference in New Issue
Block a user