I am looking to implement a navigation menu using the Bootstrap4 navigation styling. I have the navigation being outputted but I want to edit the walker class to fit my current Bootstrap4 markup but I can’t find where the walker class file lives?
I created a file in the
/src
directory called
navigation.php
which contains this code
<?php
namespace App;
// Add to functions, or to a dedicated controllers file
// Needs a global body class to hook into
/**
* Navigation arguments
*
* @param $data
*
* @return mixed
*/
function navControl( $data ) {
// Pass the walker class to a var, so it
// doesn't instantiate here.
$bootstrapWalker = 'wp_bootstrap_navwalker';
// Main Nav
$mainNavArgs = [
'theme_location' => 'primary_navigation',
'walker' => new $bootstrapWalker,
'menu_class' => 'navbar-nav mr-auto'
];
$data['mainNavArgs'] = $mainNavArgs;
return $data;
}
add_filter( 'sage/template/global/data', 'App\\navControl' );
I put this snippet in the helpers.php file
add_filter( 'body_class', function( $classes ) {
return array_merge( $classes, array( 'global' ) );
} );
and finally in my header.blade.php file I have
@if (has_nav_menu('primary_navigation'))
{!! wp_nav_menu($mainNavArgs) !!}
@endif
I am wondering where the walker class is being referenced from?