Skip to content

Instantly share code, notes, and snippets.

@campaignupgrade
Last active April 10, 2019 21:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save campaignupgrade/ccc7f10b73fc69cd7472c3962db83a42 to your computer and use it in GitHub Desktop.
Save campaignupgrade/ccc7f10b73fc69cd7472c3962db83a42 to your computer and use it in GitHub Desktop.
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";
}
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>';
}
@campaignupgrade
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment