| [ Index ] |
WordPress Source Cross Reference |
[Summary view] [Print] [Text view]
1 <?php 2 // This array constructs the admin menu bar. 3 // 4 // Menu item name 5 // The minimum level the user needs to access the item: between 0 and 10 6 // The URL of the item's file 7 $menu[0] = array(__('Dashboard'), 'read', 'index.php'); 8 9 if ( strstr($_SERVER['REQUEST_URI'], 'edit-pages.php') ) 10 $menu[5] = array(__('Write'), 'edit_pages', 'page-new.php'); 11 else 12 $menu[5] = array(__('Write'), 'edit_posts', 'post-new.php'); 13 if ( strstr($_SERVER['REQUEST_URI'], 'page-new.php') ) 14 $menu[10] = array(__('Manage'), 'edit_pages', 'edit-pages.php'); 15 else 16 $menu[10] = array(__('Manage'), 'edit_posts', 'edit.php'); 17 18 $menu[20] = array(__('Blogroll'), 'manage_links', 'link-manager.php'); 19 $menu[25] = array(__('Presentation'), 'switch_themes', 'themes.php'); 20 $menu[30] = array(__('Plugins'), 'activate_plugins', 'plugins.php'); 21 if ( current_user_can('edit_users') ) 22 $menu[35] = array(__('Users'), 'edit_users', 'users.php'); 23 else 24 $menu[35] = array(__('Profile'), 'read', 'profile.php'); 25 $menu[40] = array(__('Options'), 'manage_options', 'options-general.php'); 26 27 28 $submenu['post-new.php'][5] = array(__('Write Post'), 'edit_posts', 'post-new.php'); 29 $submenu['post-new.php'][10] = array(__('Write Page'), 'edit_pages', 'page-new.php'); 30 31 $submenu['edit.php'][5] = array(__('Posts'), 'edit_posts', 'edit.php'); 32 $submenu['edit.php'][10] = array(__('Pages'), 'edit_pages', 'edit-pages.php'); 33 $submenu['edit.php'][15] = array(__('Categories'), 'manage_categories', 'categories.php'); 34 $submenu['edit.php'][20] = array(__('Comments'), 'edit_posts', 'edit-comments.php'); 35 $awaiting_mod = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = '0'"); 36 $submenu['edit.php'][25] = array(sprintf(__("Awaiting Moderation (%s)"), "<span id='awaitmod'>$awaiting_mod</span>"), 'edit_posts', 'moderation.php'); 37 $submenu['edit.php'][30] = array(__('Files'), 'edit_files', 'templates.php'); 38 $submenu['edit.php'][35] = array(__('Import'), 'import', 'import.php'); 39 $submenu['edit.php'][40] = array(__('Export'), 'import', 'export.php'); 40 41 $submenu['link-manager.php'][5] = array(__('Manage Blogroll'), 'manage_links', 'link-manager.php'); 42 $submenu['link-manager.php'][10] = array(__('Add Link'), 'manage_links', 'link-add.php'); 43 $submenu['link-manager.php'][20] = array(__('Import Links'), 'manage_links', 'link-import.php'); 44 45 if ( current_user_can('edit_users') ) { 46 $submenu['users.php'][5] = array(__('Authors & Users'), 'edit_users', 'users.php'); 47 $submenu['users.php'][10] = array(__('Your Profile'), 'read', 'profile.php'); 48 } else { 49 $submenu['profile.php'][5] = array(__('Your Profile'), 'read', 'profile.php'); 50 } 51 52 $submenu['options-general.php'][10] = array(__('General'), 'manage_options', 'options-general.php'); 53 $submenu['options-general.php'][15] = array(__('Writing'), 'manage_options', 'options-writing.php'); 54 $submenu['options-general.php'][20] = array(__('Reading'), 'manage_options', 'options-reading.php'); 55 $submenu['options-general.php'][25] = array(__('Discussion'), 'manage_options', 'options-discussion.php'); 56 $submenu['options-general.php'][30] = array(__('Privacy'), 'manage_options', 'options-privacy.php'); 57 $submenu['options-general.php'][35] = array(__('Permalinks'), 'manage_options', 'options-permalink.php'); 58 $submenu['options-general.php'][40] = array(__('Miscellaneous'), 'manage_options', 'options-misc.php'); 59 60 $submenu['plugins.php'][5] = array(__('Plugins'), 'activate_plugins', 'plugins.php'); 61 $submenu['plugins.php'][10] = array(__('Plugin Editor'), 'edit_plugins', 'plugin-editor.php'); 62 63 $submenu['themes.php'][5] = array(__('Themes'), 'switch_themes', 'themes.php'); 64 $submenu['themes.php'][10] = array(__('Theme Editor'), 'edit_themes', 'theme-editor.php'); 65 66 // Create list of page plugin hook names. 67 foreach ($menu as $menu_page) { 68 $admin_page_hooks[$menu_page[2]] = sanitize_title($menu_page[0]); 69 } 70 71 do_action('admin_menu', ''); 72 73 // Loop over submenus and remove pages for which the user does not have privs. 74 foreach ($submenu as $parent => $sub) { 75 foreach ($sub as $index => $data) { 76 if ( ! current_user_can($data[1]) ) { 77 $menu_nopriv[$data[2]] = true; 78 unset($submenu[$parent][$index]); 79 } 80 } 81 82 if ( empty($submenu[$parent]) ) 83 unset($submenu[$parent]); 84 } 85 86 // Loop over the top-level menu. 87 // Remove menus that have no accessible submenus and require privs that the user does not have. 88 // Menus for which the original parent is not acessible due to lack of privs will have the next 89 // submenu in line be assigned as the new menu parent. 90 foreach ( $menu as $id => $data ) { 91 // If submenu is empty... 92 if ( empty($submenu[$data[2]]) ) { 93 // And user doesn't have privs, remove menu. 94 if ( ! current_user_can($data[1]) ) { 95 $menu_nopriv[$data[2]] = true; 96 unset($menu[$id]); 97 } 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 } 116 } 117 118 ksort($menu); // make it all pretty 119 120 if (! user_can_access_admin_page()) { 121 wp_die( __('You do not have sufficient permissions to access this page.') ); 122 } 123 124 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Sat Jul 15 11:57:04 2006 | Courtesy of Taragana |