[wp-trac] [WordPress Trac] #28284: Calling `wp_oembed_add_provider()` before the `plugins_loaded` action shouldn't be allowed
WordPress Trac
noreply at wordpress.org
Fri May 16 17:52:14 UTC 2014
#28284: Calling `wp_oembed_add_provider()` before the `plugins_loaded` action
shouldn't be allowed
--------------------------+-----------------------------
Reporter: johnbillion | Owner:
Type: defect (bug) | Status: new
Priority: low | Milestone: Awaiting Review
Component: Embeds | Version: 2.9
Severity: normal | Keywords: dev-feedback
Focuses: |
--------------------------+-----------------------------
If a plugin calls `wp_oembed_add_provider()` before the `plugins_loaded`
hook (ie. as soon as the plugin file is included), it can prevent other
plugins from hooking into the `oembed_providers` filter.
This happens because `wp_oembed_add_provider()` calls
`_wp_oembed_get_object()` which instantiates the `WP_oEmbed` class which
immediately applies the `oembed_providers` filter in its constructor. If
another plugin is hooked into this filter but isn't yet loaded, it's
straight outta luck because the filter has already been applied.
To prevent this problem, we should add a check to
`wp_oembed_add_provider()` which triggers a `_doing_it_wrong()` call if
the `plugins_loaded` action hasn't fired. This gives other plugins a
chance to hook into the `oembed_providers` filter.
Alternatively we could move the `oembed_providers` filter so it fires JIT
(in the `get_html()` method) rather than when the class is instantiated.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/28284>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list