\n";
}
echo $ozh_menu;
}
/* Core stuff : builds an array populated with all the infos needed for menu and submenu */
function wp_ozh_adminmenu_build () {
global $menu, $submenu, $plugin_page, $pagenow;
/* Most of the following garbage are bits from admin-header.php,
* modified to populate an array of all links to display in the menu
*/
$self = preg_replace('|^.*/wp-admin/|i', '', $_SERVER['PHP_SELF']);
$self = preg_replace('|^.*/plugins/|i', '', $self);
get_admin_page_parent();
$altmenu = array();
/* Step 1 : populate first level menu as per user rights */
foreach ($menu as $item) {
// 0 = name, 1 = capability, 2 = file
if ( current_user_can($item[1]) ) {
if ( file_exists(ABSPATH . "wp-content/plugins/{$item[2]}") )
$altmenu[$item[2]]['url'] = get_settings('siteurl') . "/wp-admin/admin.php?page={$item[2]}";
else
$altmenu[$item[2]]['url'] = get_settings('siteurl') . "/wp-admin/{$item[2]}";
if (( strcmp($self, $item[2]) == 0 && empty($parent_file)) || ($parent_file && ($item[2] == $parent_file)))
$altmenu[$item[2]]['class'] = " class='current'";
$altmenu[$item[2]]['name'] = $item[0];
/* Windows installs may have backslashes instead of slashes in some paths, fix this */
$altmenu[$item[2]]['name'] = str_replace(chr(92),chr(92).chr(92),$altmenu[$item[2]]['name']);
}
}
/* Step 2 : populate second level menu */
foreach ($submenu as $k=>$v) {
foreach ($v as $item) {
if (array_key_exists($k,$altmenu) and current_user_can($item[1])) {
// What's the link ?
$menu_hook = get_plugin_page_hook($item[2], $k);
if (file_exists(ABSPATH . "wp-content/plugins/{$item[2]}") || ! empty($menu_hook)) {
if ( 'admin.php' == $pagenow )
$link = get_settings('siteurl') . "/wp-admin/admin.php?page={$item[2]}";
else
$link = get_settings('siteurl') . "/wp-admin/{$k}?page={$item[2]}";
} else {
$link = get_settings('siteurl') . "/wp-admin/{$item[2]}";
}
/* Windows installs may have backslashes instead of slashes in some paths, fix this */
$link = str_replace(chr(92),chr(92).chr(92),$link);
$altmenu[$k]['sub'][$item[2]]['url'] = $link;
// Is it current page ?
$class = '';
if ( (isset($plugin_page) && $plugin_page == $item[2] && $pagenow == $k) || (!isset($plugin_page) && $self == $item[2] ) ) $class=" class='current'";
if ($class) {
$altmenu[$k]['sub'][$item[2]]['class'] = $class;
$altmenu[$k]['class'] = $class;
}
// What's its name again ?
$altmenu[$k]['sub'][$item[2]]['name'] = $item[0];
}
}
}
// Uncomment to see how neat it is now !
/**
global $wpdb;
$wpdb->wp_ozh_adminmenu_neat_array = "