• Resolved mowar

    (@mowar)


    Hi! I have an issue related to your frontend-nav-menu.php file:
    \wp-content\plugins\polylang\frontend\frontend-nav-menu.php

    From 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 ancestors

    Now 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 ancestors

    because 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.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Chouby

    (@chouby)

    Hi,

    Could you open a GitHub issue for me not to forget that? Thanks.

    Thread Starter mowar

    (@mowar)

    Sure, I moved this topic there!

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘current menu item’ is closed to new replies.