-
+ BAF069EA7741C8752DB52F31BB8B7DFA4F509CACC56A42E39C52C70411F270D289EB7D67156AD07E2502CCD496D3C7E7FCD0FA182DE59CCA6A47BA287510E1B3
mp-wp/wp-admin/menu.php
(0 . 0)(1 . 247)
52994 <?php
52995 /**
52996 * Build Administration Menu.
52997 *
52998 * @package WordPress
52999 * @subpackage Administration
53000 */
53001
53002 /**
53003 * Constructs the admin menu bar.
53004 *
53005 * The elements in the array are :
53006 * 0: Menu item name
53007 * 1: Minimum level or capability required.
53008 * 2: The URL of the item's file
53009 * 3: Class
53010 * 4: ID
53011 * 5: Icon for top level menu
53012 *
53013 * @global array $menu
53014 * @name $menu
53015 * @var array
53016 */
53017
53018 $awaiting_mod = wp_count_comments();
53019 $awaiting_mod = $awaiting_mod->moderated;
53020
53021 $menu[0] = array( __('Dashboard'), 'read', 'index.php', '', 'menu-top', 'menu-dashboard', 'div' );
53022
53023 $menu[4] = array( '', 'read', '', '', 'wp-menu-separator' );
53024
53025 $menu[5] = array( __('Posts'), 'edit_posts', 'edit.php', '', 'wp-menu-open menu-top', 'menu-posts', 'div' );
53026 $submenu['edit.php'][5] = array( __('Edit'), 'edit_posts', 'edit.php' );
53027 $submenu['edit.php'][10] = array( _c('Add New|post'), 'edit_posts', 'post-new.php' );
53028 $submenu['edit.php'][15] = array( __('Tags'), 'manage_categories', 'edit-tags.php' );
53029 $submenu['edit.php'][20] = array( __('Categories'), 'manage_categories', 'categories.php' );
53030
53031 $menu[10] = array( __('Media'), 'upload_files', 'upload.php', '', 'menu-top', 'menu-media', 'div' );
53032 $submenu['upload.php'][5] = array( __('Library'), 'upload_files', 'upload.php');
53033 $submenu['upload.php'][10] = array( _c('Add New|file'), 'upload_files', 'media-new.php');
53034
53035 $menu[15] = array( __('Links'), 'manage_links', 'link-manager.php', '', 'menu-top', 'menu-links', 'div' );
53036 $submenu['link-manager.php'][5] = array( __('Edit'), 'manage_links', 'link-manager.php' );
53037 $submenu['link-manager.php'][10] = array( _c('Add New|links'), 'manage_links', 'link-add.php' );
53038 $submenu['link-manager.php'][15] = array( __('Link Categories'), 'manage_categories', 'edit-link-categories.php' );
53039
53040 $menu[20] = array( __('Pages'), 'edit_pages', 'edit-pages.php', '', 'menu-top', 'menu-pages', 'div' );
53041 $submenu['edit-pages.php'][5] = array( __('Edit'), 'edit_pages', 'edit-pages.php' );
53042 $submenu['edit-pages.php'][10] = array( _c('Add New|page'), 'edit_pages', 'page-new.php' );
53043
53044 $menu[25] = array( sprintf( __('Comments %s'), "<span id='awaiting-mod' class='count-$awaiting_mod'><span class='pending-count'>" . number_format_i18n($awaiting_mod) . "</span></span>" ), 'edit_posts', 'edit-comments.php', '', 'menu-top', 'menu-comments', 'div' );
53045
53046 $_wp_last_object_menu = 25; // The index of the last top-level menu in the object menu group
53047
53048 $menu[39] = array( '', 'read', '', '', 'wp-menu-separator' );
53049
53050 $menu[40] = array( __('Appearance'), 'switch_themes', 'themes.php', '', 'menu-top', 'menu-appearance', 'div' );
53051 $submenu['themes.php'][5] = array(__('Themes'), 'switch_themes', 'themes.php');
53052 $submenu['themes.php'][10] = array(__('Editor'), 'edit_themes', 'theme-editor.php');
53053
53054 $update_plugins = get_option( 'update_plugins' );
53055 $update_count = 0;
53056 if ( !empty($update_plugins->response) )
53057 $update_count = count( $update_plugins->response );
53058
53059 $menu[45] = array( sprintf( __('Plugins %s'), "<span class='update-plugins count-$update_count'><span class='plugin-count'>" . number_format_i18n($update_count) . "</span></span>" ), 'activate_plugins', 'plugins.php', '', 'menu-top', 'menu-plugins', 'div' );
53060 $submenu['plugins.php'][5] = array( __('Installed'), 'activate_plugins', 'plugins.php' );
53061 $submenu['plugins.php'][10] = array(_c('Add New|plugin'), 'install_plugins', 'plugin-install.php');
53062 $submenu['plugins.php'][15] = array( __('Editor'), 'edit_plugins', 'plugin-editor.php' );
53063
53064 if ( current_user_can('edit_users') )
53065 $menu[50] = array( __('Users'), 'edit_users', 'users.php', '', 'menu-top', 'menu-users', 'div' );
53066 else
53067 $menu[50] = array( __('Profile'), 'read', 'profile.php', '', 'menu-top', 'menu-users', 'div' );
53068
53069 if ( current_user_can('edit_users') ) {
53070 $_wp_real_parent_file['profile.php'] = 'users.php'; // Back-compat for plugins adding submenus to profile.php.
53071 $submenu['users.php'][5] = array(__('Authors & Users'), 'edit_users', 'users.php');
53072 $submenu['users.php'][10] = array(__('Add New'), 'create_users', 'user-new.php');
53073 $submenu['users.php'][15] = array(__('Your Profile'), 'read', 'profile.php');
53074 } else {
53075 $_wp_real_parent_file['users.php'] = 'profile.php';
53076 $submenu['profile.php'][5] = array(__('Your Profile'), 'read', 'profile.php');
53077 }
53078
53079 $menu[55] = array( __('Tools'), 'manage_options', 'tools.php', '', 'menu-top', 'menu-tools', 'div' );
53080 $submenu['tools.php'][5] = array( __('Tools'), 'read', 'tools.php' );
53081 $submenu['tools.php'][10] = array( __('Import'), 'import', 'import.php' );
53082 $submenu['tools.php'][15] = array( __('Export'), 'import', 'export.php' );
53083 $submenu['tools.php'][20] = array( __('Upgrade'), 'install_plugins', 'update-core.php');
53084
53085 $menu[60] = array( __('Settings'), 'manage_options', 'options-general.php', '', 'menu-top', 'menu-settings', 'div' );
53086 $submenu['options-general.php'][10] = array(__('General'), 'manage_options', 'options-general.php');
53087 $submenu['options-general.php'][15] = array(__('Writing'), 'manage_options', 'options-writing.php');
53088 $submenu['options-general.php'][20] = array(__('Reading'), 'manage_options', 'options-reading.php');
53089 $submenu['options-general.php'][25] = array(__('Discussion'), 'manage_options', 'options-discussion.php');
53090 $submenu['options-general.php'][30] = array(__('Media'), 'manage_options', 'options-media.php');
53091 $submenu['options-general.php'][35] = array(__('Privacy'), 'manage_options', 'options-privacy.php');
53092 $submenu['options-general.php'][40] = array(__('Permalinks'), 'manage_options', 'options-permalink.php');
53093 $submenu['options-general.php'][45] = array(__('Miscellaneous'), 'manage_options', 'options-misc.php');
53094
53095 $_wp_last_utility_menu = 60; // The index of the last top-level menu in the utility menu group
53096
53097 $menu[79] = array( '', 'read', '', '', 'wp-menu-separator-last' );
53098
53099 // Back-compat for old top-levels
53100 $_wp_real_parent_file['post.php'] = 'edit.php';
53101 $_wp_real_parent_file['post-new.php'] = 'edit.php';
53102 $_wp_real_parent_file['page-new.php'] = 'edit-pages.php';
53103
53104 do_action('_admin_menu');
53105
53106 // Create list of page plugin hook names.
53107 foreach ($menu as $menu_page) {
53108 $admin_page_hooks[$menu_page[2]] = sanitize_title($menu_page[0]);
53109 }
53110
53111 $_wp_submenu_nopriv = array();
53112 $_wp_menu_nopriv = array();
53113 // Loop over submenus and remove pages for which the user does not have privs.
53114 foreach ( array( 'submenu' ) as $sub_loop ) {
53115 foreach ($$sub_loop as $parent => $sub) {
53116 foreach ($sub as $index => $data) {
53117 if ( ! current_user_can($data[1]) ) {
53118 unset(${$sub_loop}[$parent][$index]);
53119 $_wp_submenu_nopriv[$parent][$data[2]] = true;
53120 }
53121 }
53122
53123 if ( empty(${$sub_loop}[$parent]) )
53124 unset(${$sub_loop}[$parent]);
53125 }
53126 }
53127
53128 // Loop over the top-level menu.
53129 // Menus for which the original parent is not acessible due to lack of privs will have the next
53130 // submenu in line be assigned as the new menu parent.
53131 foreach ( $menu as $id => $data ) {
53132 if ( empty($submenu[$data[2]]) )
53133 continue;
53134 $subs = $submenu[$data[2]];
53135 $first_sub = array_shift($subs);
53136 $old_parent = $data[2];
53137 $new_parent = $first_sub[2];
53138 // If the first submenu is not the same as the assigned parent,
53139 // make the first submenu the new parent.
53140 if ( $new_parent != $old_parent ) {
53141 $_wp_real_parent_file[$old_parent] = $new_parent;
53142 $menu[$id][2] = $new_parent;
53143
53144 foreach ($submenu[$old_parent] as $index => $data) {
53145 $submenu[$new_parent][$index] = $submenu[$old_parent][$index];
53146 unset($submenu[$old_parent][$index]);
53147 }
53148 unset($submenu[$old_parent]);
53149
53150 if ( isset($_wp_submenu_nopriv[$old_parent]) )
53151 $_wp_submenu_nopriv[$new_parent] = $_wp_submenu_nopriv[$old_parent];
53152 }
53153 }
53154
53155 do_action('admin_menu', '');
53156
53157 // Remove menus that have no accessible submenus and require privs that the user does not have.
53158 // Run re-parent loop again.
53159 foreach ( $menu as $id => $data ) {
53160 // If submenu is empty...
53161 if ( empty($submenu[$data[2]]) ) {
53162 // And user doesn't have privs, remove menu.
53163 if ( ! current_user_can($data[1]) ) {
53164 $_wp_menu_nopriv[$data[2]] = true;
53165 unset($menu[$id]);
53166 }
53167 }
53168 }
53169
53170 // Remove any duplicated seperators
53171 $seperator_found = false;
53172 foreach ( $menu as $id => $data ) {
53173 if ( 0 == strcmp('wp-menu-separator', $data[4] ) ) {
53174 if (false == $seperator_found) {
53175 $seperator_found = true;
53176 } else {
53177 unset($menu[$id]);
53178 $seperator_found = false;
53179 }
53180 } else {
53181 $seperator_found = false;
53182 }
53183 }
53184
53185 unset($id);
53186
53187 function add_cssclass($add, $class) {
53188 $class = empty($class) ? $add : $class .= ' ' . $add;
53189 return $class;
53190 }
53191
53192 function add_menu_classes($menu) {
53193
53194 $first = $lastorder = false;
53195 $i = 0;
53196 $mc = count($menu);
53197 foreach ( $menu as $order => $top ) {
53198 $i++;
53199
53200 if ( 0 == $order ) { // dashboard is always shown/single
53201 $menu[0][4] = add_cssclass('menu-top-first menu-top-last', $top[4]);
53202 continue;
53203 }
53204
53205 if ( empty($top[2]) ) { // if separator
53206 $first = true;
53207 if ( $lastorder ) {
53208 $c = $menu[$lastorder][4];
53209 $menu[$lastorder][4] = add_cssclass('menu-top-last', $c);
53210 }
53211 continue;
53212 }
53213
53214 if ( $first ) {
53215 $c = $menu[$order][4];
53216 $menu[$order][4] = add_cssclass('menu-top-first', $c);
53217 $first = false;
53218 }
53219
53220 if ( $mc == $i ) { // last item
53221 $c = $menu[$order][4];
53222 $menu[$order][4] = add_cssclass('menu-top-last', $c);
53223 }
53224
53225 $lastorder = $order;
53226 }
53227
53228 return apply_filters( 'add_menu_classes', $menu );
53229 }
53230
53231 uksort($menu, "strnatcasecmp"); // make it all pretty
53232
53233 $menu = add_menu_classes($menu);
53234
53235 if (! user_can_access_admin_page()) {
53236 do_action('admin_page_access_denied');
53237 wp_die( __('You do not have sufficient permissions to access this page.') );
53238 }
53239
53240 ?>