2004-10-18 23:03:06 -04:00
|
|
|
<?php
|
2008-08-14 02:30:38 -04:00
|
|
|
/**
|
|
|
|
* Displays Administration Menu.
|
|
|
|
*
|
|
|
|
* @package WordPress
|
|
|
|
* @subpackage Administration
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The current page.
|
|
|
|
*
|
|
|
|
* @global string $self
|
|
|
|
* @name $self
|
|
|
|
* @var string
|
|
|
|
*/
|
2004-10-18 23:03:06 -04:00
|
|
|
$self = preg_replace('|^.*/wp-admin/|i', '', $_SERVER['PHP_SELF']);
|
|
|
|
$self = preg_replace('|^.*/plugins/|i', '', $self);
|
|
|
|
|
2008-06-04 14:09:31 -04:00
|
|
|
global $menu, $submenu, $parent_file; //For when admin-header is included from within a function.
|
|
|
|
|
2006-11-18 02:31:29 -05:00
|
|
|
get_admin_page_parent();
|
2004-10-18 23:03:06 -04:00
|
|
|
|
2008-01-04 06:47:06 -05:00
|
|
|
// We're going to do this loop three times
|
|
|
|
?>
|
|
|
|
|
|
|
|
<ul id="dashmenu">
|
|
|
|
<?php
|
|
|
|
foreach ( $menu as $key => $item ) {
|
|
|
|
if ( 3 < $key ) // get each menu item before 3
|
|
|
|
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]);
|
2008-05-27 13:55:24 -04:00
|
|
|
if ( file_exists(WP_PLUGIN_DIR . "/{$submenu[$item[2]][0][2]}") || !empty($menu_hook))
|
2008-01-04 06:47:06 -05:00
|
|
|
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]) ) {
|
2008-03-07 09:48:10 -05:00
|
|
|
$menu_hook = get_plugin_page_hook($item[2], 'admin.php');
|
2008-05-27 13:55:24 -04:00
|
|
|
if ( file_exists(WP_PLUGIN_DIR . "/{$item[2]}") || !empty($menu_hook) )
|
2008-01-04 06:47:06 -05:00
|
|
|
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( 'dashmenu' );
|
|
|
|
?>
|
|
|
|
</ul>
|
|
|
|
|
|
|
|
<ul id="adminmenu">
|
|
|
|
<?php
|
|
|
|
foreach ( $menu as $key => $item ) {
|
|
|
|
if ( 5 > $key || $key > 25 ) // get each menu item before 3
|
|
|
|
continue;
|
|
|
|
|
2004-10-18 23:03:06 -04:00
|
|
|
$class = '';
|
|
|
|
|
2005-07-17 15:29:55 -04:00
|
|
|
// 0 = name, 1 = capability, 2 = file
|
2005-02-11 21:00:56 -05:00
|
|
|
if (( strcmp($self, $item[2]) == 0 && empty($parent_file)) || ($parent_file && ($item[2] == $parent_file))) $class = ' class="current"';
|
2006-11-18 11:24:31 -05:00
|
|
|
|
|
|
|
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]);
|
2008-05-27 13:55:24 -04:00
|
|
|
if ( file_exists(WP_PLUGIN_DIR . "/{$submenu[$item[2]][0][2]}") || !empty($menu_hook))
|
2006-11-18 11:24:31 -05:00
|
|
|
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]) ) {
|
2008-03-07 09:48:10 -05:00
|
|
|
$menu_hook = get_plugin_page_hook($item[2], 'admin.php');
|
2008-05-27 13:55:24 -04:00
|
|
|
if ( file_exists(WP_PLUGIN_DIR . "/{$item[2]}") || !empty($menu_hook) )
|
2006-11-02 01:07:59 -05:00
|
|
|
echo "\n\t<li><a href='admin.php?page={$item[2]}'$class>{$item[0]}</a></li>";
|
2004-12-14 04:53:16 -05:00
|
|
|
else
|
2006-11-02 01:07:59 -05:00
|
|
|
echo "\n\t<li><a href='{$item[2]}'$class>{$item[0]}</a></li>";
|
2004-11-25 20:50:37 -05:00
|
|
|
}
|
2004-10-18 23:03:06 -04:00
|
|
|
}
|
2008-01-04 19:17:35 -05:00
|
|
|
|
|
|
|
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]);
|
2008-05-27 13:55:24 -04:00
|
|
|
if ( file_exists(WP_PLUGIN_DIR . "/{$submenu[$item[2]][0][2]}") || !empty($menu_hook))
|
2008-01-04 19:17:35 -05:00
|
|
|
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]) ) {
|
2008-03-07 09:48:10 -05:00
|
|
|
$menu_hook = get_plugin_page_hook($item[2], 'admin.php');
|
2008-05-27 13:55:24 -04:00
|
|
|
if ( file_exists(WP_PLUGIN_DIR . "/{$item[2]}") || !empty($menu_hook) )
|
2008-01-04 19:17:35 -05:00
|
|
|
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>";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-01-04 06:47:06 -05:00
|
|
|
do_action( 'adminmenu' );
|
|
|
|
?>
|
|
|
|
</ul>
|
|
|
|
|
|
|
|
<ul id="sidemenu">
|
|
|
|
<?php
|
2008-01-16 01:48:08 -05:00
|
|
|
$side_items = array();
|
2008-01-04 06:47:06 -05:00
|
|
|
foreach ( $menu as $key => $item ) {
|
2008-01-04 19:17:35 -05:00
|
|
|
if ( 26 > $key || $key > 40 )
|
2008-01-04 06:47:06 -05:00
|
|
|
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"';
|
2004-10-18 23:03:06 -04:00
|
|
|
|
2008-01-04 06:47:06 -05:00
|
|
|
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]);
|
2008-05-27 13:55:24 -04:00
|
|
|
if ( file_exists(WP_PLUGIN_DIR . "/{$submenu[$item[2]][0][2]}") || !empty($menu_hook))
|
2008-01-16 01:48:08 -05:00
|
|
|
$side_items[] = "\n\t<li><a href='admin.php?page={$submenu[$item[2]][0][2]}'$class>{$item[0]}</a>";
|
2008-01-04 06:47:06 -05:00
|
|
|
else
|
2008-01-16 01:48:08 -05:00
|
|
|
$side_items[] = "\n\t<li><a href='{$submenu[$item[2]][0][2]}'$class>{$item[0]}</a>";
|
2008-01-04 06:47:06 -05:00
|
|
|
} else if ( current_user_can($item[1]) ) {
|
2008-03-07 09:48:10 -05:00
|
|
|
$menu_hook = get_plugin_page_hook($item[2], 'admin.php');
|
2008-05-27 13:55:24 -04:00
|
|
|
if ( file_exists(WP_PLUGIN_DIR . "/{$item[2]}") || !empty($menu_hook) )
|
2008-01-16 01:48:08 -05:00
|
|
|
$side_items[] = "\n\t<li><a href='admin.php?page={$item[2]}'$class>{$item[0]}</a>";
|
2008-01-04 06:47:06 -05:00
|
|
|
else
|
2008-01-16 01:48:08 -05:00
|
|
|
$side_items[] = "\n\t<li><a href='{$item[2]}'$class>{$item[0]}</a>";
|
2008-01-04 06:47:06 -05:00
|
|
|
}
|
|
|
|
}
|
2008-02-21 23:45:24 -05:00
|
|
|
echo implode(' </li>', $side_items) . '</li>';
|
2008-01-16 01:48:08 -05:00
|
|
|
unset($side_items);
|
2008-01-04 06:47:06 -05:00
|
|
|
do_action( 'sidemenu' );
|
2004-10-18 23:03:06 -04:00
|
|
|
?>
|
|
|
|
</ul>
|
|
|
|
|
2008-01-04 06:47:06 -05:00
|
|
|
|
2004-10-18 23:03:06 -04:00
|
|
|
<?php
|
|
|
|
// Sub-menu
|
|
|
|
if ( isset($submenu["$parent_file"]) ) :
|
|
|
|
?>
|
2005-09-05 19:33:10 -04:00
|
|
|
<ul id="submenu">
|
2006-11-19 02:56:05 -05:00
|
|
|
<?php
|
|
|
|
foreach ($submenu["$parent_file"] as $item) :
|
2005-07-13 12:04:14 -04:00
|
|
|
if ( !current_user_can($item[1]) )
|
2004-10-18 23:03:06 -04:00
|
|
|
continue;
|
|
|
|
|
2005-03-02 11:30:00 -05:00
|
|
|
if ( isset($submenu_file) ) {
|
2005-03-20 23:18:16 -05:00
|
|
|
if ( $submenu_file == $item[2] ) $class = ' class="current"';
|
2005-03-02 11:30:00 -05:00
|
|
|
else $class = '';
|
2005-03-20 23:18:16 -05:00
|
|
|
} else if ( (isset($plugin_page) && $plugin_page == $item[2]) || (!isset($plugin_page) && $self == $item[2]) ) $class = ' class="current"';
|
2004-12-24 15:55:36 -05:00
|
|
|
else $class = '';
|
2004-10-18 23:03:06 -04:00
|
|
|
|
2005-02-25 11:11:27 -05:00
|
|
|
$menu_hook = get_plugin_page_hook($item[2], $parent_file);
|
|
|
|
|
2008-05-27 13:55:24 -04:00
|
|
|
if (file_exists(WP_PLUGIN_DIR . "/{$item[2]}") || ! empty($menu_hook)) {
|
2005-02-25 11:11:27 -05:00
|
|
|
if ( 'admin.php' == $pagenow )
|
2006-11-02 01:07:59 -05:00
|
|
|
echo "\n\t<li><a href='admin.php?page={$item[2]}'$class>{$item[0]}</a></li>";
|
2005-02-25 11:11:27 -05:00
|
|
|
else
|
2006-11-02 01:07:59 -05:00
|
|
|
echo "\n\t<li><a href='{$parent_file}?page={$item[2]}'$class>{$item[0]}</a></li>";
|
2005-02-06 20:15:06 -05:00
|
|
|
} else {
|
2006-11-02 01:07:59 -05:00
|
|
|
echo "\n\t<li><a href='{$item[2]}'$class>{$item[0]}</a></li>";
|
2005-02-06 20:15:06 -05:00
|
|
|
}
|
2004-10-18 23:03:06 -04:00
|
|
|
endforeach;
|
|
|
|
?>
|
|
|
|
|
|
|
|
</ul>
|
2006-02-09 04:03:13 -05:00
|
|
|
<?php
|
2006-10-05 21:14:47 -04:00
|
|
|
else :
|
|
|
|
?>
|
|
|
|
<div id="minisub"></div>
|
|
|
|
<?php
|
2006-02-09 04:03:13 -05:00
|
|
|
|
2006-11-19 02:56:05 -05:00
|
|
|
endif;
|
2006-02-09 04:03:13 -05:00
|
|
|
|
|
|
|
do_action('admin_notices');
|
|
|
|
|
2006-11-18 11:24:31 -05:00
|
|
|
?>
|