summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorps2015-03-10 00:30:31 (GMT)
committerJohnAlbin2015-03-10 00:41:08 (GMT)
commita272af7acc640bf270c65dc28e61bb4976c76ea0 (patch)
tree4173f79a91ba00ad5b25877372f8629dce530a49
parent8ffd0ac18b51b7a01f2c6019882adb1cb044b340 (diff)
Issue #2128643 by jweowu: Infinite loop in zen_preprocess_menu_link()
-rw-r--r--template.php26
1 files changed, 17 insertions, 9 deletions
diff --git a/template.php b/template.php
index e63e9a4..70cb338 100644
--- a/template.php
+++ b/template.php
@@ -621,7 +621,12 @@ function zen_menu_local_task($variables) {
* Implements hook_preprocess_menu_link().
*/
function zen_preprocess_menu_link(&$variables, $hook) {
- foreach ($variables['element']['#attributes']['class'] as $key => $class) {
+ $menu_item_classes =& $variables['element']['#attributes']['class'];
+ $menu_link_classes =& $variables['element']['#localized_options']['attributes']['class'];
+
+ // Add BEM-style classes to the menu item classes.
+ $extra_classes = array('menu__item');
+ foreach ($menu_item_classes as $key => $class) {
switch ($class) {
// Menu module classes.
case 'expanded':
@@ -630,28 +635,31 @@ function zen_preprocess_menu_link(&$variables, $hook) {
case 'active':
// Menu block module classes.
case 'active-trail':
- array_unshift($variables['element']['#attributes']['class'], 'is-' . $class);
+ $extra_classes[] = 'is-' . $class;
break;
case 'has-children':
- array_unshift($variables['element']['#attributes']['class'], 'is-parent');
+ $extra_classes[] = 'is-parent';
break;
}
}
- array_unshift($variables['element']['#attributes']['class'], 'menu__item');
- if (empty($variables['element']['#localized_options']['attributes']['class'])) {
- $variables['element']['#localized_options']['attributes']['class'] = array();
+ $menu_item_classes = array_merge($extra_classes, $menu_item_classes);
+
+ // Add BEM-style classes to the menu link classes.
+ $extra_classes = array('menu__link');
+ if (empty($menu_link_classes)) {
+ $menu_link_classes = array();
}
else {
- foreach ($variables['element']['#localized_options']['attributes']['class'] as $key => $class) {
+ foreach ($menu_link_classes as $key => $class) {
switch ($class) {
case 'active':
case 'active-trail':
- array_unshift($variables['element']['#localized_options']['attributes']['class'], 'is-' . $class);
+ $extra_classes[] = 'is-' . $class;
break;
}
}
}
- array_unshift($variables['element']['#localized_options']['attributes']['class'], 'menu__link');
+ $menu_link_classes = array_merge($extra_classes, $menu_link_classes);
}
/**