Make WordPress Core

Changeset 34552


Ignore:
Timestamp:
09/25/2015 07:20:37 PM (9 years ago)
Author:
DrewAPicture
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/widgets/class-wp-widget-text.php

    r34440 r34552  
    3131        $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance, $this->id_base );
    3232
     33        $widget_text = ! empty( $instance['text'] ) ? $instance['text'] : '';
     34
    3335        /**
    3436         * Filter the content of the Text widget.
    3537         *
    3638         * @since 2.3.0
     39         * @since 4.4.0 Added the `$this` parameter.
    3740         *
    38          * @param string    $widget_text The widget content.
    39          * @param WP_Widget $instance    WP_Widget instance.
     41         * @param string         $widget_text The widget content.
     42         * @param array          $instance    Array of settings for the current widget.
     43         * @param WP_Widget_Text $this        Current Text widget instance.
    4044         */
    41         $text = apply_filters( 'widget_text', empty( $instance['text'] ) ? '' : $instance['text'], $instance );
     45        $text = apply_filters( 'widget_text', $widget_text, $instance, $this );
     46
    4247        echo $args['before_widget'];
    4348        if ( ! empty( $title ) ) {
Note: See TracChangeset for help on using the changeset viewer.