Put menus in their proper place. TODO: refactor.

git-svn-id: https://develop.svn.wordpress.org/trunk@6558 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Matt Mullenweg 2008-01-05 00:17:35 +00:00
parent edacf65f4a
commit 4c1bc01ade
2 changed files with 28 additions and 3 deletions

View File

@ -59,6 +59,31 @@ foreach ( $menu as $key => $item ) {
echo "\n\t<li><a href='{$item[2]}'$class>{$item[0]}</a></li>";
}
}
foreach ( $menu as $key => $item ) {
if ( $key < 41 ) // there is a more efficient way to do this!
continue;
$class = '';
// 0 = name, 1 = capability, 2 = file
if (( strcmp($self, $item[2]) == 0 && empty($parent_file)) || ($parent_file && ($item[2] == $parent_file))) $class = ' class="current"';
if ( !empty($submenu[$item[2]]) ) {
$submenu[$item[2]] = array_values($submenu[$item[2]]); // Re-index.
$menu_hook = get_plugin_page_hook($submenu[$item[2]][0][2], $item[2]);
if ( file_exists(ABSPATH . PLUGINDIR . "/{$submenu[$item[2]][0][2]}") || !empty($menu_hook))
echo "\n\t<li><a href='admin.php?page={$submenu[$item[2]][0][2]}'$class>{$item[0]}</a></li>";
else
echo "\n\t<li><a href='{$submenu[$item[2]][0][2]}'$class>{$item[0]}</a></li>";
} else if ( current_user_can($item[1]) ) {
if ( file_exists(ABSPATH . PLUGINDIR . "/{$item[2]}") )
echo "\n\t<li><a href='admin.php?page={$item[2]}'$class>{$item[0]}</a></li>";
else
echo "\n\t<li><a href='{$item[2]}'$class>{$item[0]}</a></li>";
}
}
do_action( 'adminmenu' );
?>
</ul>
@ -66,7 +91,7 @@ do_action( 'adminmenu' );
<ul id="sidemenu">
<?php
foreach ( $menu as $key => $item ) {
if ( 26 > $key ) // get each menu item before 3
if ( 26 > $key || $key > 40 )
continue;
$class = '';

View File

@ -18,8 +18,8 @@ else
$awaiting_mod = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = '0'");
if ( 100 < $awaiting_mod )
$awaiting_mod = '99+'; // to not blow out layout
$menu[15] = array( sprintf( __('Comments %s'), "<span id='awaiting-mod' class='comment-count'>$awaiting_mod</span>" ), 'edit_posts', 'edit-comments.php');
$menu[25] = array(__('Design'), 'switch_themes', 'themes.php');
$menu[15] = array(__('Design'), 'switch_themes', 'themes.php');
$menu[20] = array( sprintf( __('Comments %s'), "<span id='awaiting-mod' class='comment-count'>$awaiting_mod</span>" ), 'edit_posts', 'edit-comments.php');
$menu[30] = array(__('Plugins'), 'activate_plugins', 'plugins.php');
if ( current_user_can('edit_users') )
$menu[35] = array(__('Users'), 'edit_users', 'users.php');