From 59cec2e2ff80de74649ced3813afac6f671fab9c Mon Sep 17 00:00:00 2001 From: Helen Hou-Sandi Date: Fri, 25 Jul 2014 15:25:20 +0000 Subject: [PATCH] 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. git-svn-id: https://develop.svn.wordpress.org/trunk@29300 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/post-new.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/wp-admin/post-new.php b/src/wp-admin/post-new.php index 79896c3b78..bfdffaf3a3 100644 --- a/src/wp-admin/post-new.php +++ b/src/wp-admin/post-new.php @@ -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"; }