#13371 closed defect (bug) (fixed)
Nav menu items should be filterable, regardless of context
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Milestone: | 3.0 | Priority: | normal |
| Severity: | normal | Version: | 3.0 |
| Component: | Menus | Keywords: | menus, nav menus, has-patch |
| Focuses: | Cc: |
Description
It's kind of weird that in order for a plugin/theme to filter the nav menu items, the $args->context needs to be 'frontend'.
For example, since the $args object is passed through the wp_nav_menu_items filter, the user-defined filter can do the contextual checks. For instance ...
add_filter('wp_nav_menu_items', 'my_nav_menu_items_filter', 10, 2);
function my_nav_menu_items_filter($items, $args) {
if( $args->context != 'frontend' )
return $items;
// proceed with the filter
}
Plus, I can see plenty of reasons why a plugin/theme might want to filter the items regardless of context.
Either way, it should be up to the plugin/theme author, shouldn't it?
I've attached a patch.
Attachments (1)
Change History (5)
#2
in reply to:
↑ 1
@
16 years ago
Replying to nacin:
This is a bit of a rabbit hole. OTOH, since we're already giving them access via the wp_nav_menu filter, I'd rather not tie plugin authors' hands and force them to regex through HTML to do that they need.
My thoughts exactly. Seems like the only way to do it, if the context isn't 'frontend'.
This is a bit of a rabbit hole. OTOH, since we're already giving them access via the wp_nav_menu filter, I'd rather not tie plugin authors' hands and force them to regex through HTML to do that they need.