Make WordPress Core

Opened 14 years ago

Closed 14 years ago

Last modified 14 years ago

#15404 closed defect (bug) (wontfix)

Allow to target the different list items via CSS in the Admin Bar

Reported by: defries's profile defries Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.1
Component: Administration Keywords: has-patch
Focuses: Cc:

Description

For the My Site menu in the Admin Bar there's no way currently to remove certain list items of the specific site.

If you have more than 20 sites in the dropdown you would have to manually look up 20 css classes to target the list items. For instance, if you don't want your visitor to directly go to the Dashboard you would need 20 css statements set to display:none.

Via a simple CSS change one would be able to target a specific list item via a display:none statement.

Attachments (3)

admin_bar_patch.patch (2.2 KB) - added by defries 14 years ago.
15404.diff (2.3 KB) - added by nacin 14 years ago.
15404.patch (2.4 KB) - added by ocean90 14 years ago.

Download all attachments as: .zip

Change History (17)

#1 follow-up: @nacin
14 years ago

  • Component changed from Accessibility to Administration
  • Milestone changed from Awaiting Review to 3.1

The CSS change looks fine, that said, there are remove_node and remove_menu methods for the WP_Admin_Bar class, that ideally you would then leverage to remove specific ones.

Obviously you also will want to make sure that you are actually denying users access to these pages via capability checks, unless of course this is only about usability and simplicity, versus access.

#2 in reply to: ↑ 1 @defries
14 years ago

Replying to nacin:

The CSS change looks fine, that said, there are remove_node and remove_menu methods for the WP_Admin_Bar class, that ideally you would then leverage to remove specific ones.

Obviously you also will want to make sure that you are actually denying users access to these pages via capability checks, unless of course this is only about usability and simplicity, versus access.

It's more about usability and simplicity. Just to have some easy control over what is shown in that particular menu.

#3 follow-up: @nacin
14 years ago

  • Keywords needs-patch added; admin bar removed

Looking at the code some more, the add_menu() method wants an 'id' to be a sanitized value. We shouldn't overload it.

That's fine, because add_menu also takes a 'meta' argument, which can take the form of array( 'class' => 'more classes here' ).

#4 follow-up: @nacin
14 years ago

Those additional classes should probably be namespaced the way the ids are. I'd suggest ab-blog-, i.e. ab-blog-dashboard.

#5 in reply to: ↑ 4 @defries
14 years ago

Replying to nacin:

Those additional classes should probably be namespaced the way the ids are. I'd suggest ab-blog-, i.e. ab-blog-dashboard.

With the dash con-catting it to one class there's no way to target them. Or am I missing the point?

#6 in reply to: ↑ 3 @defries
14 years ago

Replying to nacin:

That's fine, because add_menu also takes a 'meta' argument, which can take the form of array( 'class' => 'more classes here' ).

I see that now too, no clue how to do that, but I understand what you mean.
Basically I was looking for an easy CSS hack to change for instance a list item to display:none, but also to change a background and/or color and such.

#7 @defries
14 years ago

  • Cc defries added

@nacin
14 years ago

#8 @nacin
14 years ago

Patch, untested, attached.

#9 @garyc40
14 years ago

  • Keywords has-patch needs-testing added; needs-patch removed

#10 @johnpbloch
14 years ago

  • Keywords needs-refresh added; needs-testing removed

These patches no longer apply cleanly because the surrounding code has changed.

@ocean90
14 years ago

#11 @ocean90
14 years ago

  • Keywords needs-refresh removed

I have nacin's updated. It's a good idea but we shouldn't change the ID because then we have duplicate IDs which wouldn't be valid.

#12 @nacin
14 years ago

Devil's advocate: What's the use case here? Instead of display:none, why not loop through and individually remove those nodes in PHP?

#13 @nacin
14 years ago

  • Milestone 3.1 deleted
  • Resolution set to wontfix
  • Status changed from new to closed

#14 @nacin
14 years ago

You can also use attribute selectors here, specifically [att$=val].

Note: See TracTickets for help on using tickets.