Make WordPress Core

Opened 16 years ago

Closed 14 years ago

Last modified 14 years ago

#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)

16327.001.patch (1.0 KB ) - added by r-a-y 16 years ago.
16327.diff (837 bytes ) - added by ryan 14 years ago.
16327-ut.diff (564 bytes ) - added by ryan 14 years ago.

Download all attachments as: .zip

Change History (8)

@r-a-y
16 years ago

#1 @nacin
16 years ago

  • Milestone Awaiting ReviewFuture Release
  • Version 3.12.9

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;
}

#2 @r-a-y
16 years ago

That was how I originally wrote the function.

I was concerned about having duplicate $format's when I just realized that $format is a key! D'oh!

So this works for me.

#3 @nacin
14 years ago

  • Keywords needs-refresh added
  • Milestone Future Release3.5

@ryan
14 years ago

@ryan
14 years ago

#4 @ryan
14 years ago

  • Owner set to ryan
  • Resolutionfixed
  • Status newclosed

In [21351]:

Introduce wp_oembed_remove_provider(). Props r-a-y. fixes #16327

#5 @ryan
14 years ago

Last edited 14 years ago by nacin (previous) (diff)
Note: See TracTickets for help on using tickets.