Make WordPress Core


Ignore:
Timestamp:
08/20/2008 09:42:31 PM (16 years ago)
Author:
ryan
Message:

Collapse crazyhorse to trunk. Incoming! see #7552

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/menu.php

    r8645 r8691  
    1919 * @var array
    2020 */
    21 $menu[0] = array(__('Dashboard'), 'read', 'index.php');
    22 
    23 if (strpos($_SERVER['REQUEST_URI'], 'edit-pages.php') !== false)
    24     $menu[5] = array(__('Write'), 'edit_pages', 'page-new.php');
    25 elseif (strpos($_SERVER['REQUEST_URI'], 'link-manager.php') !== false)
    26     $menu[5] = array(__('Write'), 'manage_links', 'link-add.php');
    27 else
    28     $menu[5] = array(__('Write'), 'edit_posts', 'post-new.php');
    29 
    30 if (strpos($_SERVER['REQUEST_URI'], 'page-new.php') !== false)
    31     $menu[10] = array(__('Manage'), 'edit_pages', 'edit-pages.php');
    32 elseif (strpos($_SERVER['REQUEST_URI'], 'link-add.php') !== false)
    33     $menu[10] = array(__('Manage'), 'manage_links', 'link-manager.php');
    34 else
    35     $menu[10] = array(__('Manage'), 'edit_posts', 'edit.php');
    3621
    3722$awaiting_mod = wp_count_comments();
    3823$awaiting_mod = $awaiting_mod->moderated;
    39 $menu[15] = array(__('Design'), 'switch_themes', 'themes.php');
    40 $menu[20] = array( sprintf( __('Comments %s'), "<span id='awaiting-mod' class='count-$awaiting_mod'><span class='comment-count'>" . number_format_i18n($awaiting_mod) . "</span></span>" ), 'edit_posts', 'edit-comments.php');
    41 $menu[30] = array(__('Settings'), 'manage_options', 'options-general.php');
    4224
    43 $update_plugins = get_option( 'update_plugins' );
    44 $update_count = 0;
    45 if ( isset( $update_plugins->response ) )
    46     $update_count = count( $update_plugins->response );
     25$inbox_num = count( wp_get_inbox_items() );
     26$awaiting_mod = wp_count_comments();
     27$awaiting_mod = $awaiting_mod->moderated;
    4728
    48 $menu[35] = array( sprintf( __('Plugins %s'), "<span id='update-plugins' class='count-$update_count'><span class='plugin-count'>" . number_format_i18n($update_count) . "</span></span>" ), 'activate_plugins', 'plugins.php');
    49 if ( current_user_can('edit_users') )
    50     $menu[40] = array(__('Users'), 'edit_users', 'users.php');
    51 else
    52     $menu[40] = array(__('Profile'), 'read', 'profile.php');
     29$top_menu = $top_submenu = $menu = $submenu = array();
    5330
    54 $_wp_real_parent_file['post.php'] = 'post-new.php'; // Back-compat
    55 $submenu['post-new.php'][5] = array(__('Post'), 'edit_posts', 'post-new.php');
    56 $submenu['post-new.php'][10] = array(__('Page'), 'edit_pages', 'page-new.php');
    57 $submenu['post-new.php'][15] = array(__('Link'), 'manage_links', 'link-add.php');
     31$top_menu[5]  = array( __('My Account'), 'read', 'profile.php' );
     32$top_menu[10] = array( __('My Dashboard'), 'read', 'index.php' );
     33$top_menu[15] = array( __('New Post'), 'edit_posts', 'post-new.php', 'highlighted' );
     34//$top_menu[20] = array( sprintf( __('Inbox (%s)'), "<span id='inbox-num' class='count-$inbox_num'><span class='inbox-count'>" . number_format_i18n($inbox_num) . "</span></span>" ), 'edit_posts', 'inbox.php' );
     35$top_menu[20] = array( sprintf( __('Comments (%s)'), "<span id='awaiting-mod' class='count-$awaiting_mod'><span class='comment-count'>" . number_format_i18n($awaiting_mod) . "</span></span>" ), 'edit_posts', 'edit-comments.php');
     36$top_menu[25] = array( __('Help'), 'read', 'index.php?help' ); // place holder
    5837
    59 $submenu['edit-comments.php'][5] = array(__('Comments'), 'edit_posts', 'edit-comments.php');
     38$top_submenu['profile.php'][5]  = array( __('Profile'), 'read', 'profile.php' );
     39$top_submenu['profile.php'][10] = array( __('Stats'), 'read', 'inbox.php?page=stats' ); // place holder
    6040
    61 $submenu['edit.php'][5] = array(__('Posts'), 'edit_posts', 'edit.php');
    62 $submenu['edit.php'][10] = array(__('Pages'), 'edit_pages', 'edit-pages.php');
    63 $submenu['edit.php'][15] = array(__('Links'), 'manage_links', 'link-manager.php');
    64 $submenu['edit.php'][20] = array(__('Categories'), 'manage_categories', 'categories.php');
    65 $submenu['edit.php'][25] = array(__('Tags'), 'manage_categories', 'edit-tags.php');
    66 $submenu['edit.php'][30] = array(__('Link Categories'), 'manage_categories', 'edit-link-categories.php');
    67 $submenu['edit.php'][35] = array(__('Media Library'), 'upload_files', 'upload.php');
    68 $submenu['edit.php'][40] = array(__('Import'), 'import', 'import.php');
    69 $submenu['edit.php'][45] = array(__('Export'), 'import', 'export.php');
    7041
    71 if ( current_user_can('edit_users') ) {
    72     $_wp_real_parent_file['profile.php'] = 'users.php'; // Back-compat for plugins adding submenus to profile.php.
    73     $submenu['users.php'][5] = array(__('Authors &amp; Users'), 'edit_users', 'users.php');
    74     $submenu['users.php'][10] = array(__('Your Profile'), 'read', 'profile.php');
    75 } else {
    76     $_wp_real_parent_file['users.php'] = 'profile.php';
    77     $submenu['profile.php'][5] = array(__('Your Profile'), 'read', 'profile.php');
    78 }
     42$menu[0] = array( __('Dashboard'), 'read', 'index.php' );
    7943
    80 $submenu['options-general.php'][10] = array(__('General'), 'manage_options', 'options-general.php');
    81 $submenu['options-general.php'][15] = array(__('Writing'), 'manage_options', 'options-writing.php');
    82 $submenu['options-general.php'][20] = array(__('Reading'), 'manage_options', 'options-reading.php');
    83 $submenu['options-general.php'][25] = array(__('Discussion'), 'manage_options', 'options-discussion.php');
    84 $submenu['options-general.php'][30] = array(__('Privacy'), 'manage_options', 'options-privacy.php');
    85 $submenu['options-general.php'][35] = array(__('Permalinks'), 'manage_options', 'options-permalink.php');
    86 $submenu['options-general.php'][40] = array(__('Miscellaneous'), 'manage_options', 'options-misc.php');
     44$menu[5] = array( __('Content'), 'edit_posts', 'edit.php', 'wp-menu-open' );
     45    $submenu['edit.php'][5]  = array( __('Posts'), 'edit_posts', 'edit.php' );
     46    $submenu['edit.php'][10] = array( __('Comments'), 'edit_posts', 'edit-comments.php' );
     47    $submenu['edit.php'][15] = array( __('Media Library'), 'upload_files', 'upload.php' );
     48    $submenu['edit.php'][20] = array( __('Links'), 'manage_links', 'link-manager.php' );
     49    $submenu['edit.php'][25] = array( __('Pages'), 'edit_pages', 'edit-pages.php' );
    8750
    88 $submenu['plugins.php'][5] = array(__('Plugins'), 'activate_plugins', 'plugins.php');
    89 $submenu['plugins.php'][10] = array(__('Plugin Editor'), 'edit_plugins', 'plugin-editor.php');
     51$menu[10] = array( __('Templates'), 'switch_themes', 'themes.php' );
     52    $submenu['themes.php'][5]  = array(__('Themes'), 'switch_themes', 'themes.php');
     53    $submenu['themes.php'][10] = array(__('Theme Editor'), 'edit_themes', 'theme-editor.php');
    9054$submenu['plugins.php'][15] = array(__('Install Plugins'), 'install_plugins', 'plugin-install.php');
    9155
    92 $submenu['themes.php'][5] = array(__('Themes'), 'switch_themes', 'themes.php');
    93 $submenu['themes.php'][10] = array(__('Theme Editor'), 'edit_themes', 'theme-editor.php');
     56$menu[15] = array( __('Utilities'), 'read', 'users.php' ); // placeholder - should be inbox
     57    $submenu['users.php'][5]  = array( __('Inbox'), 'read', 'inbox.php' );
     58    $submenu['users.php'][10] = array( __('Tags'), 'manage_categories', 'edit-tags.php' );
     59    $submenu['users.php'][15] = array( __('Categories'), 'manage_categories', 'categories.php' );
     60    $submenu['users.php'][20] = array( __('Link Categories'), 'manage_categories', 'edit-link-categories.php' );
     61    $submenu['users.php'][25] = array( __('Users'), 'edit_users', 'users.php' );
     62    $submenu['users.php'][30] = array( __('Import'), 'import', 'import.php' );
     63    $submenu['users.php'][35] = array( __('Export'), 'import', 'export.php' );
     64    $submenu['users.php'][40] = array( __('Settings'), 'manage_options', 'options-general.php' );
     65        $_wp_real_parent_file['options-general.php'] = 'users.php';
     66        $submenu['options-general.php'][10] = array( __('General'), 'manage_options', 'options-general.php' );
     67        $submenu['options-general.php'][15] = array( __('Writing'), 'manage_options', 'options-writing.php' );
     68        $submenu['options-general.php'][20] = array( __('Reading'), 'manage_options', 'options-reading.php' );
     69        $submenu['options-general.php'][25] = array( __('Discussion'), 'manage_options', 'options-discussion.php' );
     70        $submenu['options-general.php'][30] = array( __('Privacy'), 'manage_options', 'options-privacy.php' );
     71        $submenu['options-general.php'][35] = array( __('Permalinks'), 'manage_options', 'options-permalink.php' );
     72        $submenu['options-general.php'][40] = array( __('Miscellaneous'), 'manage_options', 'options-misc.php' );
     73
     74$menu[20] = array( __('Plugins'), 'activate_plugins', 'plugins.php' );
     75    $submenu['plugins.php'][5]  = array( __('Plugins'), 'activate_plugins', 'plugins.php' );
     76    $submenu['plugins.php'][10] = array( __('Plugin Editor'), 'edit_plugins', 'plugin-editor.php' );
    9477
    9578do_action('_admin_menu');
     
    10386$_wp_menu_nopriv = array();
    10487// Loop over submenus and remove pages for which the user does not have privs.
    105 foreach ($submenu as $parent => $sub) {
    106     foreach ($sub as $index => $data) {
    107         if ( ! current_user_can($data[1]) ) {
    108             unset($submenu[$parent][$index]);
    109             $_wp_submenu_nopriv[$parent][$data[2]] = true;
     88foreach ( array( 'top_submenu', 'submenu' ) as $sub_loop ) {
     89    foreach ($$sub_loop as $parent => $sub) {
     90        foreach ($sub as $index => $data) {
     91            if ( ! current_user_can($data[1]) ) {
     92                unset(${$sub_loop}[$parent][$index]);
     93                $_wp_submenu_nopriv[$parent][$data[2]] = true;
     94            }
    11095        }
     96
     97        if ( empty(${$sub_loop}[$parent]) )
     98            unset(${$sub_loop}[$parent]);
    11199    }
    112 
    113     if ( empty($submenu[$parent]) )
    114         unset($submenu[$parent]);
    115100}
    116101
Note: See TracChangeset for help on using the changeset viewer.