#19136 closed defect (bug) (fixed)
Secondary items should be a flag for the admin bar
Reported by: | nacin | Owned by: | koopersmith |
---|---|---|---|
Milestone: | 3.3 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Toolbar | Keywords: | |
Focuses: | Cc: |
Description
Follow-up to #18197, 18197#comment:64, [19120], and an IRC discussion.
The current setup is clever, but doesn't scale and isn't flexible (for plugins, especially).
Attachments (4)
Change History (17)
#2
@
13 years ago
Also test with 18197#comment:122.
#5
@
13 years ago
Patch builds secondary menus into the core admin bar class. Late binding allows items to be registered to either the primary or secondary menu through the use of the boolean secondary parameter (in add_menu/add_node).
#8
@
13 years ago
- Resolution fixed deleted
- Status changed from closed to reopened
There are a bunch of issues with the secondary flag. The main problem is that in the case of a secondary menu, setting a flag on each item is far worse than having one common parent.
A good example use case is BuddyPress — BP adds a top level admin bar menu, and provides plugins with a variable to implement their own submenus. If BP wanted to change its menu to become a secondary component of another menu, it would have to update every submenu item with the secondary flag (instead of just changing the parent). The larger issue here is plugins: every single plugin that added a BuddyPress admin submenu would have to update their items with the secondary flag.
The ideal solution is using groups, which would allow us to split submenus into sections. In the case of the BuddyPress menu, it could be converted to a group and be easily styled. No plugins would have to be updated, as the parent ID would still work.
#9
@
13 years ago
I was with the impression that the secondary flag would be only for second level menus, i.e. all "top > submenu.secondary" will behave exactly like "top > submenu" except they will be outputted at the bottom and have slightly different styling. All children of submenu.secondary would inherit the styling.
Not sure another UL was needed there at all. Seems to just make things complicated and more fragile.
So the secondary flag would be valid only on the first level of submenus "top > submenu", and ignored on any sub-submenus, etc. So if a plugin decides to move it's menu and adds the flag, all children would inherit the styling, no additional flags needed.
#10
@
13 years ago
Replying to azaozz:
I was with the impression that the secondary flag would be only for second level menus, i.e. all "top > submenu.secondary" will behave exactly like "top > submenu" except they will be outputted at the bottom and have slightly different styling. All children of submenu.secondary would inherit the styling.
This is still how it works with groups3.diff except "levels" are "groups" and there is no upper limit to the number of groupings. Previous to this patch, there were only two "types" of menu stylings, and no way to reliably group them by ID. See below:
Not sure another UL was needed there at all. Seems to just make things complicated and more fragile.
If it's the UL I think you're seeing, it is needed to maintain the styling and parentage associated with groups.
So the secondary flag would be valid only on the first level of submenus "top > submenu", and ignored on any sub-submenus, etc. So if a plugin decides to move it's menu and adds the flag, all children would inherit the styling, no additional flags needed.
The "secondary flag" is a poor way to architect this, and actually perpetuates the problem you mention here. It limits any ability to reliably move groups of items in the future, and is a work-around approach similar to the rabbit-hole of the current main admin-nav.
Implementing "true" groups rather than mimic them (numerically or otherwise) allows us to designate physical menu groups with valid and unique identifiers to *know* that a group of items always contain its children regardless of where it might ever be relocated in the future, up to and including anything that a plugin might choose to add anywhere in the binding process.
After review, this patch is actually considerably smaller than it looks, and touches very few guts of the core API itself.
Also fixes 18197#comment:88.