1

In short, is there a filter for the Admin Panels Nav-Menu Dropdown List?

For non-administrators I need to remove access to modifying / selecting a specific menu but still allow access to other menus. I need to filter the listed menus and unset the specific "Main Menu" but am having trouble finding the correct hook.

1

I believe the filter you want is wp_get_nav_menus:

function wp_get_nav_menus( $args = array() ) {
    $defaults = array( 'hide_empty' => false, 'orderby' => 'name' );
    $args = wp_parse_args( $args, $defaults );

     /**
     * Filter the navigation menu objects being returned.
     *
     * @since 3.0.0
     *
     * @see get_terms()
     *
     * @param array $menus An array of menu objects.
     * @param array $args  An array of arguments used to retrieve menu objects.
     */
    return apply_filters( 'wp_get_nav_menus', get_terms( 'nav_menu',  $args), $args );
}

The wp_get_nav_menus() function is used on line 383 of wp-admin-nav-menus.php to set the $nav_menus variable which is used throughout the file in a number of places, so be very careful what you do.

| improve this answer | |
  • Perfect, I was able to use this and there doesn't seem to be any side-effects... yet. – Howdy_McGee May 29 '15 at 0:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.