Changeset 3536
- Timestamp:
- 02/17/2006 12:57:10 AM (19 years ago)
- Location:
- trunk/wp-admin
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/admin-functions.php
r3520 r3536 1232 1232 global $menu; 1233 1233 global $submenu; 1234 global $menu_nopriv; 1234 1235 1235 1236 $parent = get_admin_page_parent(); 1237 1238 if ( isset($menu_nopriv[$pagenow]) ) 1239 return false; 1240 1241 if ( empty($parent) ) 1242 return true; 1243 1244 if (isset ($submenu[$parent])) { 1245 foreach ($submenu[$parent] as $submenu_array) { 1246 if ($submenu_array[2] == $pagenow) { 1247 if (current_user_can($submenu_array[1])) 1248 return true; 1249 else 1250 return false; 1251 } 1252 } 1253 } 1236 1254 1237 1255 foreach ($menu as $menu_array) { 1238 1256 //echo "parent array: " . $menu_array[2]; 1239 1257 if ($menu_array[2] == $parent) { 1240 if (!current_user_can($menu_array[1])) { 1258 if (current_user_can($menu_array[1])) 1259 return true; 1260 else 1241 1261 return false; 1242 } else { 1243 break; 1244 } 1245 } 1246 } 1247 1248 if (isset ($submenu[$parent])) { 1249 foreach ($submenu[$parent] as $submenu_array) { 1250 if ($submenu_array[2] == $pagenow) { 1251 if (!current_user_can($submenu_array[1])) { 1252 return false; 1253 } else { 1254 return true; 1255 } 1256 } 1257 } 1258 } 1259 1262 } 1263 } 1264 1260 1265 return true; 1261 1266 } … … 1314 1319 global $pagenow; 1315 1320 global $plugin_page; 1316 1317 if (isset ($parent_file) && !empty ($parent_file)) { 1321 global $real_parent_file; 1322 1323 if ( !empty ($parent_file) ) { 1324 if ( isset($real_parent_file[$parent_file]) ) 1325 $parent_file = $real_parent_file[$parent_file]; 1326 1318 1327 return $parent_file; 1319 1328 } … … 1323 1332 if ($parent_menu[2] == $plugin_page) { 1324 1333 $parent_file = $plugin_page; 1325 return $plugin_page; 1334 if ( isset($real_parent_file[$parent_file]) ) 1335 $parent_file = $real_parent_file[$parent_file]; 1336 1337 return $parent_file; 1326 1338 } 1327 1339 } … … 1330 1342 foreach (array_keys($submenu) as $parent) { 1331 1343 foreach ($submenu[$parent] as $submenu_array) { 1344 if ( isset($real_parent_file[$parent]) ) 1345 $parent = $real_parent_file[$parent]; 1332 1346 if ($submenu_array[2] == $pagenow) { 1333 1347 $parent_file = $parent; … … 1364 1378 global $submenu; 1365 1379 global $menu; 1380 global $real_parent_file; 1366 1381 1367 1382 $parent = plugin_basename($parent); 1383 if ( isset($real_parent_file[$parent]) ) 1384 $parent = $real_parent_file[$parent]; 1385 1368 1386 $file = plugin_basename($file); 1369 1387 -
trunk/wp-admin/menu-header.php
r3517 r3536 12 12 if (( strcmp($self, $item[2]) == 0 && empty($parent_file)) || ($parent_file && ($item[2] == $parent_file))) $class = ' class="current"'; 13 13 14 if ( current_user_can($item[1]) ) {14 if ( !empty($submenu[$item[2]]) || current_user_can($item[1]) ) { 15 15 if ( file_exists(ABSPATH . "wp-content/plugins/{$item[2]}") ) 16 16 echo "\n\t<li><a href='" . get_settings('siteurl') . "/wp-admin/admin.php?page={$item[2]}'$class>{$item[0]}</a></li>"; -
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.