function metatags_quick_menu_local_tasks_alter in Meta tags quick 8.3
Same name and namespace in other branches
- 7.2 metatags_quick.module \metatags_quick_menu_local_tasks_alter()
Implements hook_menu_local_tasks_alter().
File
- ./
metatags_quick.module, line 188 - Meta tags implemented with FieldAPI/EntityAPI
Code
function metatags_quick_menu_local_tasks_alter(&$data, $router_item, $root_path) {
return;
$language = \Drupal::languageManager()
->getLanguage();
$current_path = current_path();
// Don't add meta tags editing tab to admin pages.
if (path_is_admin($current_path)) {
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;
}
$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' => $current_path,
'lang' => $language->id,
'destination' => $current_path,
);
$data['tabs'][0][$edit_url] = 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;
}*/
}
}