Roots Discourse

Correct namespace to customize Nav menu

hello,

which is supposed to be the correct namespace to customize the hook and the related nav menu?

use WP_Customize_Nav_Menus; //<--- no clues where to look for :D

add_filter( 'wp_nav_menu_items', __NAMESPACE__ .'add_extra_item_to_nav_menu', 10, 2 );
function add_extra_item_to_nav_menu( $items, $args ) {
    if (is_user_logged_in() && $args->menu == 303) {
        $items .= '<li><a href="'. get_permalink( get_option('woocommerce_myaccount_page_id') ) .'">My Account</a></li>';
    }
    elseif (!is_user_logged_in() && $args->menu == 303) {
        $items .= '<li><a href="' . get_permalink( wc_get_page_id( 'myaccount' ) ) . '">Sign in  /  Register</a></li>';
    }
    return $items;
}

tyvm!

It should be

add_filter( 'wp_nav_menu_items', __NAMESPACE__ . '\\add_extra_item_to_nav_menu', 10, 2 );

ty :slight_smile:
it works! :slight_smile:

just a question: yes there a list of accessible NAMESPACES?
how can someone guess the correct set to be used=