Reply To: URLs are not being displayed properly in custom menu

#20345
simoami
Participant

I hit the same problem. Upon debugging, the culprit is in core/functions/navigation.php (line 29)


function enlightenment_nav_menu_container_extra_atts( $nav_menu, $args ) {
        $atts = apply_filters( 'enlightenment_nav_menu_container_extra_atts', ' role="navigation"' );

        $nav_menu = str_replace(
                $args->container_class . '"',
                $args->container_class . '"' . enlightenment_extra_atts( $atts ),
                $nav_menu
        );
        return $nav_menu;
}

The condition occurs when $args->container_class is blank. so the replace logic becomes unprecise as it replaces the first double-quote (“) character it encounters as opposed to the last closing double quote.

For example, given:


<div class="menu">

when $args->container_class is blank, the search phrase is ” and the replacement is ” role=”navigation”

after the replace operation, the string becomes:


<div class=" role="navigation"menu">

and as you can see all of the tag attributes are swallowed.

My Recommendation:

Since $args->container_class is not a reliable source, it would be more efficient to use regular expressions to replace the class attribute’s closing quote.