function oembed_get_provider in oEmbed 7
Same name and namespace in other branches
- 7.0 oembed.module \oembed_get_provider()
Returns the provider for a url.
Parameters
string $url: The url to get the provider for.
array $matches: Array reference for providers that capture arguments from URL.
string $role:
Return value
mixed A valid callback or FALSE
7 calls to oembed_get_provider()
- MediaInternetOEmbedHandler::claim in ./
MediaInternetOEmbedHandler.inc - Claim this URL.
- OEmbedStreamWrapper::stream_open in ./
OEmbedStreamWrapper.inc - Support for fopen(), file_get_contents(), file_put_contents() etc.
- oembed_get_data in ./
oembed.module - Fetch data for an embeddable URL.
- oembed_media_parse in ./
oembed.media.inc - Implements hook_media_parse().
- oembed_resolve_link in ./
oembed.filter.inc - PREG replace callback finds [embed] shortcodes, URLs and request options.
File
- ./
oembed.module, line 174 - Core functionality for oEmbed
Code
function oembed_get_provider($url, &$matches, $role = 'consumer') {
ctools_include('plugins');
$plugins = ctools_get_plugins('oembed', 'providers');
uasort($plugins, 'ctools_plugin_sort');
// This function may need check twice if a provider matches the URL. The first
// check is to determine if the plugin's callback can handle the URL.
// The second check returns the name of the child plugin that can fulfill
// the request.
foreach ($plugins as $plugin) {
// A plugin with no schemes is effectively disabled.
if ($plugin[$role] && !empty($plugin['scheme'])) {
// Remove '#' and '#i' from the begining and end.
$scheme = substr($plugin['scheme'], 1, -2);
$sub_schemes = explode('|', $scheme);
foreach ($sub_schemes as $pattern) {
// Plugins will only be checked if they are enabled for the role.
if (preg_match("#{$pattern}#i", $url, $matches)) {
// A scheme map is used to match a URL to a specific child plugin.
if (!empty($plugin['scheme map'])) {
foreach ($plugin['scheme map'] as $id => $scheme) {
if (preg_match($scheme, $url, $matches)) {
// This forces the 'get child' callback to the loaded.
ctools_plugin_get_function($plugin, 'get child');
$plugin = ctools_get_plugins('oembed', 'providers', $id);
break;
}
}
}
return $plugin;
}
}
}
}
return FALSE;
}