? me.menu_item_link.big.patch
? me.menu_item_link.small.patch
Index: me.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/me/me.module,v
retrieving revision 1.11
diff -u -r1.11 me.module
--- me.module	22 Feb 2009 21:15:19 -0000	1.11
+++ me.module	22 Nov 2010 22:19:48 -0000
@@ -31,10 +31,14 @@
 
 /**
  * Implementation of hook_theme_registry_alter().
+ *
+ * There is a different registry version for each theme,
+ * and this function will be called for each of them.
  */
 function me_theme_registry_alter(&$theme_registry) {
   if (isset($theme_registry['menu_item_link']['function'])) {
-    variable_set('me_theme_menu_item_link_func', $theme_registry['menu_item_link']['function']);
+    // remember the original function
+    $theme_registry['menu_item_link']['me_original_function'] = $theme_registry['menu_item_link']['function'];
     $theme_registry['menu_item_link']['function'] = 'me_theme_menu_item_link';
   }
 }
@@ -50,9 +54,26 @@
  * Implementation of theme_menu_item_link().
  */
 function me_theme_menu_item_link($link) {
-  _me_check_path($link);
-  $function = me_variable_get('me_theme_menu_item_link_func');
-  return $function($link);
+  static $_functions = array();
+
+  $theme = $GLOBALS['theme'];
+
+  if (!isset($_functions[$theme])) {
+    $registry = theme_get_registry();
+    if (function_exists($candidate = $registry['menu_item_link']['me_original_function'])) {
+      $_functions[$theme] = $candidate;
+    }
+  }
+
+  if (isset($_functions[$theme]) && $_functions[$theme] !== __FUNCTION__) {
+    _me_check_path($link);
+    $function = $_functions[$theme];
+    return $function($link);
+  }
+  else {
+    // This should never happen.
+    return __FUNCTION__;
+  }
 }
 
 /**
