You are here

function menu_badges_menu_local_tasks_alter in Menu Badges 7

Implements hook_menu_local_tasks_alter().

File

./menu_badges.module, line 73
Menu Badges module file.

Code

function menu_badges_menu_local_tasks_alter(&$data, $router_item, $root_path) {
  $tab_badges = variable_get('menu_badges_tab_callbacks', array());
  if (empty($tab_badges)) {
    return;
  }
  if (!empty($data['tabs'][0]['output'])) {
    foreach (array_keys($data['tabs'][0]['output']) as $i => $tab) {
      if (!empty($tab_badges[$data['tabs'][0]['output'][$i]['#link']['path']])) {
        $data['tabs'][0]['output'][$i]['#link']['localized_options']['link_badge'] = array(
          'callback' => $tab_badges[$data['tabs'][0]['output'][$i]['#link']['path']]['callback'],
        );
        if (!empty($tab_badges[$data['tabs'][0]['output'][$i]['#link']['path']]['arguments'])) {
          $data['tabs'][0]['output'][$i]['#link']['localized_options']['link_badge']['arguments'] = $tab_badges[$data['tabs'][0]['output'][$i]['#link']['path']]['arguments'];
        }
      }
    }
  }
  if (!empty($data['tabs'][1]['output'])) {
    foreach (array_keys($data['tabs'][1]['output']) as $i => $tab) {
      if (!empty($tab_badges[$data['tabs'][1]['output'][$i]['#link']['path']])) {
        $data['tabs'][1]['output'][$i]['#link']['localized_options']['link_badge'] = array(
          'callback' => $tab_badges[$data['tabs'][1]['output'][$i]['#link']['path']]['callback'],
        );
        if (!empty($tab_badges[$data['tabs'][1]['output'][$i]['#link']['path']]['arguments'])) {
          $data['tabs'][1]['output'][$i]['#link']['localized_options']['link_badge']['arguments'] = $tab_badges[$data['tabs'][1]['output'][$i]['#link']['path']]['arguments'];
        }
      }
    }
  }
  if (!empty($data['actions']['output'])) {
    foreach (array_keys($data['actions']['output']) as $i => $tab) {
      if (!empty($tab_badges[$data['actions']['output'][$i]['#link']['path']])) {
        $data['actions']['output'][$i]['#link']['localized_options']['link_badge'] = array(
          'callback' => $tab_badges[$data['actions']['output'][$i]['#link']['path']]['callback'],
        );
        if (!empty($tab_badges[$data['actions']['output'][$i]['#link']['path']]['arguments'])) {
          $data['actions']['output'][$i]['#link']['localized_options']['link_badge']['arguments'] = $tab_badges[$data['actions']['output'][$i]['#link']['path']]['arguments'];
        }
      }
    }
  }
}