function accountmenu_translated_menu_link_alter in Account menu 6
Same name and namespace in other branches
- 7 accountmenu.module \accountmenu_translated_menu_link_alter()
Implements hook_link_alter.
Ensures links that should have destinations do so, and applies our own @name and @realname tokens.
File
- ./
accountmenu.module, line 155 - accountmenu.module Provide a dynamic Log in/My account/Log out account menu
Code
function accountmenu_translated_menu_link_alter(&$item) {
if ($item['module'] != 'accountmenu') {
return;
}
if (_accountmenu_menu_need_destination($item['link_path'])) {
if (_accountmenu_is_404() || arg(0) === 'user') {
// on a 404 page or any 'user' paths, send user to the front
$item['localized_options']['query'] = 'destination=<front>';
}
else {
$item['localized_options']['query'] = drupal_get_destination();
}
// potx will complain here, but line 496 of menu.inc is doing the same so
$item['title'] = t($item['link_title']);
}
elseif ($item['link_path'] == 'user/%') {
$token_list = _accountmenu_get_name_and_realname();
// no check_plain() here because menu display will do it
$item['options']['accountmenu_link_title'] = $item['link_title'];
// Substitute the @name and @realname (internal) tokens.
$item['title'] = $item['link_title'] = t($item['link_title'], $token_list);
}
}