Opened 10 years ago
Closed 10 years ago
#33944 closed enhancement (fixed)
Add parameters to widget_nav_menu_args filter
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 4.4 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Widgets | Keywords: | has-patch |
Focuses: | Cc: |
Description
I want add parameters to widget_nav_menu_args filter so you can easier override the navigation options by widget basis.
Attachments (3)
Change History (16)
#2
@
10 years ago
- Milestone changed from Awaiting Review to 4.4
- Owner set to DrewAPicture
- Status changed from new to assigned
#5
@
10 years ago
See 33944.2.patch with $this
added.
#6
@
10 years ago
After considering 33944.2.patch a little bit, let's omit the fifth parameter. I don't see the merit in passing either the $this
instance or the id_base
for that matter. id_base
is always going to be nav_menu
for widgets of this type.
We can always add $this
later if there's a demonstrated need.
Side note: I'm also having a bit of "buyer's remorse" on adding $nav_menu
as a parameter in the first place when this hook was introduced, mostly because it's already passed as part of the $nav_menu_args
array.
This ticket was mentioned in Slack in #core by drew. View the logs.
10 years ago
#8
@
10 years ago
After talking to @johnbillion in Slack (linked above) about it a little bit, we decided the value in filtering by the widget title (which is afforded by passing $instance
) is low, since the menu ID is already available via both the $nav_menu_args
and $nav_menu
parameters.
Therefore, passing $this
provides the most value in directly targeting widget instances.
#9
@
10 years ago
- Keywords reporter-feedback added
@walterbarcelos: Can you provide a use-case for why you would want $instance
passed to this hook?
#10
@
10 years ago
- Milestone changed from 4.4 to Awaiting Review
Waiting on reporter feedback from @walterbarcelos.
#11
@
10 years ago
- Keywords reporter-feedback removed
Hi @DrewAPicture.
Sorry for the delay and thank you very much for reviewing this patch.
After reading your comments I think you're totally right. I only need the $instance
object to do what I'd like to do.
The idea is to add an action to in_widget_form
, detect if it's a custom menu widget and if so, display a dropdown so the user can select any of the walkers I have implemented. Pretty much like the page template selection on the page's form.
I need $instance
because when I filter widget_nav_menu_args
I need to get the value selected on the dropdown, which is accessible through the widget settings, in order to create the walker object and assign it to $nav_menu_args['walker']
.
Please let me know if you need more info.
Thanks,
Walter.
I think I'd much prefer to pass the entire
WP_Nav_Menu_Widget
instance instead of just theid_base
value. That said, I'm not super excited about passing 5 parameters to this filter.