Update 30.6.2019
Ah, now I think understand what is going on with the code and the warning. I think it is literally trying to find a class named "new wp_bootstrap_navwalker()".
In my local sandbox WP I got the shortcode working after I changed 'walker' => $walker,
to 'walker' => new $walker,
. I also changed the walker parameter from walker="new wp_bootstrap_navwalker()"
to walker="wp_bootstrap_navwalker"
EDIT
'walker' => new $walker,
should probably be something like 'walker' => $walker ? new $walker : '',
to avoid errors, if $walker
is null
.
If you're getting a "class not found" warning, then maybe the class file hasn't just been included/loaded when you're trying to instantiate the class. So perhaps you could try requiring/including the class file inside your shortcode function when it's needed. Something along these lines,
function se_menu_shortcode( $atts, $content = null ) {
// extract
if ( ! class_exists('wp_bootstrap_navwalker') ) {
require_once 'path/to/class/definition/file.php';
}
// return
}
Or maybe you could try writing an autoloader for handling the requiring/including of classes automatically, https://www.php.net/manual/en/function.spl-autoload-register.php