function theme_link_formatter_link_no_protocol in Link 7
Formats a link without the http:// or https://.
File
- ./
link.module, line 1407 - Defines simple link field types.
Code
function theme_link_formatter_link_no_protocol($vars) {
// If no URL value is present there's no point in continuing.
if (empty($vars['element']['url'])) {
return '';
}
$link_options = $vars['element'];
unset($link_options['title']);
unset($link_options['url']);
// We drop any scheme of the url.
$scheme = parse_url($vars['element']['url']);
$search = '/' . preg_quote($scheme['scheme'] . '://', '/') . '/';
$replace = '';
$display_url = preg_replace($search, $replace, $vars['element']['url'], 1);
return l($display_url, $vars['element']['url'], $link_options);
}