diff --git a/menu_attributes.module b/menu_attributes.module
index 894d5f6..6d0451f 100644
--- a/menu_attributes.module
+++ b/menu_attributes.module
@@ -279,3 +279,79 @@ function menu_attributes_form_menu_configure_alter(&$form, $form_state) {
$form['attributes']['#pre_render'][] = 'vertical_tabs_form_pre_render';
}
}
+
+/**
+ * Implements hook_theme_registry_alter().
+ */
+function menu_attributes_theme_registry_alter(&$registry) {
+ $registry['links']['function'] = 'menu_attributes_theme_links';
+}
+
+/**
+ * Return a themed set of links.
+ *
+ * @param $links
+ * A keyed array of links to be themed.
+ * @param $attributes
+ * A keyed array of attributes
+ *
+ * @return
+ * A string containing an unordered list of links.
+ */
+function menu_attributes_theme_links($links, $attributes = array('class' => 'links')) {
+ global $language;
+ $output = '';
+
+ if (count($links) > 0) {
+ $output = '
';
+
+ $num_links = count($links);
+ $i = 1;
+
+ foreach ($links as $key => $link) {
+ $class = $key;
+
+ // Add first, last and active classes to the list of links to help out themers.
+ if ($i == 1) {
+ $class .= ' first';
+ }
+ if ($i == $num_links) {
+ $class .= ' last';
+ }
+ if (isset($link['href']) && ($link['href'] == $_GET['q'] || ($link['href'] == '' && drupal_is_front_page()))
+ && (empty($link['language']) || $link['language']->language == $language->language)) {
+ $class .= ' active';
+ }
+ $output .= '- $class)) .'>';
+
+ if (isset($link['href'])) {
+ // Remove disabled attributes.
+ foreach ($link['attributes'] as $attribute => $value) {
+ if (!variable_get("menu_attributes_{$attribute}_enable", 1)) {
+ unset($link['attributes'][$attribute]);
+ }
+ }
+ // Pass in $link as $options, they share the same keys.
+ $output .= l($link['title'], $link['href'], $link);
+ }
+ else if (!empty($link['title'])) {
+ // Some links are actually not links, but we wrap these in for adding title and class attributes
+ if (empty($link['html'])) {
+ $link['title'] = check_plain($link['title']);
+ }
+ $span_attributes = '';
+ if (isset($link['attributes'])) {
+ $span_attributes = drupal_attributes($link['attributes']);
+ }
+ $output .= ''. $link['title'] .'';
+ }
+
+ $i++;
+ $output .= "
\n";
+ }
+
+ $output .= '
';
+ }
+
+ return $output;
+}