You are here

function metatags_quick_menu_local_tasks_alter in Meta tags quick 7.2

Same name and namespace in other branches
  1. 8.3 metatags_quick.module \metatags_quick_menu_local_tasks_alter()

Implements hook_menu_local_tasks_alter().

File

./metatags_quick.module, line 244
Quick and dirty implementation of meta tags for drupal 7 Module defines new field type 'meta'. Fields of this type are not displayed in HTML. Instead, they add html meta to the head section.

Code

function metatags_quick_menu_local_tasks_alter(&$data, $router_item, $root_path) {

  // Don't add meta tags editing tab to admin pages.
  if (path_is_admin($_GET['q'])) {
    return;
  }

  // Don't add meta tags editing tab if path based meta tags are disabled.
  if (!variable_get('metatags_quick_use_path_based', 1)) {
    return;
  }

  // Don't add meta tags editing tab.
  if (variable_get('metatags_quick_remove_tab', 0)) {
    return;
  }
  if (!_metatags_quick_path_based_page()) {
    return;
  }
  global $language;
  $active_item = menu_get_item();
  $edit_url = 'admin/config/search/metatags_quick/path_based/edit';
  $item = menu_get_item($edit_url);
  if ($item['access']) {
    $item['#href'] = $edit_url;
    $item['localized_options']['query'] = array(
      'path' => $_GET['q'],
      'lang' => $language->language,
      'destination' => $_GET['q'],
    );
    $data['tabs'][0]['output'][] = array(
      '#theme' => 'menu_local_task',
      '#link' => $item,
    );
    if (isset($data['tabs'][0]['count'])) {
      ++$data['tabs'][0]['count'];
    }
    else {
      $data['actions'] = array(
        'count' => 0,
        'output' => array(),
      );

      // Drupal does not display single tab. WTF?
      $data['tabs'][0]['count'] = 2;
    }
  }
}