Commit 2af0413a authored by shadcn's avatar shadcn
Browse files

Issue #2540466: Not supporting special menu items or nolink menu items

parent f9b1dfaa
Loading
Loading
Loading
Loading
+27 −2
Changes for admin_menu_source.module: 27 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -73,10 +73,35 @@ function admin_menu_source_admin_menu_output_alter(&$content) {
    }

    if (!empty($source_menu)) {
      $content['menu'] = admin_menu_links_menu(admin_menu_tree($source_menu));
      // Get the menu tree.
      $tree = admin_menu_tree($source_menu);

      // Fix for special_menu_items so multiple <nolink> are supported.
      // Replace <nolink> with <nolink-*>.
      $count = 0;
      foreach ($tree as &$data) {
        if ($data['link']['href'] == '<nolink>') {
          $data['link']['href'] = '<nolink-' . $count . '>';
          $count++;
        }
      }

      // Build the menu as renderable menu links.
      $menu = admin_menu_links_menu($tree);

      // Replace <nolink-*> back with <nolink>.
      foreach ($menu as &$data) {
        preg_match("/^<nolink.*>/", $data['#href'], $matches);
        if (count($matches)) {
          $data['#href'] = '<nolink>';
        }
      }

      // Replace with new $menu.
      $content['menu'] = $menu;
      $content['menu']['#theme'] = 'admin_menu_links';
      $content['menu']['#weight'] = 0;
      $content['menu']['#sorted'] = TRUE;
      $content['menu']['#wrapper_attributes']['id'] = 'admin-menu-menu';
    }
  }
}