#25313 closed defect (bug) (fixed)
Video and audio shortcode callback functions wrapped in a filter, but executed too early to be hooked onto
Reported by: | ericlewis | Owned by: | SergeyBiryukov |
---|---|---|---|
Milestone: | 3.7 | Priority: | normal |
Severity: | normal | Version: | 3.6 |
Component: | Media | Keywords: | has-patch commit |
Focuses: | Cc: |
Description
In the add_shortcode calls for the video and audio shortcodes, both seem to offer developers the option to register their own callback for this shortcode by wrapping the default callback in a wrapper. However, media.php is loaded before even mu-plugins, so there is no way save hacking core to add a filter here.
Attachments (7)
Change History (24)
#1
@
11 years ago
- Summary changed from Video and audio shortcode callback functions wrapped in a filter, but too early to be hooked onto to Video and audio shortcode callback functions wrapped in a filter, but executed too early to be hooked onto
#3
@
11 years ago
25313.patch is an attempt to add all the default shortcodes on init with the highest priority, like we do for create_initial_post_types()
.
#4
@
11 years ago
I'm OK with 25313.patch, though:
- It needs a better name.
add_shortcodes()
sounds like a multiple-shortcode version ofadd_shortcode()
, not a core registration.wp_add_initial_shortcodes()
perhaps. - As always, I am curious what this might break...
#5
@
11 years ago
To be honest, though, I'd rather just remove these filters and force everything to go through wp_audio_shortcode()
and wp_video_shortcode()
. Then, have an early filter in both of those functions that allow short-circuiting.
This pattern for existing shortcodes came up *huge* when we changed how the caption shortcode worked, when we put the caption inside the shortcode content. Huge forwards compatibility win.
#6
@
11 years ago
25313.2.patch uses wp_add_initial_shortcodes()
.
#9
@
11 years ago
Piggybacking on Sergey's work, attachment:25313.4.patch:
- changes the new filter's name to wp_(audio|video)_shortcode_override, as the filter isn't a handler
- passes $instances into the filter, as this can be handy in the overriding function to give separate media instances independent names.
#10
@
11 years ago
- Keywords has-patch added
25313.5.patch changes the default value to an empty string, for consistency with the post_gallery
filter.
#13
@
11 years ago
We should properly document these. Also, while post_gallery is a good model to follow, I'm not sure I love '' !==
. We use false more often, though ideally we actually use null wherever possible. Or so goes my idealistic thinking, anyway.
Is there a compelling reason to use ''
? I'd think any string returned should be obeyed. Returning nothing is valid in some contexts, I'd suggest.
#14
@
11 years ago
attachment:25313.6.patch adds hook documentation, and changes the pre-filtered value to null.
#15
@
11 years ago
- Owner set to SergeyBiryukov
- Resolution set to fixed
- Status changed from new to closed
In 25484:
#16
@
11 years ago
25313.7.patch makes the arguments more consistent with the ones of img_caption_shortcode
and post_gallery
filters, per the IRC discussion.
Confirmed, the filters are currently unusable:
wp_audio_shortcode_handler
: tags/3.6.1/wp-includes/media.php#L949wp_video_shortcode_handler
: tags/3.6.1/wp-includes/media.php#L1093