Adds a URL format and oEmbed provider URL pair.
Description
See also
Parameters
$format
stringrequired- The format of URL that this provider can handle. You can use asterisks as wildcards.
$provider
stringrequired- The URL to the oEmbed provider.
$regex
booloptional- Whether the
$format
parameter is in a RegEx format.Default:
false
Source
function wp_oembed_add_provider( $format, $provider, $regex = false ) {
if ( did_action( 'plugins_loaded' ) ) {
$oembed = _wp_oembed_get_object();
$oembed->providers[ $format ] = array( $provider, $regex );
} else {
WP_oEmbed::_add_provider_early( $format, $provider, $regex );
}
}
Changelog
Version | Description |
---|---|
2.9.0 | Introduced. |
Basic Example
Register a provider for any URL beginning in http://site.com/watchvideo/ using a simple wildcard URL format:
Note: Do not leave empty space, neither before nor after
YouTube
Register YouTube’s oEmbed provider for YouTube URLs using a regex URL format:
Note: YouTube is already registered by default with WordPress. This is merely an example, you do not need to register YouTube yourself.