Opened 11 years ago
Closed 9 years ago
#24605 closed enhancement (fixed)
Pass widget ID as a third parameter to widget_text filter
Reported by: | namarpi | Owned by: | DrewAPicture |
---|---|---|---|
Milestone: | 4.4 | Priority: | normal |
Severity: | normal | Version: | 3.5.1 |
Component: | Widgets | Keywords: | has-patch |
Focuses: | Cc: |
Description
I would like to identify the current widget when using widget_text filter. If the widget ID will be returned by the filter, it would be very useful. A solution can be adding a third parameter in the wp-includes/default-widget.php near the line 401:
Original:
$text = apply_filters( 'widget_text', empty( $instance['text'] ) ? '' : $instance['text'], $instance );
Offered:
$text = apply_filters( 'widget_text', empty( $instance['text'] ) ? '' : $instance['text'], $instance, $this->id );
Attachments (2)
Change History (13)
#3
@
11 years ago
- Summary changed from Returning widget ID as third parameter of widget_text filter to Pass widget ID as a third parameter to widget_text filter
- Type changed from feature request to enhancement
#4
@
11 years ago
Maybe it would be a better solution if the widget_text meta data in Options table will contain the widget ID. In this latter case there will be a possibility to find all the necessary widgets before (outside of) the loop.
#5
@
11 years ago
I would like to recant my Comment 4 because finally I have found the solution for getting widget IDs before the loop. In addition I would like to opiniate my original ticket.
#7
@
10 years ago
- Keywords has-patch added; needs-patch removed
I definitely see the benefit in being able to selectively filter text widgets.
ID is passed through via:
$args['widget_id']
I've attached a quick patch above.
#8
@
9 years ago
- Milestone changed from Awaiting Review to 4.4
- Owner set to DrewAPicture
- Status changed from new to assigned
#10
@
9 years ago
Let's pass the entire WP_Widget_Text
instance instead of just a part of it. Also, the type and description on the $instance
parameter were incorrect. Both are done in 24605.diff.
+1