Opened 13 months ago

Closed 8 months ago

Last modified 8 months ago

#20504 closed defect (bug) (fixed)

show_in_admin_bar should affect the "View $post_type" link in the admin bar

Reported by: griffinjt Owned by: nacin
Priority: normal Milestone: 3.5
Component: Toolbar Version: 3.3.1
Severity: normal Keywords: has-patch dev-feedback
Cc:

Description

When I set the 'show_in_admin_bar' post type parameter to false, I expect it to remove all instances of the post type from the admin bar view. However, it only removes the Add New post type link from the admin bar, but as soon as you go to edit the post type, you are given a link to View the post type in the admin bar.

In wp-includes/admin-bar.php on line 485, it checks for the parameter for adding the new link:

$cpts = (array) get_post_types( array( 'show_in_admin_bar' => true ), 'objects' );

This check can easily be made for the View post type link as well. I've attached a patch that checks for it. Since show_in_admin_bar defaults to true, it won't affect the current setup. It will only hide the link from the menu if you specify show_in_admin_bar to false.

If this isn't the expected way of doing things, then there should be a filter or some other post type arg that will let you hide this link as well.

Attachments (1)

admin-bar-patch.diff (585 bytes) - added by griffinjt 13 months ago.

Download all attachments as: .zip

Change History (5)

  • Milestone changed from Awaiting Review to 3.5

Okay. I'd be more interested in hiding the edit link but I understand this as well.

I'd be fine with that as well. It's just misleading when the set it to false and yet something about the CPT still appears in the bar.

Version 0, edited 8 months ago by griffinjt (next)
  • Owner set to nacin
  • Resolution set to fixed
  • Status changed from new to closed

In [21957]:

Check a post type's show_in_admin_bar property for 'View' and 'Edit' object links. Previously show_in_admin_bar was only checked for the add new menu. fixes #20504.

For [21957], props griffinjt — sorry about that.

Note: See TracTickets for help on using tickets.