#29417 closed enhancement (fixed)
More semantic filter for item labels in Walker_Nav_Menu
Reported by: | danielbachhuber | Owned by: | DrewAPicture |
---|---|---|---|
Milestone: | 4.4 | Priority: | normal |
Severity: | normal | Version: | 4.0 |
Component: | Menus | Keywords: | |
Focuses: | Cc: |
Description
Walker_Nav_Menu
has a nice nav_menu_link_attributes
filter for modifying the attributes of a nav menu item. However, it applies the_title
for the label of the item, and only supplies the value and the ID of the nav menu item.
This makes it difficult to target when you only want to filter the label of the item. It would be nice to have a more semantic filter which supplied the full $item
and $args
.
My use case: I'm adding the HTML for FontAwesome icons when certain conditions are met.
Attachments (2)
Change History (14)
#1
@
10 years ago
- Keywords has-patch added; needs-patch removed
I added a filter, nav_menu_item_args, on the entire $args object so all the before/after/link_before/link_after properties can be modified, covering your use case. I added it before any use of $args, in case one might want to modify it for the other uses in the function as well.
#2
follow-up:
↓ 3
@
10 years ago
- Keywords needs-docs added
- Version set to 4.0
Thanks for the patch bjornjohansen!
The new filter will also need hook documentation.
Could you add that, and submit a new patch please?
#3
in reply to:
↑ 2
@
10 years ago
Replying to kpdesign:
Thanks for the patch bjornjohansen!
The new filter will also need hook documentation.
Could you add that, and submit a new patch please?
Thank you for the feedback, Kim. What should I use for @since? Should I be bold and set it to 4.1?
#6
@
9 years ago
- Milestone changed from Future Release to 4.4
- Owner changed from bjornjohansen to DrewAPicture
#8
@
9 years ago
- Resolution fixed deleted
- Status changed from closed to reopened
- Type changed from defect (bug) to enhancement
The new filter doesn't have a summary or a description.
Added nav_menu_item_args filter