Opened 14 years ago
Closed 14 years ago
#16015 closed defect (bug) (fixed)
show_in_menu has some menu selection issues
Reported by: | nacin | Owned by: | duck_ |
---|---|---|---|
Milestone: | 3.1 | Priority: | normal |
Severity: | normal | Version: | 3.1 |
Component: | Posts, Post Types | Keywords: | has-patch commit |
Focuses: | Cc: |
Description
I have an employees post type with show_in_menu set to 'users.php'. This hides the Add New menu, as expected, and nests "Employees" under Users.
post-new.php?post_type=employees doesn't trigger any item in the menu from being selected. This is expected.
However, post.php?post=100&action=edit does show the Employees submenu as selected -- but not the rest of the menu. This is unexpected. The entire menu should be selected.
(Think of it as consistent with Posts, only lacking an "Add New" submenu -- that's the responsibility of the developer.)
Attachments (2)
Change History (10)
#1
@
14 years ago
- Keywords has-patch needs-testing added
My patch is not very elegant. It loops through the submenu items to check if $submenu_file == $sub_item[2]
. This is the same check that happens way below, where 'current'
class is attached to current sub-item.
I kind of dislike it, but it works.
Any idea how to fix this without having to refactor the way _wp_menu_output
works?
#2
@
14 years ago
Set the $parent_file based on show_in_menu in post.php. Not tested every usage of $parent_file to test this, but all menus seem to function correctly. Note that for edit.php?post_type=bar and edit.php?post_status=foo&post_type=bar the $parent_file is set to the show_in_menu var via get_admin_parent_page().
I do think that _wp_menu_output needs to be revisited in the future, I have a patch somewhere with some optimizations but never got round to testing properly and uploading.
#6
@
14 years ago
To reproduce:
add_action( 'init', 'ticket_16015' ); function ticket_16015() { register_post_type( 'employees', array( 'labels' => array( 'name' => __( 'Employees' ), 'singular_name' => __( 'Employees' ), ), 'public' => true, 'show_ui' => true, 'show_in_menu' => 'users.php', 'has_archive' => true, 'rewrite' => true, 'supports' => array( 'title' ,'thumbnail', 'excerpt', 'editor', 'custom-fields' ), ) ); }
there's a patch for that