diff --git a/wp-admin/menu.php b/wp-admin/menu.php index 1d09dd85c7..65bdf8e6c9 100644 --- a/wp-admin/menu.php +++ b/wp-admin/menu.php @@ -246,11 +246,13 @@ do_action('admin_menu', ''); // Remove menus that have no accessible submenus and require privs that the user does not have. // Run re-parent loop again. foreach ( $menu as $id => $data ) { + if ( ! current_user_can($data[1]) ) + $_wp_menu_nopriv[$data[2]] = true; + // If submenu is empty... if ( empty($submenu[$data[2]]) ) { // And user doesn't have privs, remove menu. - if ( ! current_user_can($data[1]) ) { - $_wp_menu_nopriv[$data[2]] = true; + if ( isset( $_wp_menu_nopriv[$data[2]] ) ) { unset($menu[$id]); } }