From 684d85ff2fc116f62e6db0158346b92b1f66bc3d Mon Sep 17 00:00:00 2001 From: Andrew Nacin Date: Thu, 9 Dec 2010 04:02:37 +0000 Subject: [PATCH] Fix menu_page_url() for submenu pages attached to custom menu pages. props duck_, see #14159. git-svn-id: https://develop.svn.wordpress.org/trunk@16829 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-admin/includes/plugin.php | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/wp-admin/includes/plugin.php b/wp-admin/includes/plugin.php index e0c758dada..5310558744 100644 --- a/wp-admin/includes/plugin.php +++ b/wp-admin/includes/plugin.php @@ -1008,7 +1008,7 @@ function add_submenu_page( $parent_slug, $page_title, $menu_title, $capability, /** * Add sub menu page to the tools main menu. -* + * * This function takes a capability which will be used to determine whether * or not a page is included in the menu. * @@ -1027,7 +1027,7 @@ function add_management_page( $page_title, $menu_title, $capability, $menu_slug, /** * Add sub menu page to the options main menu. -* + * * This function takes a capability which will be used to determine whether * or not a page is included in the menu. * @@ -1046,7 +1046,7 @@ function add_options_page( $page_title, $menu_title, $capability, $menu_slug, $f /** * Add sub menu page to the themes main menu. -* + * * This function takes a capability which will be used to determine whether * or not a page is included in the menu. * @@ -1065,7 +1065,7 @@ function add_theme_page( $page_title, $menu_title, $capability, $menu_slug, $fun /** * Add sub menu page to the plugins main menu. -* + * * This function takes a capability which will be used to determine whether * or not a page is included in the menu. * @@ -1084,7 +1084,7 @@ function add_plugins_page( $page_title, $menu_title, $capability, $menu_slug, $f /** * Add sub menu page to the Users/Profile main menu. -* + * * This function takes a capability which will be used to determine whether * or not a page is included in the menu. * @@ -1106,7 +1106,7 @@ function add_users_page( $page_title, $menu_title, $capability, $menu_slug, $fun } /** * Add sub menu page to the Dashboard main menu. -* + * * This function takes a capability which will be used to determine whether * or not a page is included in the menu. * @@ -1125,7 +1125,7 @@ function add_dashboard_page( $page_title, $menu_title, $capability, $menu_slug, /** * Add sub menu page to the posts main menu. -* + * * This function takes a capability which will be used to determine whether * or not a page is included in the menu. * @@ -1144,7 +1144,7 @@ function add_posts_page( $page_title, $menu_title, $capability, $menu_slug, $fun /** * Add sub menu page to the media main menu. -* + * * This function takes a capability which will be used to determine whether * or not a page is included in the menu. * @@ -1163,7 +1163,7 @@ function add_media_page( $page_title, $menu_title, $capability, $menu_slug, $fun /** * Add sub menu page to the links main menu. -* + * * This function takes a capability which will be used to determine whether * or not a page is included in the menu. * @@ -1182,7 +1182,7 @@ function add_links_page( $page_title, $menu_title, $capability, $menu_slug, $fun /** * Add sub menu page to the pages main menu. -* + * * This function takes a capability which will be used to determine whether * or not a page is included in the menu. * @@ -1201,7 +1201,7 @@ function add_pages_page( $page_title, $menu_title, $capability, $menu_slug, $fun /** * Add sub menu page to the comments main menu. -* + * * This function takes a capability which will be used to determine whether * or not a page is included in the menu. * @@ -1280,10 +1280,11 @@ function menu_page_url($menu_slug, $echo = true) { global $_parent_pages; if ( isset( $_parent_pages[$menu_slug] ) ) { - if ( $_parent_pages[$menu_slug] ) { - $url = admin_url( add_query_arg( 'page', $menu_slug, $_parent_pages[$menu_slug] ) ); + $parent_slug = $_parent_pages[$menu_slug]; + if ( $parent_slug && ! isset( $_parent_pages[$parent_slug] ) ) { + $url = admin_url( add_query_arg( 'page', $menu_slug, $parent_slug ) ); } else { - $url = admin_url('admin.php?page=' . $menu_slug); + $url = admin_url( 'admin.php?page=' . $menu_slug ); } } else { $url = ''; @@ -1694,4 +1695,4 @@ function settings_fields($option_group) { wp_nonce_field("$option_group-options"); } -?> \ No newline at end of file +?>