[wp-trac] [WordPress Trac] #29463: Add filter in WP_Nav_Menu_Widget
WordPress Trac
noreply at wordpress.org
Tue Sep 2 09:24:55 UTC 2014
#29463: Add filter in WP_Nav_Menu_Widget
-------------------------------+------------------------------
Reporter: cyman | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Widgets | Version: 3.0
Severity: normal | Resolution:
Keywords: reporter-feedback | Focuses: administration
-------------------------------+------------------------------
Changes (by johnbillion):
* keywords: => reporter-feedback
* focuses: administration, template => administration
* version: trunk => 3.0
Comment:
Thanks for the report cyman.
The `wp_nav_menu()` function contains a filter which gets applied to the
arguments for all nav menus
([https://developer.wordpress.org/reference/hooks/wp_nav_menu_args/ see
here]).
{{{
$args = apply_filters ( 'wp_nav_menu_args', array $args );
}}}
Is this filter sufficient for your use case? You can target the menu using
the `menu` parameter. Eg:
{{{
add_filter( 'wp_nav_menu_args', function( array $args ) {
if ( 'my_menu' == $args['menu'] ) {
// do something
}
} );
}}}
If this isn't sufficient, and you think we might need a more targeted
filter for the `WP_Nav_Menu_Widget`, then you can read up about Subversion
and creating a patch on [https://make.wordpress.org/core/handbook/svn/ the
SVN page of the WordPress handbook]. Once you've created a patch file you
can upload it to this ticket.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/29463#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list