WordPress.org

Codex

Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Function Reference/wp oembed add provider

Description

Registers an oEmbed provider with WordPress and adds it to the whitelist, allowing all users who can write posts to use this provider. See the Embeds document for more details.

This function should be called from a plugin or a theme's functions.php file.

Usage

 <?php wp_oembed_add_provider$format$provider$regex ); ?> 

Parameters

$format
(string) (required) The URL structure that this oEmbed provider supports. Can either be in a wildcard format (use '*') or in a regex format (see the regex parameter)
Default: None
$provider
(string) (required) The base URL to the oEmbed provider. Query arguments will automatically be appended.
Default: None
$regex
(boolean) (optional) Designates whether the format parameter is a regex string or not. True means it is, False means it's just simple wildcard string.
Default: False

Examples

Register a provider for any URL beginning in http://site.com/watchvideo/ using a simple wildcard URL format:

<?php wp_oembed_add_provider( 'http://site.com/watchvideo/*', 'http://site.com/oembedprovider' ); ?>

Be careful,do not leave empty space, neither before nor after

Register YouTube's oEmbed provider for YouTube URLs using a regex URL format:

<?php wp_oembed_add_provider( '#http://(www\.)?youtube\.com/watch.*#i', 'http://www.youtube.com/oembed', true ); ?>

Note that YouTube is already registered by default with WordPress. This is merely an example, you do not need to register YouTube yourself.

Change Log

Since: 2.9.0

Source File

wp_oembed_add_provider() is located in wp-includes/embed.php.

Resources

Related

Embeds: wp_oembed_add_provider(), wp_oembed_remove_provider(), wp_oembed_get(), wp_embed_defaults(), wp_embed_register_handler(), wp_embed_unregister_handler(), get_embedded_audio(), get_embedded_media(), get_embedded_video(), wp_embed_handler_audio(), wp_embed_handler_video()