Fix submenus for post types. Props TobiasBg. see #12453

git-svn-id: http://svn.automattic.com/wordpress/trunk@13579 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan
2010-03-04 00:15:55 +00:00
parent 779a3e76dd
commit aa47e83dee
5 changed files with 52 additions and 23 deletions

View File

@@ -72,17 +72,26 @@ wp_enqueue_script( 'jquery-color' );
$editing = false;
if (isset($_GET['page'])) {
if ( isset($_GET['page']) ) {
$plugin_page = stripslashes($_GET['page']);
$plugin_page = plugin_basename($plugin_page);
}
if ( isset($_GET['post_type']) )
$typenow = sanitize_user($_GET['post_type'], true);
else
$typenow = '';
require(ABSPATH . 'wp-admin/menu.php');
do_action('admin_init');
if (isset($plugin_page) ) {
if ( ! $page_hook = get_plugin_page_hook($plugin_page, $pagenow) ) {
if ( isset($plugin_page) ) {
if ( !empty($typenow) )
$the_parent = $pagenow . '?post_type=' . $typenow;
else
$the_parent = $pagenow;
if ( ! $page_hook = get_plugin_page_hook($plugin_page, $the_parent) ) {
$page_hook = get_plugin_page_hook($plugin_page, $plugin_page);
// backwards compatibility for plugins using add_management_page
if ( empty( $page_hook ) && 'edit.php' == $pagenow && '' != get_plugin_page_hook($plugin_page, 'tools.php') ) {
@@ -95,6 +104,7 @@ if (isset($plugin_page) ) {
exit;
}
}
unset($the_parent);
}
$hook_suffix = '';
@@ -105,12 +115,6 @@ else if ( isset($plugin_page) )
else if ( isset($pagenow) )
$hook_suffix = $pagenow;
if ( isset($_GET['post_type']) )
$typenow = $_GET['post_type'];
else
$typenow = '';
// @todo validate typenow against post types.
set_current_screen();
// Handle plugin admin pages.