function elf_url_external in External Links Filter 6.3
Same name and namespace in other branches
- 5.3 elf.module \elf_url_external()
- 7.3 elf.module \elf_url_external()
Test if a URL is external
Parameters
$url string:
1 call to elf_url_external()
- elf_replace in ./
elf.module - Add classes to external or mailto links in a text.
File
- ./
elf.module, line 183 - Adds an icon to external and mailto links.
Code
function elf_url_external($url) {
global $base_url;
static $pattern = NULL;
// Statically store internal domains as a PCRE pattern.
if (!$pattern) {
$domains = array();
foreach (array_merge(variable_get('elf_domains', array()), array(
$base_url,
)) as $domain) {
$domains[] = preg_quote($domain, '#');
}
$pattern = '#^(' . str_replace('\\*', '.*', implode('|', $domains)) . ')#';
}
return preg_match($pattern, $url) ? FALSE : menu_path_is_external($url);
}