current menu item
-
Hi! I have an issue related to your frontend-nav-menu.php file:
\wp-content\plugins\polylang\frontend\frontend-nav-menu.phpFrom line 141. you have a code to remove the ‘current-menu-item’ classes:
$item->classes = array_diff( $item->classes, array( 'current-menu-item' ) ); $r_ids = array_merge( $r_ids, $this->get_ancestors( $item ) ); // Remove the classes for these ancestorsNow my problem is, that I have a plugin, that identifies current menu items not by their current-menu-item class, but by wether the ‘current’ attribute is true or false:
if ($item->current) { /* $item is active */ }So what I would like to ask is, that could you also set this current attribute to false in your code, where you are removing the classes:
$item->classes = array_diff( $item->classes, array( 'current-menu-item' ) ); $item->current = false; /*new line*/ $r_ids = array_merge( $r_ids, $this->get_ancestors( $item ) ); // Remove the classes for these ancestorsbecause I’m not sure, if checking an element wether or not it has the ‘current-menu-item’ class would be enough to identify which menu item is active, because theme developers might change this class name, but the current attribute should be correct.
The topic ‘current menu item’ is closed to new replies.