diff --git a/core/includes/menu.inc b/core/includes/menu.inc index 1103be6..91598b3 100644 --- a/core/includes/menu.inc +++ b/core/includes/menu.inc @@ -1662,6 +1662,40 @@ function theme_menu_local_task($variables) { } /** + * Preprocess variables for a single local task link. + * + * @param $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. + * + * @ingroup themeable + */ +function template_preprocess_menu_local_task(&$variables) { + $link = $variables['element']['#link']; + $link_text = $link['title']; + + $variables['wrapper_attributes'] = new Attribute(); + if (!empty($variables['element']['#active'])) { + $variables['wrapper_attributes']['class'] = array('active'); + // Add text to indicate active tab for non-visual users. + $active = '' . t('(active tab)') . ''; + + // 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)); + } + + $variables['link'] = l($link_text, $link['href'], $link['localized_options']); +} + +/** * Returns HTML for a single local action link. * * @param $variables diff --git a/core/themes/stark/templates/menu/menu-local-task.html.twig b/core/themes/stark/templates/menu/menu-local-task.html.twig new file mode 100644 index 0000000..ccac471 --- /dev/null +++ b/core/themes/stark/templates/menu/menu-local-task.html.twig @@ -0,0 +1,17 @@ +{# +/** + * @file + * Default theme implementation for a local task menu. + * + * - wrapper_attributes: HTML attributes for the wrapper element. + * - link: HTML string representing the rendered link. + * + * @see template_preprocess + * @see template_preprocess_menu_local_task + * + * @ingroup themeable + */ +#} +
  • + {{- link -}} +