Make WordPress Core


Ignore:
Timestamp:
06/18/2008 01:55:39 AM (18 years ago)
Author:
mdawaffe
Message:

crazyhorse: first pass at menu positioning - will break some things. Menu reorganization to come

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/crazyhorse/wp-admin/menu.php

    r7857 r8115  
    55// The minimum level the user needs to access the item: between 0 and 10
    66// The URL of the item's file
     7
     8$awaiting_mod = wp_count_comments();
     9$awaiting_mod = $awaiting_mod->moderated;
     10
     11$top_menu = array();
     12$top_menu[5] = array( __('My Account'), 'read', 'profile.php' );
     13$top_menu[10] = array( __('My Dashboard'), 'read', 'index.php' );
     14$top_menu[15] = array( __('New Post'), 'edit_posts', 'post-new.php' );
     15$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' );
     16$top_menu[25] = array( __('Help'), 'read', 'index.php?help' ); // place holder
     17
     18$top_submenu = array();
     19$top_submenu['profile.php'][5] = array( __('Something'), 'read', 'profile.php?something' ); // place holder
     20
    721$menu[0] = array(__('Dashboard'), 'read', 'index.php');
    822
     
    2135    $menu[10] = array(__('Manage'), 'edit_posts', 'edit.php');
    2236
    23 $awaiting_mod = wp_count_comments();
    24 $awaiting_mod = $awaiting_mod->moderated;
    2537$menu[15] = array(__('Design'), 'switch_themes', 'themes.php');
    2638$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');
     
    8294$_wp_menu_nopriv = array();
    8395// Loop over submenus and remove pages for which the user does not have privs.
    84 foreach ($submenu as $parent => $sub) {
    85     foreach ($sub as $index => $data) {
    86         if ( ! current_user_can($data[1]) ) {
    87             unset($submenu[$parent][$index]);
    88             $_wp_submenu_nopriv[$parent][$data[2]] = true;
     96foreach ( array( 'top_submenu', 'submenu' ) as $sub_loop ) {
     97    foreach ($$sub_loop as $parent => $sub) {
     98        foreach ($sub as $index => $data) {
     99            if ( ! current_user_can($data[1]) ) {
     100                unset(${$sub_loop}[$parent][$index]);
     101                $_wp_submenu_nopriv[$parent][$data[2]] = true;
     102            }
    89103        }
     104
     105        if ( empty(${$sub_loop}[$parent]) )
     106            unset(${$sub_loop}[$parent]);
    90107    }
    91 
    92     if ( empty($submenu[$parent]) )
    93         unset($submenu[$parent]);
    94108}
    95109
Note: See TracChangeset for help on using the changeset viewer.