diff --git a/core/includes/menu.inc b/core/includes/menu.inc
index b9c967f..7f2a5ae 100644
--- a/core/includes/menu.inc
+++ b/core/includes/menu.inc
@@ -1555,112 +1555,53 @@ function _menu_tree_data(&$links, $parents, $depth) {
}
/**
- * Implements template_preprocess_HOOK() for theme_menu_tree().
- */
-function template_preprocess_menu_tree(&$variables) {
- $variables['tree'] = $variables['tree']['#children'];
-}
-
-/**
- * Returns HTML for a wrapper for a menu sub-tree.
+ * Prepares variables for menu tree templates.
*
- * @param $variables
- * An associative array containing:
- * - tree: An HTML string containing the tree's items.
+ * Default template: menu-tree.html.twig.
*
- * @see template_preprocess_menu_tree()
- * @ingroup themeable
- */
-function theme_menu_tree($variables) {
- return '
';
-}
-
-/**
- * Returns HTML for a menu link and submenu.
- *
- * @param $variables
+ * @param array $variables
* An associative array containing:
- * - element: Structured array data for a menu link.
- *
- * @ingroup themeable
+ * - tree: A render array for a menu tree.
*/
-function theme_menu_link(array $variables) {
- $element = $variables['element'];
- $sub_menu = '';
-
- if ($element['#below']) {
- $sub_menu = drupal_render($element['#below']);
- }
- $output = l($element['#title'], $element['#href'], $element['#localized_options']);
- return '' . $output . $sub_menu . "\n";
+function template_preprocess_menu_tree(&$variables) {
+ $variables['tree'] = $variables['tree']['#children'];
}
/**
- * Preprocess variables for a menu link and submenu.
+ * Prepares variables for menu link plus submenu templates.
*
- * @param $variables
+ * Default template: menu-link.html.twig.
+ *
+ * @param array $variables
* An associative array containing:
* - element: Structured array data for a menu link.
- *
- * @ingroup themeable
*/
function template_preprocess_menu_link(&$variables) {
$element = $variables['element'];
- $variables['sub_menu'] = ($element['#below']) ? drupal_render($element['#below']) : '';
+ // @todo Remove below drupal_render()?
+ $variables['sub_menu'] = ($element['#below']) ? drupal_render($element['#below']) : array();
$variables['link'] = l($element['#title'], $element['#href'], $element['#localized_options']);
$variables['wrapper_attributes'] = new Attribute($element['#attributes']);
}
/**
- * Returns HTML for a single local task link.
+ * Prepares variables for single local task link templates.
*
- * @param $variables
+ * Default template: menu-local-task.html.twig.
+ *
+ * @param $array 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 theme_menu_local_task($variables) {
+function template_preprocess_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 = '' . 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));
- }
-
- return '' . l($link_text, $link['href'], $link['localized_options']) . '';
-}
-
-/**
- * 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'];
$variables['wrapper_attributes'] = new Attribute();
$variables['active'] = FALSE;
@@ -1680,40 +1621,21 @@ function template_preprocess_menu_local_task(&$variables) {
}
/**
- * Returns HTML for a single local action link.
+ * Prepares variables for single local action link templates.
*
- * @param $variables
+ * Default template: menu-local-action.html.twig.
+ *
+ * @param array $variables
* An associative array containing:
* - element: A render element containing:
* - #link: A menu link array with 'title', 'href', and 'localized_options'
* keys.
- *
- * @ingroup themeable
- */
-function theme_menu_local_action($variables) {
- $link = $variables['element']['#link'];
- $link += array(
- 'href' => '',
- 'localized_options' => array(),
- );
- $link['localized_options']['attributes']['class'][] = 'button';
- $link['localized_options']['attributes']['class'][] = 'button-action';
-
- $output = '';
- $output .= l($link['title'], $link['href'], $link['localized_options']);
- $output .= "";
-
- return $output;
-}
-
-/**
- * Preprocess variables for a single local action link template.
*/
function template_preprocess_menu_local_action(&$variables) {
$link = $variables['element']['#link'];
$link += array(
'href' => '',
- 'localized_options' => array(),
+ 'localized_options' => new Attribute(),
);
$link['localized_options']['attributes']['class'][] = 'button';
$link['localized_options']['attributes']['class'][] = 'button-action';
diff --git a/core/includes/theme.inc b/core/includes/theme.inc
index 4c0e580..c7a805b 100644
--- a/core/includes/theme.inc
+++ b/core/includes/theme.inc
@@ -3255,18 +3255,23 @@ function drupal_common_theme() {
// From menu.inc.
'menu_link' => array(
'render element' => 'element',
+ 'template' => 'menu-link',
),
'menu_tree' => array(
'render element' => 'tree',
+ 'template' => 'menu-tree',
),
'menu_local_task' => array(
'render element' => 'element',
+ 'template' => 'menu-local-task',
),
'menu_local_action' => array(
'render element' => 'element',
+ 'template' => 'menu-local-action',
),
'menu_local_tasks' => array(
'variables' => array('primary' => array(), 'secondary' => array()),
+ 'template' => 'menu-local-tasks',
),
// From form.inc.
'input' => array(
diff --git a/core/themes/stark/templates/menu.inc/menu-link.html.twig b/core/modules/system/templates/menu-link.html.twig
similarity index 88%
rename from core/themes/stark/templates/menu.inc/menu-link.html.twig
rename to core/modules/system/templates/menu-link.html.twig
index 4a4dde6..9d3146a 100644
--- a/core/themes/stark/templates/menu.inc/menu-link.html.twig
+++ b/core/modules/system/templates/menu-link.html.twig
@@ -11,8 +11,8 @@
* Note: This template renders the content for each individual menu item in
* menu-local-tasks.html.twig.
*
- * @see template_preprocess
- * @see template_preprocess_menu_link
+ * @see template_preprocess()
+ * @see template_preprocess_menu_link()
*
* @ingroup themeable
*/
diff --git a/core/themes/stark/templates/menu.inc/menu-local-action.html.twig b/core/modules/system/templates/menu-local-action.html.twig
similarity index 71%
rename from core/themes/stark/templates/menu.inc/menu-local-action.html.twig
rename to core/modules/system/templates/menu-local-action.html.twig
index 45b9358..08bd68b 100644
--- a/core/themes/stark/templates/menu.inc/menu-local-action.html.twig
+++ b/core/modules/system/templates/menu-local-action.html.twig
@@ -6,8 +6,8 @@
* Available variables:
* - link: A rendered link element.
*
- * @see template_preprocess
- * @see template_preprocess_menu_local_action
+ * @see template_preprocess()
+ * @see template_preprocess_menu_local_action()
*
* @ingroup themeable
*/
diff --git a/core/themes/stark/templates/menu.inc/menu-local-task.html.twig b/core/modules/system/templates/menu-local-task.html.twig
similarity index 76%
rename from core/themes/stark/templates/menu.inc/menu-local-task.html.twig
rename to core/modules/system/templates/menu-local-task.html.twig
index 029fead..2d1c516 100644
--- a/core/themes/stark/templates/menu.inc/menu-local-task.html.twig
+++ b/core/modules/system/templates/menu-local-task.html.twig
@@ -4,14 +4,14 @@
* Default theme implementation for a local task link.
*
* Available variables:
- * - wrapper_attributes: An array of HTML attributes for the wrapper element.
+ * - wrapper_attributes: HTML attributes for the wrapper element.
* - link: The rendered link ( tag).
*
* Note: This template renders the content for each individual task item in
* menu-local-tasks.html.twig.
*
- * @see template_preprocess
- * @see template_preprocess_menu_local_task
+ * @see template_preprocess()
+ * @see template_preprocess_menu_local_task()
*
* @ingroup themeable
*/
@@ -24,4 +24,4 @@
({{ 'active tab'|t }})
{% endif %}
-{% endspaceless %}
\ No newline at end of file
+{% endspaceless %}
diff --git a/core/themes/stark/templates/menu.inc/menu-local-tasks.html.twig b/core/modules/system/templates/menu-local-tasks.html.twig
similarity index 86%
rename from core/themes/stark/templates/menu.inc/menu-local-tasks.html.twig
rename to core/modules/system/templates/menu-local-tasks.html.twig
index a90921d..2ca090d 100755
--- a/core/themes/stark/templates/menu.inc/menu-local-tasks.html.twig
+++ b/core/modules/system/templates/menu-local-tasks.html.twig
@@ -10,11 +10,11 @@
* Note: Each item for both sets of tasks can be individually themed in
* menu-local-task.html.twig.
*
- * @see template_preprocess
- * @see template_preprocess_menu_local_tasks
+ * @see template_preprocess()
+ * @see template_preprocess_menu_local_tasks()
*
-* @ingroup themeable
-*/
+ * @ingroup themeable
+ */
#}
{% if primary_tasks %}
{{ 'Primary tabs'|t }}
diff --git a/core/themes/stark/templates/menu.inc/menu-tree.html.twig b/core/modules/system/templates/menu-tree.html.twig
similarity index 82%
rename from core/themes/stark/templates/menu.inc/menu-tree.html.twig
rename to core/modules/system/templates/menu-tree.html.twig
index 7134dec..0dc857e 100644
--- a/core/themes/stark/templates/menu.inc/menu-tree.html.twig
+++ b/core/modules/system/templates/menu-tree.html.twig
@@ -9,8 +9,8 @@
* Note: Each item in the menu tree can be individually themed in
* menu-link.html.twig.
*
- * @see template_preprocess
- * @see template_preprocess_menu_tree
+ * @see template_preprocess()
+ * @see template_preprocess_menu_tree()
*
* @ingroup themeable
*/