function theme_menu_local_task

Returns HTML for a single local task link.

Parameters

$variables: An associative array containing:

  • element: A render element containing:

    • #link: A menu link array with 'title', 'href', and 'localized_options' keys.
    • #active: A boolean indicating whether the local task is active.

Related topics

4 theme calls to theme_menu_local_task()
hook_menu_local_tasks in drupal/core/modules/system/system.api.php
Alter tabs and actions displayed on the page before they are rendered.
menu_local_tasks in drupal/core/includes/menu.inc
Collects the local tasks (tabs), action links, and the root path.
menu_test_menu_local_tasks in drupal/core/modules/system/tests/modules/menu_test/menu_test.module
Implements hook_menu_local_tasks().
ViewFormControllerBase::getDisplayTabs in drupal/core/modules/views_ui/lib/Drupal/views_ui/ViewFormControllerBase.php
Adds tabs for navigating across Displays when editing a View.

File

drupal/core/includes/menu.inc, line 1656
API for the Drupal menu system.

Code

function theme_menu_local_task($variables) {
  $link = $variables['element']['#link'];
  $link += array(
    'localized_options' => array(),
  );
  $link_text = $link['title'];
  if (!empty($variables['element']['#active'])) {

    // Add text to indicate active tab for non-visual users.
    $active = '<span class="element-invisible">' . t('(active tab)') . '</span>';

    // If the link does not contain HTML already, check_plain() it now.
    // After we set 'html'=TRUE the link will not be sanitized by l().
    if (empty($link['localized_options']['html'])) {
      $link['title'] = check_plain($link['title']);
    }
    $link['localized_options']['html'] = TRUE;
    $link_text = t('!local-task-title!active', array(
      '!local-task-title' => $link['title'],
      '!active' => $active,
    ));
  }
  return '<li' . (!empty($variables['element']['#active']) ? ' class="active"' : '') . '>' . l($link_text, $link['href'], $link['localized_options']) . '</li>';
}