Add span, data-attr to menu items including superfish menu

Public

For use effects from Codrops http://tympanus.net/Development/CreativeLinkEffects/

Get raw version
php
  1. function THEME_menu_link(array $vars) {
  2. $element = $vars['element'];
  3. $sub_menu = '';
  4.  
  5. if ($element['#below']) {
  6. $sub_menu = drupal_render($element['#below']);
  7. }
  8. $element['#localized_options']['html'] = TRUE;
  9. $element['link_options']['attributes']['data-hover'] = $element['#title']; // add data-hover to link
  10. $linktext = '<span>' . $element['#title'] . '</span>'; // or manually add data-hover attribute to span
  11. $output = l($linktext, $element['#href'], $element['#localized_options']);
  12. return '<li' . drupal_attributes($element['#attributes']) . '>' . $output . $sub_menu . "</li>\n";
  13. }
  14.  
  15. function THEME_superfish_menu_item_link(array $vars) {
  16. $element = $vars['menu_item'];
  17. $vars['link_options']['html'] = TRUE;
  18. $vars['link_options']['attributes']['data-hover'] = $element['link']['title']; // add data-hover to link
  19. $linktext = '<span>' . $element['link']['title'] . '</span>'; // or manually add data-hover attribute to span
  20. return l($linktext, $element['link']['link_path'], $vars['link_options']);
  21. }