Changeset 3536 for trunk/wp-admin/menu.php
- Timestamp:
- 02/17/2006 12:57:10 AM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/menu.php
r3185 r3536 50 50 $submenu['themes.php'][10] = array(__('Theme Editor'), 'edit_themes', 'theme-editor.php'); 51 51 52 // Loop over submenus and remove pages for which the user does not have privs. 53 foreach ($submenu as $parent => $sub) { 54 foreach ($sub as $index => $data) { 55 if ( ! current_user_can($data[1]) ) { 56 $menu_nopriv[$data[2]] = true; 57 unset($submenu[$parent][$index]); 58 } 59 } 60 61 if ( empty($submenu[$parent]) ) 62 unset($submenu[$parent]); 63 } 64 65 // Loop over the top-level menu. 66 // Remove menus that have no accessible submenus and require privs that the user does not have. 67 // Menus for which the original parent is not acessible due to lack of privs will have the next 68 // submenu in line be assigned as the new menu parent. 69 foreach ( $menu as $id => $data ) { 70 // If submenu is empty... 71 if ( empty($submenu[$data[2]]) ) { 72 // And user doesn't have privs, remove menu. 73 if ( ! current_user_can($data[1]) ) { 74 $menu_nopriv[$data[2]] = true; 75 unset($menu[$id]); 76 } 77 } else { 78 $subs = $submenu[$data[2]]; 79 $first_sub = array_shift($subs); 80 $old_parent = $data[2]; 81 $new_parent = $first_sub[2]; 82 // If the first submenu is not the same as the assigned parent, 83 // make the first submenu the new parent. 84 if ( $new_parent != $old_parent ) { 85 $real_parent_file[$old_parent] = $new_parent; 86 $menu[$id][2] = $new_parent; 87 88 foreach ($submenu[$old_parent] as $index => $data) { 89 $submenu[$new_parent][$index] = $submenu[$old_parent][$index]; 90 unset($submenu[$old_parent][$index]); 91 } 92 unset($submenu[$old_parent]); 93 } 94 } 95 } 96 52 97 // Create list of page plugin hook names. 53 98 foreach ($menu as $menu_page) {
Note: See TracChangeset
for help on using the changeset viewer.