More fun with menus.
git-svn-id: https://develop.svn.wordpress.org/trunk@4100 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
01bfb73c52
commit
aeed0eca65
@ -1343,15 +1343,32 @@ function user_can_access_admin_page() {
|
|||||||
global $plugin_page;
|
global $plugin_page;
|
||||||
|
|
||||||
$parent = get_admin_page_parent();
|
$parent = get_admin_page_parent();
|
||||||
|
/*echo "pa: $parent pn: $pagenow pp: $plugin_page<br/>";
|
||||||
|
echo "<pre>";
|
||||||
|
print_r($_wp_menu_nopriv);
|
||||||
|
print_r($_wp_submenu_nopriv);
|
||||||
|
echo "</pre>";*/
|
||||||
if ( isset($_wp_submenu_nopriv[$parent][$pagenow]) )
|
if ( isset($_wp_submenu_nopriv[$parent][$pagenow]) )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if ( isset($plugin_page) && isset($_wp_submenu_nopriv[$parent][$plugin_page]) )
|
if ( isset($plugin_page) && isset($_wp_submenu_nopriv[$parent][$plugin_page]) )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
//if ( empty($parent) )
|
if ( empty($parent) ) {
|
||||||
//return false;
|
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])) {
|
if (isset ($submenu[$parent])) {
|
||||||
foreach ($submenu[$parent] as $submenu_array) {
|
foreach ($submenu[$parent] as $submenu_array) {
|
||||||
|
@ -69,11 +69,14 @@ foreach ($menu as $menu_page) {
|
|||||||
$admin_page_hooks[$menu_page[2]] = sanitize_title($menu_page[0]);
|
$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.
|
// Loop over submenus and remove pages for which the user does not have privs.
|
||||||
foreach ($submenu as $parent => $sub) {
|
foreach ($submenu as $parent => $sub) {
|
||||||
foreach ($sub as $index => $data) {
|
foreach ($sub as $index => $data) {
|
||||||
if ( ! current_user_can($data[1]) ) {
|
if ( ! current_user_can($data[1]) ) {
|
||||||
unset($submenu[$parent][$index]);
|
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;
|
$_wp_menu_nopriv[$data[2]] = true;
|
||||||
unset($menu[$id]);
|
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];
|
|
||||||
} */
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user