Big changes on the road to 3.0
Introduction
I have been blown away with the popularity of wp-bootstrap-navwalker and the people contributing to the project. Originally, wp-bootstrap-navwalker was built to serve my specific development needs and solve the simple problem of adding Bootstrap menus to WordPress.
As usage grows, so do the feature requests. To this point I have been reluctant to add additional features in an effort to keep things simple but I do think there is value in creating so complimentary add-ons to introduce more features. To achieve this I will be doing a complete rewrite.
The Plan
The plan is to create a modular walker framework that achieves the base functionality needed to implement Bootstrap 3.0 menus with extensibility to create add-on modules.
The add-on modules will be disabled by default and can be turned on by calling a public function similar to this:
if ( class_exists( 'WP_Bootstrap_Navwalker' ) ) {
WP_Bootstrap_Navwalker::add_addon_support( array(
'multi-level-dropdown',
'nav-list' )
);
}
This way we avoid loading additional bloat into our sites while adding additional featured to the mix. Right away I see addons for multi level dropdowns, and abstracting the glyphicons functionality to an add-on aswell.
Two Pronged Solution
The ideal situation is to develop this as a drop in library for theme developers to integrate into their theme or framework. Aswell as a plugin where you can turn on and off individual framework options.
The beauty of taking the time to also create a plugin is this will also give us utility classes needed to easily add the framework options to our themes as well.
Technical Considerations
Ideally this would be achieved while adding the least additional HTTP requests as possible. Understanding that some add-ons may require additional .less & .js files I think it is important to compile and minify all of out resources into single .css & .js files.
This is a large consideration that may be difficult to achieve, although with libraries like Grunt this may be possible. I think its worth taking a look at and may be a plugin of its own. I would love a plugin that would take all of the .less, .css & .js files from my theme/plugins and package and minify them nicely.
Yes, this would be beautiful.
if ( class_exists( 'Gruntify' ) ) {
Gruntify::add_less( array(
'../less/style.less' )
);
Gruntify::add_js( array(
'../js/awesomeness.js' )
);
} else {
// Enqueue normally
}
Feedback
I would love to know what you all think about this direction.
Especially you amazing contributors: @claudiosmweb @mindctrl @pattonwebz @cvrebert @mafuba @wboptimise @mharis
I really enjoyed the idea. We can also take advantage and use filters and actions to facilitate this.
Sounds like an awesome idea, man. So is there any progress with it yet? I'm itching to get a glance at the code to see the direction your taking with this.
Also what kind of other features have been requested?
I'm totally up for helping out any way I can - even if it's just testing till I can break it haha! - but I'd love to get more involved in the development process as this grows.
I like where you're going with this. The modular idea is interesting. How do you see the walker callback working in wp_nav_menu to let it know which kind of nav you want for that location? Something like 'walker' => 'wp_bootstrap_navwalker::nav-list'?
The beauty of taking the time to also create a plugin is this will also give us utility classes needed to easily add the framework options to our themes as well.
I didn't quite understand what you mean here.
Understanding that some add-ons may require additional .less & .js files I think it is important to compile and minify all of out resources into single .css & .js files.
That's a good idea, but I wonder if it would conflict with other solutions that do this. Dependency Minification is a cool plugin I recently came across. Other caching solutions concat and minify too.
I'm glad you all like the idea.
@claudiosmweb I'm glad you like the idea, and that was the route I was hoping to go.
@pattonwebz No progress yet, just planning at this point. I hope to start sometime this week. As for features theres nothing really on my radar right now except for multilevel, but I think this might be a great way to implement the button walker I was talking about a while back, a new way of doing glyphicons, and possibly implementing my list nav walker as well.
@mindctrl That is a great question. Your suggestion may be the solution, but after giving it some thought I think it may be best to handle feature assignment form the class and define the nemu and its features via a function the hooks into the class.
Something like this maybe as there may be multiple add-ons you want to load witho with one menu. (just brainstorming)
if ( class_exists( 'WP_Bootstrap_Navwalker' ) ) {
function wp_bootstrap_navwalker_setup() {
add_wp_bootstrap_menu( 'primary', array(
'glyphcions',
'nav-list' )
);
add_wp_bootstrap_menu( 'footer', array(
'glyphcions' )
);
}
add_action( 'wp_bootstrap_navwalker_init', 'wp_bootstrap_navwalker_setup' );
}
This way every instance of the walker can support its own list of add-ons.
Hi! Really love this script! But do you have any idea when it might be ready for 3.0?
Hey @stinaq,
Ed actually made this 3.0 compatible pretty much as soon as Bootstrap 3 was out.
If your using 3.0 your good to go by following the instructions at the walker's main page :)
Thanks for the feedback everyone. As I am in the middle of a huge project at the moment I am going to close this issue and revisit it when I have more time.