Skip to content

Instantly share code, notes, and snippets.

@dirtystylus
Last active December 25, 2015 14:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dirtystylus/6993164 to your computer and use it in GitHub Desktop.
Save dirtystylus/6993164 to your computer and use it in GitHub Desktop.
Pulls the class elements from child <a> element and puts them on the parent <li> item. Useful if you want classes you added with the menu_attributes module to be used on the parent <li>, since those classes are placed on the <a> element itself.
function THEME_preprocess_menu_link(&$variables) {
$element = &$variables['element'];
if (!empty($element['#original_link']['options']['attributes']['class'])) {
foreach($element['#original_link']['options']['attributes']['class'] as $class) {
$element['#attributes']['class'][] = $class;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment