Last active

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

Give wp_nav_menu() a different class then default. In some cases themes style on the class 'menu'. What result in possible weird behavior.

View gist:4448611
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
<?php
class Nav_Menu_Widget_Classname {
public function __construct() {
add_action( 'widget_display_callback', array( $this, 'menu_different_class' ), 10, 2 );
}
public function menu_different_class( $settings, $widget ) {
if( $widget instanceof WP_Nav_Menu_Widget )
add_filter( 'wp_nav_menu_args', array( $this, 'wp_nav_menu_args' ) );
return $settings;
}
public function wp_nav_menu_args( $args ) {
remove_filter( 'wp_nav_menu_args', array( $this, 'wp_nav_menu_args' ) );
if( 'menu' == $args['menu_class'] )
$args['menu_class'] = apply_filters( 'nav_menu_widget_class', 'menu_widget');
return $args;
}
}
$GLOBALS['nav_menu_widget_classname'] = new Nav_Menu_Widget_Classname();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.