function oembed_get_provider in oEmbed 7.0
Same name and namespace in other branches
- 7 oembed.module \oembed_get_provider()
Returns the provider for a url.
Parameters
string $url: Teh url to get the provider for.
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 169
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) {
// Plugins will only be checked if they are enabled for the role.
if ($plugin[$role] && preg_match($plugin['scheme'], $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;
}