Created
September 9, 2016 01:07
-
-
Save orakili/2eb56343b00f3713891d68df0efa6688 to your computer and use it in GitHub Desktop.
Prevent php warnings when class is not set.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/context.module b/context.module | |
index 5c0bd5c..5db5763 100644 | |
--- a/context.module | |
+++ b/context.module | |
@@ -244,8 +244,10 @@ function context_preprocess_menu_link(&$variables) { | |
// - Do not add class twice on current page. | |
if (in_array($variables['element']['#href'], $reaction_menu_paths) && $variables['element']['#href'] != $_GET['q']) { | |
// Do not add the 'active' class twice in views tabs. | |
- if (!in_array('active', $variables['element']['#localized_options']['attributes']['class'])) { | |
- $variables['element']['#localized_options']['attributes']['class'][] = 'active'; | |
+ if (!empty($variables['element']['#localized_options']['attributes']['class'])) { | |
+ if (!in_array('active', $variables['element']['#localized_options']['attributes']['class'])) { | |
+ $variables['element']['#localized_options']['attributes']['class'][] = 'active'; | |
+ } | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment