backdrop-contrib / radix

A responsive base theme with Bootstrap and Sass for Backdrop CMS.
http://docs.radixtheme.org
GNU General Public License v2.0
4 stars 2 forks source link

theme_link implementation breaks lots of other things #28

Closed jenlampton closed 7 years ago

jenlampton commented 7 years ago

in includes/menu.inc there is an implementation of theme_link() that does not take into account standard link properties, like #title. This means that if there is any use of theme('link') anywhere in Backdrop core or contrib, those links are going to be broken if the Radix theme is used.

/**
 * Implements theme_link().
 */
function radix_link($variables) {
  dpm('called me!');
  $icons = '';
  $variables['options']['attributes'] = !empty($variables['options']['attributes']) ? $variables['options']['attributes'] : array();
  $variables['options']['html'] = !empty($variables['options']['html']) ? $variables['options']['html'] : FALSE;
  if (isset($variables['options']['attributes']['class']) && is_array($variables['options']['attributes']['class'])) {
    $css_classes = $variables['options']['attributes']['class'];
    if ($icon_classes = preg_grep('/^icon\-.*/', $css_classes)) {
      // Render an icon for each class.
      foreach ($icon_classes as $icon_class) {
        $icons .= '<i class="' . $icon_class . '"></i>';
      }
      // Unset icon classes for attributes to prevent double rendering.
      $variables['options']['attributes']['class'] = array_diff($css_classes, $icon_classes);
    }
  }
  return '<a href="' . check_plain(url($variables['path'], $variables['options'])) . '"' . backdrop_attributes($variables['options']['attributes']) . '>' . $icons . ($variables['options']['html'] ? $variables['text'] : check_plain($variables['text'])) . '</a>';
}

There's no documentation here as to why this general link function was overridden, but it looks like it has something to do with icons. This function should be adapted so that it only affects the places where it needs to do it's icon-thing, and leaves all the other links alone.

Additionally, a function as broad as theme_link should be moved out of the menu.inc file so that people can find it.

jenlampton commented 7 years ago

On closer inspection, I think this is just some weirdness with how core handles theme_link vs #link. Not Radix's problem.