From 5ed9c32d49480ddb96de97b7e06ff03f70268a4c Mon Sep 17 00:00:00 2001 From: ryan Date: Fri, 24 Oct 2008 22:40:19 +0000 Subject: [PATCH] If parent uses admin.php, use admin.php for subs. fixes #7962 git-svn-id: http://svn.automattic.com/wordpress/trunk@9337 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/menu-header.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/wp-admin/menu-header.php b/wp-admin/menu-header.php index dbd9fcf867..a6714dd5a8 100644 --- a/wp-admin/menu-header.php +++ b/wp-admin/menu-header.php @@ -36,6 +36,7 @@ function _wp_menu_output( &$menu, &$submenu, $submenu_as_parent = true ) { $first = true; // 0 = name, 1 = capability, 2 = file, 3 = class, 4 = id, 5 = icon src foreach ( $menu as $key => $item ) { + $admin_is_parent = false; $class = array(); if ( $first ) { $class[] = 'wp-first-item'; @@ -66,13 +67,16 @@ function _wp_menu_output( &$menu, &$submenu, $submenu_as_parent = true ) { } elseif ( $submenu_as_parent && !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(WP_PLUGIN_DIR . "/{$submenu[$item[2]][0][2]}") || !empty($menu_hook)) + if ( file_exists(WP_PLUGIN_DIR . "/{$submenu[$item[2]][0][2]}") || !empty($menu_hook)) { + $admin_is_parent = true; echo "$img$toggle{$item[0]}"; - else + } else { echo "\n\t$img$toggle{$item[0]}"; + } } else if ( current_user_can($item[1]) ) { $menu_hook = get_plugin_page_hook($item[2], 'admin.php'); if ( file_exists(WP_PLUGIN_DIR . "/{$item[2]}") || !empty($menu_hook) ) { + $admin_is_parent = true; echo "\n\t$img$toggle{$item[0]}"; } else { echo "\n\t$img$toggle{$item[0]}"; @@ -106,7 +110,7 @@ function _wp_menu_output( &$menu, &$submenu, $submenu_as_parent = true ) { if ( file_exists(WP_PLUGIN_DIR . "/{$sub_item[2]}") || ! empty($menu_hook) ) { // If admin.php is the current page or if the parent exists as a file in the plugins or admin dir - $parent_exists = (file_exists(WP_PLUGIN_DIR . "/{$item[2]}") && !is_dir(WP_PLUGIN_DIR . "/{$item[2]}") ) || file_exists($item[2]); + $parent_exists = (!$admin_is_parent && file_exists(WP_PLUGIN_DIR . "/{$item[2]}") && !is_dir(WP_PLUGIN_DIR . "/{$item[2]}") ) || file_exists($item[2]); if ( $parent_exists ) echo "{$sub_item[0]}"; elseif ( 'admin.php' == $pagenow || !$parent_exists )