#16327 closed defect (bug) (fixed)
oEmbed - Add a function to remove an oEmbed provider
| Reported by: | r-a-y | Owned by: | ryan |
|---|---|---|---|
| Priority: | normal | Milestone: | 3.5 |
| Component: | Media | Version: | 2.9 |
| Severity: | normal | Keywords: | has-patch needs-refresh |
| Cc: | Focuses: |
Description
In /wp-includes/media.php, there's the ability to add an oEmbed provider with wp_oembed_add_provider(), but no way to remove one.
The attached patch is an attempt to allow you to remove an oEmbed provider.
For the $match parameter, I've opted to allow you to match any portion of the $format key.
For example, to remove the YouTube oEmbed provider, you can use:
wp_oembed_remove_provider( '#http://(www\.)?youtube.com/watch.*#i', 'http://www.youtube.com/oembed' );
or:
wp_oembed_remove_provider( 'youtube.com', 'http://www.youtube.com/oembed' );
---
If partial matching for the $format key is undesired, let me know and I'll repatch for an exact match only.
Attachments (3)
Change History (8)
Note:
See TracTickets
for help on using tickets.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
Clever, but I think we should just have:
function wp_oembed_remove_provider( $format ) { require_once( ABSPATH . WPINC . '/class-oembed.php' ); $oembed = _wp_oembed_get_object(); if ( isset( $oembed->providers[ $format ] ) ) { unset( $oembed->providers[ $format ] ); return true; } return false; }