When adding a post of a post type whose menu item is in a submenu, highlight the correct menu item. props mordauk, markjaquith. fixes #24137.

Built from https://develop.svn.wordpress.org/trunk@29300


git-svn-id: http://core.svn.wordpress.org/trunk@29082 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Helen Hou-Sandí 2014-07-25 15:26:18 +00:00
parent 0e4c8b2b0c
commit 6513808db0
1 changed files with 10 additions and 2 deletions

View File

@ -28,8 +28,16 @@ if ( 'post' == $post_type ) {
$submenu_file = "post-new.php?post_type=$post_type";
if ( isset( $post_type_object ) && $post_type_object->show_in_menu && $post_type_object->show_in_menu !== true ) {
$parent_file = $post_type_object->show_in_menu;
if ( ! isset( $_registered_pages[ get_plugin_page_hookname( "post-new.php?post_type=$post_type", $post_type_object->show_in_menu ) ] ) )
$submenu_file = $parent_file;
// What if there isn't a post-new.php item for this post type?
if ( ! isset( $_registered_pages[ get_plugin_page_hookname( "post-new.php?post_type=$post_type", $post_type_object->show_in_menu ) ] ) ) {
if ( isset( $_registered_pages[ get_plugin_page_hookname( "edit.php?post_type=$post_type", $post_type_object->show_in_menu ) ] ) ) {
// Fall back to edit.php for that post type, if it exists
$submenu_file = "edit.php?post_type=$post_type";
} else {
// Otherwise, give up and highlight the parent
$submenu_file = $parent_file;
}
}
} else {
$parent_file = "edit.php?post_type=$post_type";
}