1.20.x link.theme.inc | theme_link_formatter_link_default($variables) |
Formats a link.
File
- modules/
link/ link.theme.inc, line 42 - Theme functions and preprocessing for Link module output.
Code
function theme_link_formatter_link_default($variables) {
$output = '';
$link_options = $variables['element'];
unset($link_options['title']);
unset($link_options['url']);
if (isset($link_options['attributes']['class'])) {
$link_options['attributes']['class'] = array($link_options['attributes']['class']);
}
// Display a normal link if both title and URL are available.
if (!empty($variables['element']['title']) && !empty($variables['element']['url'])) {
$output = l($variables['element']['title'], $variables['element']['url'], $link_options);
}
// If only a title, display the title.
elseif (!empty($variables['element']['title'])) {
$output = $link_options['html'] ? $variables['element']['title'] : check_plain($variables['element']['title']);
}
elseif (!empty($variables['element']['url'])) {
$output = l($variables['element']['title'], $variables['element']['url'], $link_options);
}
return $output;
}