Opened 13 years ago
Closed 13 years ago
#19125 closed defect (bug) (fixed)
CPT as a submenu item does not get the correct classes when adding new
Reported by: | helenyhou | Owned by: | nacin |
---|---|---|---|
Milestone: | 3.3 | Priority: | low |
Severity: | normal | Version: | 3.3 |
Component: | Posts, Post Types | Keywords: | has-patch |
Focuses: | Cc: |
Description
If you register a post type as a submenu item, the parent item does not get the appropriate classes when adding a new item, nor does the submenu item itself. This causes the menu to not be expanded. It is fine when on the list table or editing an existing item, and when the CPT has its own menu item. It seems that $typenow
is not being set somehow in just this case.
Attachments (2)
Change History (15)
#2
follow-up:
↓ 3
@
13 years ago
It should be noted that with 19125.diff, there won't be any submenu added, unless you call add_submenu_page() manually for the post-new.php?post_type=$post_type file.
Or, if you want the main submenu selected, you'd want $submenu_file to equal that edit.php page.
Because this wasn't implemented originally, I'd be somewhat hesitant to do it now. Then again, I think it can be done in a backwards compatible way, as any developer wanting to customize this would set $submenu_file and $parent_file later on. (Or we could wrap it in an isset()).
#3
in reply to:
↑ 2
@
13 years ago
Replying to nacin:
It should be noted that with 19125.diff, there won't be any submenu added, unless you call add_submenu_page() manually for the post-new.php?post_type=$post_type file.
Not quite sure I understand what you mean by this?
Because this wasn't implemented originally, I'd be somewhat hesitant to do it now.
I think it just became more noticeable because menus do not stay expanded anymore, so it's less clear where you are in the admin. You are right, though - it doesn't work in 3.2.1 (or previous) either.
#4
@
13 years ago
Should have said:
It should be noted that with 19125.diff, there won't be any submenu highlighted, unless you call add_submenu_page() manually for the post-new.php?post_type=$post_type file (and give it something to highlight).
#6
@
13 years ago
I want to fix $parent_file on post-new.php. The $submenu_file is a separate fix we could probably go through with -- especially since if a plugin is correcting it, they'll just override the value anyway -- but it could wait.
#11
@
13 years ago
- Component changed from General to Post Types
Ideally, $submenu_file should be set to post-new.php?post_type=$post_type if that's been added, and otherwise be set to edit.php?post_type=$post_type. Since admin_menu has already been fired, there's probably the ability to check for this in a semi-sane way. Here's a patch for review.
It's $parent_file not being set properly. I was playing with this last week, but I was struggling to ascertain whether it was a valid bug fix. Patch incoming that *would* fix it.