WordPress.org

Make WordPress Core

Opened 2 years ago

Closed 19 months ago

Last modified 19 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
Milestone: 3.5 Priority: normal
Severity: normal Version: 3.3.1
Component: Toolbar Keywords: has-patch dev-feedback
Focuses: 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 2 years ago.

Download all attachments as: .zip

Change History (5)

griffinjt2 years ago

comment:1 nacin19 months ago

  • 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.

comment:2 griffinjt19 months ago

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 19 months ago by griffinjt (next)

comment:3 nacin19 months ago

  • 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.

comment:4 nacin19 months ago

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

Note: See TracTickets for help on using tickets.