Last active
April 10, 2019 21:47
-
-
Save campaignupgrade/ccc7f10b73fc69cd7472c3962db83a42 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class f6_dropdown_menu extends Walker_Nav_Menu { | |
// Add vertical menu class and submenu data attribute to sub menus | |
function start_lvl( &$output, $depth = 0, $args = array() ) { | |
$indent = str_repeat( "\t", $depth ); | |
$output .= "\n$indent<ul class=\"vertical menu dropdown\">\n"; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function primaryNavigation() { | |
if (has_nav_menu('primary_navigation')) { | |
return wp_nav_menu([ | |
'container' => false, | |
'menu' => __( 'Primary Navigation', 'sage' ), | |
'menu_class' => 'horizontal menu dropdown align-right', | |
'theme_location' => 'primary_navigation', | |
'items_wrap' => '<ul id="%1$s" class="%2$s" data-dropdown-menu>%3$s</ul>', | |
// Recommend setting this to false, but if you need a fallback.... | |
'fallback_cb' => false, | |
'walker' => new \f6_dropdown_menu() | |
]); | |
} | |
return '<span class="">Please select a Primary Menu</span>'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The first file, the walker class, adds css classes to the submenus.
The second file adds classes to the menu.
I'd like to rewrite the function as
function primaryNavigation( $menuclass $submenuclass )
and pass the params to the function and walker class respectively.