Changeset 4093
- Timestamp:
- 08/14/2006 09:24:43 PM (18 years ago)
- Location:
- trunk/wp-admin
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/admin-functions.php
r4082 r4093 1490 1490 global $menu; 1491 1491 global $real_parent_file; 1492 global $menu_nopriv; 1493 1494 $file = plugin_basename($file); 1495 //echo "Adding $parent $file $access_level<br />"; 1496 if ( !current_user_can($access_level) ) { 1497 $menu_nopriv[$file] = true; 1498 return false; 1499 } 1492 1500 1493 1501 $parent = plugin_basename($parent); 1494 1502 if ( isset($real_parent_file[$parent]) ) 1495 1503 $parent = $real_parent_file[$parent]; 1496 1497 $file = plugin_basename($file);1498 1504 1499 1505 // If the parent doesn't already have a submenu, add a link to the parent -
trunk/wp-admin/menu.php
r3999 r4093 44 44 45 45 if ( current_user_can('edit_users') ) { 46 $real_parent_file['profile.php'] = 'users.php'; // Back-compat for plugins adding submenus to profile.php. 46 47 $submenu['users.php'][5] = array(__('Authors & Users'), 'edit_users', 'users.php'); 47 48 $submenu['users.php'][10] = array(__('Your Profile'), 'read', 'profile.php'); … … 69 70 } 70 71 71 do_action('admin_menu', '');72 73 72 // Loop over submenus and remove pages for which the user does not have privs. 74 73 foreach ($submenu as $parent => $sub) { … … 85 84 86 85 // Loop over the top-level menu. 87 // Remove menus that have no accessible submenus and require privs that the user does not have.88 86 // Menus for which the original parent is not acessible due to lack of privs will have the next 89 87 // submenu in line be assigned as the new menu parent. 88 foreach ( $menu as $id => $data ) { 89 if ( empty($submenu[$data[2]]) ) 90 continue; 91 $subs = $submenu[$data[2]]; 92 $first_sub = array_shift($subs); 93 $old_parent = $data[2]; 94 $new_parent = $first_sub[2]; 95 // If the first submenu is not the same as the assigned parent, 96 // make the first submenu the new parent. 97 if ( $new_parent != $old_parent ) { 98 $real_parent_file[$old_parent] = $new_parent; 99 $menu[$id][2] = $new_parent; 100 101 foreach ($submenu[$old_parent] as $index => $data) { 102 $submenu[$new_parent][$index] = $submenu[$old_parent][$index]; 103 unset($submenu[$old_parent][$index]); 104 } 105 unset($submenu[$old_parent]); 106 } 107 } 108 109 do_action('admin_menu', ''); 110 111 // Remove menus that have no accessible submenus and require privs that the user does not have. 90 112 foreach ( $menu as $id => $data ) { 91 113 // If submenu is empty... … … 96 118 unset($menu[$id]); 97 119 } 98 } else { 99 $subs = $submenu[$data[2]]; 100 $first_sub = array_shift($subs); 101 $old_parent = $data[2]; 102 $new_parent = $first_sub[2]; 103 // If the first submenu is not the same as the assigned parent, 104 // make the first submenu the new parent. 105 if ( $new_parent != $old_parent ) { 106 $real_parent_file[$old_parent] = $new_parent; 107 $menu[$id][2] = $new_parent; 108 109 foreach ($submenu[$old_parent] as $index => $data) { 110 $submenu[$new_parent][$index] = $submenu[$old_parent][$index]; 111 unset($submenu[$old_parent][$index]); 112 } 113 unset($submenu[$old_parent]); 114 } 115 } 120 } 116 121 } 117 122
Note: See TracChangeset
for help on using the changeset viewer.