-// This array constructs the admin menu bar.
-//
-// Menu item name
-// The minimum level the user needs to access the item: between 0 and 10
-// The URL of the item's file
-$menu[0] = array(__('Dashboard'), 'read', 'index.php');
-
-if (strpos($_SERVER['REQUEST_URI'], 'edit-pages.php') !== false)
- $menu[5] = array(__('Write'), 'edit_pages', 'page-new.php');
-else
- $menu[5] = array(__('Write'), 'edit_posts', 'post-new.php');
-if (strpos($_SERVER['REQUEST_URI'], 'page-new.php') !== false)
- $menu[10] = array(__('Manage'), 'edit_pages', 'edit-pages.php');
-else
- $menu[10] = array(__('Manage'), 'edit_posts', 'edit.php');
-
-$menu[15] = array(__('Comments'), 'edit_posts', 'edit-comments.php');
-$menu[20] = array(__('Blogroll'), 'manage_links', 'link-manager.php');
-$menu[25] = array(__('Presentation'), 'switch_themes', 'themes.php');
-$menu[30] = array(__('Plugins'), 'activate_plugins', 'plugins.php');
-if ( current_user_can('edit_users') )
- $menu[35] = array(__('Users'), 'edit_users', 'users.php');
-else
- $menu[35] = array(__('Profile'), 'read', 'profile.php');
-$menu[40] = array(__('Options'), 'manage_options', 'options-general.php');
+/**
+ * Build Administration Menu.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/**
+ * Constructs the admin menu bar.
+ *
+ * The elements in the array are :
+ * 0: Menu item name
+ * 1: Minimum level or capability required.
+ * 2: The URL of the item's file
+ * 3: Class
+ * 4: ID
+ * 5: Icon for top level menu
+ *
+ * @global array $menu
+ * @name $menu
+ * @var array
+ */
+
+$awaiting_mod = wp_count_comments();
+$awaiting_mod = $awaiting_mod->moderated;
+
+if ( is_multisite() && is_super_admin() ) {
+ /* translators: Network menu item */
+ $menu[0] = array(__('Super Admin'), 'manage_network', 'ms-admin.php', '', 'menu-top menu-top-first menu-icon-site', 'menu-site', 'div');
+ $submenu[ 'ms-admin.php' ][1] = array( __('Admin'), 'manage_network', 'ms-admin.php' );
+ /* translators: Sites menu item */
+ $submenu[ 'ms-admin.php' ][5] = array( __('Sites'), 'manage_sites', 'ms-sites.php' );
+ $submenu[ 'ms-admin.php' ][10] = array( __('Users'), 'manage_network_users', 'ms-users.php' );
+ $submenu[ 'ms-admin.php' ][20] = array( __('Themes'), 'manage_network_themes', 'ms-themes.php' );
+ $submenu[ 'ms-admin.php' ][25] = array( __('Options'), 'manage_network_options', 'ms-options.php' );
+ $submenu[ 'ms-admin.php' ][30] = array( __('Update'), 'manage_network', 'ms-upgrade-network.php' );
+
+ $menu[1] = array( '', 'read', 'separator1', '', 'wp-menu-separator' );
+
+ $menu[2] = array( __('Dashboard'), 'read', 'index.php', '', 'menu-top menu-icon-dashboard', 'menu-dashboard', 'div' );
+} else {
+ $menu[2] = array( __('Dashboard'), 'read', 'index.php', '', 'menu-top menu-top-first menu-icon-dashboard', 'menu-dashboard', 'div' );
+}
+
+if ( is_multisite() || is_super_admin() ) {
+ $submenu[ 'index.php' ][0] = array( __('Dashboard'), 'read', 'index.php' );
+
+ if ( is_multisite() )
+ $submenu[ 'index.php' ][5] = array( __('My Sites'), 'read', 'my-sites.php' );
+
+ if ( is_super_admin() ) {
+ $plugin_update_count = $theme_update_count = $wordpress_update_count = 0;
+ $update_plugins = get_site_transient( 'update_plugins' );
+ if ( !empty($update_plugins->response) )
+ $plugin_update_count = count( $update_plugins->response );
+ $update_themes = get_site_transient( 'update_themes' );
+ if ( !empty($update_themes->response) )
+ $theme_update_count = count( $update_themes->response );
+ $update_wordpress = get_core_updates( array('dismissed' => false) );
+ if ( !empty($update_wordpress) && !in_array( $update_wordpress[0]->response, array('development', 'latest') ) )
+ $wordpress_update_count = 1;
+
+ $update_count = $plugin_update_count + $theme_update_count + $wordpress_update_count;
+ $update_title = array();
+ if ( $wordpress_update_count )
+ $update_title[] = sprintf(__('%d WordPress Update'), $wordpress_update_count);
+ if ( $plugin_update_count )
+ $update_title[] = sprintf(_n('%d Plugin Update', '%d Plugin Updates', $plugin_update_count), $plugin_update_count);
+ if ( $theme_update_count )
+ $update_title[] = sprintf(_n('%d Theme Update', '%d Themes Updates', $theme_update_count), $theme_update_count);
+
+ $update_title = !empty($update_title) ? esc_attr(implode(', ', $update_title)) : '';
+
+ $submenu[ 'index.php' ][10] = array( sprintf( __('Updates %s'), "<span class='update-plugins count-$update_count' title='$update_title'><span class='update-count'>" . number_format_i18n($update_count) . "</span></span>" ), 'install_plugins', 'update-core.php');
+ unset($plugin_update_count, $theme_update_count, $wordpress_update_count, $update_count, $update_title);
+ }
+}
+
+$menu[4] = array( '', 'read', 'separator1', '', 'wp-menu-separator' );
+
+$menu[5] = array( __('Posts'), 'edit_posts', 'edit.php', '', 'open-if-no-js menu-top menu-icon-post', 'menu-posts', 'div' );
+ $submenu['edit.php'][5] = array( __('Posts'), 'edit_posts', 'edit.php' );
+ /* translators: add new post */
+ $submenu['edit.php'][10] = array( _x('Add New', 'post'), 'edit_posts', 'post-new.php' );
+
+ $i = 15;
+ foreach ( $wp_taxonomies as $tax ) {
+ if ( ! $tax->show_ui || ! in_array('post', (array) $tax->object_type, true) )
+ continue;