#34167 closed enhancement (fixed)
Shortcode_atts pass $shortcode
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 4.4 | Priority: | normal |
Severity: | normal | Version: | 4.4 |
Component: | General | Keywords: | has-patch |
Focuses: | Cc: |
Description
It would be useful to pass the Shortcode name as the 4th param to the filter shortcode_atts_{$shortcode}
Use case - I am wanting to add a filter for a number of shortcodes - so I loop through the and add the filter. However this means that I don't know the exact shortcode context in the callback.
Workaround - I am currently working around this by using a closure and use
to import the $shortcode
variable into the closure. However this is not PHP 5.2 compatable.
Attachments (2)
Change History (9)
#2
@
9 years ago
- Milestone changed from Awaiting Review to 4.4
Just for reference, since I wondered this as I read the ticket: in #15155 it appears that @nacin suggested not having the generic `shortcode_atts` filter.
#3
@
9 years ago
Oh good call on using current_filter
to achieve this. I'd be happy enough with this solution.
#4
@
9 years ago
Two things about the patch:
- Needs a changelog entry for the added argument.
- Since we're touching the lines, add curly braces.
Adding context seems like a smart thing to do, though workarounds may exist.
Just FYI, another option in a case like this is to use the
current_filter()
function to determine the value of the dynamic portion of the hook. Your patch would be even better, of course. :-)