Make WordPress Core

Opened 10 years ago

Closed 8 years ago

Last modified 8 years ago

#29417 closed enhancement (fixed)

More semantic filter for item labels in Walker_Nav_Menu

Reported by: danielbachhuber's profile danielbachhuber Owned by: drewapicture's profile 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)

29417.patch (506 bytes) - added by bjornjohansen 9 years ago.
Added nav_menu_item_args filter
29417.diff (605 bytes) - added by wonderboymusic 8 years ago.

Download all attachments as: .zip

Change History (14)

@bjornjohansen
9 years ago

Added nav_menu_item_args filter

#1 @bjornjohansen
9 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.

Last edited 9 years ago by bjornjohansen (previous) (diff)

#2 follow-up: @kpdesign
9 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 @bjornjohansen
9 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?

#4 @kpdesign
9 years ago

Yes, since 4.1 is the current release cycle, use @since 4.1.0 in the doc block.

#5 @DrewAPicture
9 years ago

  • Owner set to bjornjohansen
  • Status changed from new to assigned

@wonderboymusic
8 years ago

#6 @wonderboymusic
8 years ago

  • Milestone changed from Future Release to 4.4
  • Owner changed from bjornjohansen to DrewAPicture

#7 @wonderboymusic
8 years ago

  • Resolution set to fixed
  • Status changed from assigned to closed

In 34471:

Nav Menus: Add a 'nav_menu_item_args' filter to Walker_Nav_Menu::start_el().

Props bjornjohansen.
Fixes #29417.

#8 @DrewAPicture
8 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.

#9 @DrewAPicture
8 years ago

  • Resolution set to fixed
  • Status changed from reopened to closed

In 34481:

Docs: Add a summary to the hook doc for the nav_menu_item_args filter, introduced in [34471].

Fixes #29417.

#10 @johnbillion
8 years ago

  • Keywords needs-patch added; good-first-bug has-patch needs-docs removed
  • Resolution fixed deleted
  • Status changed from closed to reopened

This filter should receive the $depth parameter too, so it more closely matches all the other filters in this class.

#11 @johnbillion
8 years ago

  • Resolution set to fixed
  • Status changed from reopened to closed

In 34507:

Add $depth as a parameter in the nav_menu_item_args filter.

Fixes #29417

#12 @johnbillion
8 years ago

  • Keywords needs-patch removed
Note: See TracTickets for help on using tickets.