diff -u b/core/includes/common.inc b/core/includes/common.inc --- b/core/includes/common.inc +++ b/core/includes/common.inc @@ -2273,7 +2273,7 @@ */ function l($text, $path, array $options = array()) { // Build a variables array to keep the structure of the alter consistent with - // template_preprocess_link(). + // theme_link(). $variables = array( 'text' => $text, 'path' => $path, diff -u b/core/includes/theme.inc b/core/includes/theme.inc --- b/core/includes/theme.inc +++ b/core/includes/theme.inc @@ -1681,18 +1681,14 @@ } /** - * Prepares variables for link templates. + * Returns HTML for a link. * - * Default template: link.html.twig. + * This is a wrapper around l() to allow for more advanced themeing and use of + * array(#theme => 'link') style render arrays. * - * All Drupal code that outputs a link should call the l() function. That - * function performs some initial preprocessing, and then, if necessary, calls - * theme('link') for rendering the anchor tag. - * - * To optimize performance for sites that don't need custom theming of links, - * the l() function includes an inline copy of this function, and uses that - * copy if none of the enabled modules or the active theme implement any - * preprocess or process functions or override this theme implementation. + * Where performance is more important than theme flexibility, always call l() + * directly. There is a measurable performance impact when using theme('link') + * style implementations on link-heavy sites. * * @param $variables * An associative array containing the keys 'text', 'path', and 'options'. @@ -1700,39 +1696,8 @@ * * @see l() */ -function template_preprocess_link(&$variables) { - // Merge in defaults. - $variables['options'] += array( - 'attributes' => array(), - 'query' => array(), - 'html' => FALSE, - ); - - // Add 'active' class if appropriate. - if ($variables['url_is_active'] = url_is_active($variables['path'], $variables['options'])) { - $variables['options']['attributes']['class'][] = 'active'; - } - - // Remove all HTML and PHP tags from a tooltip, calling expensive strip_tags() - // only when a quick strpos() gives suspicion tags are present. - if (isset($variables['options']['attributes']['title']) && strpos($variables['options']['attributes']['title'], '<') !== FALSE) { - $variables['options']['attributes']['title'] = strip_tags($variables['options']['attributes']['title']); - } - - // Allow other modules to modify the structure of the link. - drupal_container()->get('module_handler')->alter('link', $variables); - - // Move attributes out of options. url() doesn't need them and they make more - // sense as top level variables in templates. - $variables['attributes'] = new Attribute($variables['options']['attributes']); - unset($variables['options']['attributes']); - - // The result of url() is a plain-text URL. Because we are using it here - // in an HTML argument context, we need to encode it properly. - $variables['url'] = check_plain(url($variables['path'], $variables['options'])); - - // Sanitize the link text if necessary. - $variables['text'] = ($variables['options']['html']) ? $variables['text'] : check_plain($variables['text']); +function theme_link(&$variables) { + return l($variables['text'], $variables['path'], $variables['options']); } /** @@ -3185,7 +3150,6 @@ ), 'link' => array( 'variables' => array('text' => NULL, 'path' => NULL, 'options' => array()), - 'template' => 'link', ), 'links' => array( 'variables' => array('links' => array(), 'attributes' => array('class' => array('links')), 'heading' => array()), reverted: --- b/core/modules/system/templates/link.html.twig +++ /dev/null @@ -1,15 +0,0 @@ -{# -/** - * Returns HTML for a link tag. - * - * Available variables - * - text: The content to display within the element. - * - url: The sanitized url for this link. - * - url_is_active: TRUE if the url for this link leads to the current page. - * - attributes: (optional) HTML attributes to apply to the element. - * - * @see template_preprocess_link() - * @ingroup themeable - */ -#} -{{ text }}