widget_nav_menu_args

Filters the arguments for the Custom Menu widget.

Description

apply_filters( 'widget_nav_menu_args', (array) $nav_menu_args, (WP_Term) $nav_menu, (array) $args, (array) $instance ); 

Parameters (4)

0. $nav_menu_args (array)
1. $nav_menu (WP_Term)
Nav menu object for the current menu.
2. $args (array)
Display arguments for the current widget.
3. $instance (array)
Array of settings for the current widget.

Usage

To run the hook, copy the example below.
  1. $nav_menu_args = apply_filters( 'widget_nav_menu_args', $nav_menu_args, $nav_menu, $args, $instance ); 
  2.  
  3. if ( !empty( $nav_menu_args ) ) { 
  4.  
  5. // everything has led up to this point... 
  6.  
  7.  
The following example is for adding a hook callback.
  1. // define the widget_nav_menu_args callback 
  2. function filter_widget_nav_menu_args( $nav_menu_args, $nav_menu, $args, $instance ) { 
  3. // make filter magic happen here... 
  4. return $nav_menu_args
  5. }; 
  6.  
  7. // add the filter 
  8. add_filter( 'widget_nav_menu_args', 'filter_widget_nav_menu_args', 10, 4 ); 
To remove a hook callback, use the example below.
  1. // remove the filter 
  2. remove_filter( 'widget_nav_menu_args', 'filter_widget_nav_menu_args', 10, 4 ); 

Defined (1)

The filter is defined in the following location(s).

/wp-includes/widgets/class-wp-nav-menu-widget.php  
  1. wp_nav_menu( apply_filters( 'widget_nav_menu_args', $nav_menu_args, $nav_menu, $args, $instance ) );