diff --git a/wp-admin/admin-functions.php b/wp-admin/admin-functions.php
index 50f7a7662b..c67fc65ac2 100644
--- a/wp-admin/admin-functions.php
+++ b/wp-admin/admin-functions.php
@@ -1343,15 +1343,32 @@ function user_can_access_admin_page() {
global $plugin_page;
$parent = get_admin_page_parent();
-
+ /*echo "pa: $parent pn: $pagenow pp: $plugin_page
";
+ echo "
"; + print_r($_wp_menu_nopriv); + print_r($_wp_submenu_nopriv); + echo "";*/ if ( isset($_wp_submenu_nopriv[$parent][$pagenow]) ) return false; if ( isset($plugin_page) && isset($_wp_submenu_nopriv[$parent][$plugin_page]) ) return false; - //if ( empty($parent) ) - //return false; + if ( empty($parent) ) { + if ( isset($_wp_menu_nopriv[$pagenow]) ) + return false; + if ( isset($_wp_submenu_nopriv[$pagenow][$pagenow]) ) + return false; + if ( isset($plugin_page) && isset($_wp_submenu_nopriv[$pagenow][$plugin_page]) ) + return false; + foreach (array_keys($_wp_submenu_nopriv) as $key) { + if ( isset($_wp_submenu_nopriv[$key][$pagenow]) ) + return false; + if ( isset($plugin_page) && isset($_wp_submenu_nopriv[$key][$plugin_page]) ) + return false; + } + return true; + } if (isset ($submenu[$parent])) { foreach ($submenu[$parent] as $submenu_array) { diff --git a/wp-admin/menu.php b/wp-admin/menu.php index aede64bde5..19b64c02b9 100644 --- a/wp-admin/menu.php +++ b/wp-admin/menu.php @@ -69,11 +69,14 @@ foreach ($menu as $menu_page) { $admin_page_hooks[$menu_page[2]] = sanitize_title($menu_page[0]); } +$_wp_submenu_nopriv = array(); +$_wp_menu_nopriv = array(); // Loop over submenus and remove pages for which the user does not have privs. foreach ($submenu as $parent => $sub) { foreach ($sub as $index => $data) { if ( ! current_user_can($data[1]) ) { unset($submenu[$parent][$index]); + $_wp_submenu_nopriv[$parent][$data[2]] = true; } } @@ -118,24 +121,6 @@ foreach ( $menu as $id => $data ) { $_wp_menu_nopriv[$data[2]] = true; unset($menu[$id]); } - } else { - /* $subs = $submenu[$data[2]]; - $first_sub = array_shift($subs); - $old_parent = $data[2]; - $new_parent = $first_sub[2]; - // If the first submenu is not the same as the assigned parent, - // make the first submenu the new parent. - if ( $new_parent != $old_parent ) { - $_wp_real_parent_file[$old_parent] = $new_parent; - $menu[$id][2] = $new_parent; - - foreach ($submenu[$old_parent] as $index => $data) { - $submenu[$new_parent][$index] = $submenu[$old_parent][$index]; - unset($submenu[$old_parent][$index]); - } - unset($submenu[$old_parent]); - $_wp_submenu_nopriv[$new_parent] = $_wp_submenu_nopriv[$old_parent]; - } */ } }