Skip to content

Instantly share code, notes, and snippets.

@msonnabaum
Created April 16, 2014 19:17
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 msonnabaum/10922562 to your computer and use it in GitHub Desktop.
Save msonnabaum/10922562 to your computer and use it in GitHub Desktop.
<?php
function menu_render_no_access_checks($menu_name) {
$menu = _menu_build_tree($menu_name, array('max_depth' => 1));
// Copy/paste from menu_navigation_links
foreach ($menu['tree'] as $item) {
if (!$item['link']['hidden']) {
$class = '';
$l = $item['link']['localized_options'];
$l['href'] = $item['link']['href'];
$l['title'] = $item['link']['title'];
if ($item['link']['in_active_trail']) {
$class = ' active-trail';
$l['attributes']['class'][] = 'active-trail';
}
// Normally, l() compares the href of every link with $_GET['q'] and sets
// the active class accordingly. But local tasks do not appear in menu
// trees, so if the current path is a local task, and this link is its
// tab root, then we have to set the class manually.
if ($item['link']['href'] == $router_item['tab_root_href'] && $item['link']['href'] != $_GET['q']) {
$l['attributes']['class'][] = 'active';
}
// Keyed with the unique mlid to generate classes in theme_links().
$links['menu-' . $item['link']['mlid'] . $class] = $l;
}
}
return theme('links', array('links' => $links));
}
print menu_render_no_access_checks('user-menu');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment