Introducing Sagextras

After all of the discussion about trying to restore the older Bootstrap friendly Navwalker from older versions of Roots/Sage, I went ahead and made a small plugin called Sagextras to help bring it back. And I grew it a bit. It works the same way Soil does. Put a add_theme_support('se-feature'); in your lib/config.php and it will load the necessary feature.

Right now it has an implementation of the Navwalker from Roots 7.0.3 and also a return of the Bootstrap friendly gallery shortcode from the 7.x branch. I’ve tested this in a few installs.

Please, clone it, install it, try it out. Send in issues, send in pull requests if you see something terribly wrong. Maybe you can help me refactor this code to use namespaces like Sage and Soil do now.

Right now it’s only in the GitHub repo. Once I’m sure it’s stable enough to use, I’ll register it on Packagist so it can be installed via Composer.

I did this because it might be helpful to a lot of you, so I look forward to you guys helping out.

9 Likes

That’s cool. I was looking forward to either fork repo recommended by @ben (https://github.com/twittem/wp-bootstrap-navwalker) and create a plugin for it or to rip nav walker out of Sage pre 8.2.0

Your work really helped bootstrap my ideas :slight_smile: And so I added my ideas to Your work :slight_smile: (pull request awaits ;))

Thanks for the contributions. I’ve merged your pull into the repo. Appreciate the work refactoring the code to use namespaces.

The gist linked in the README throws an error for me:

Fatal error: Class 'Sagextras_Nav_Walker' not found

Few more questions that may be relevant.

Is the namespace Sageextras or Sagextras I see it both ways in the code.

I’ve got the plugin activated and added

add_theme_support('se-nav-walker');

to lib/config.php and I’ve tried

new Sageextras\Nav\NavWalker()

and other variants in the templates/header.php ‘walker’ but can’t get it to load.

Remove reference to Sageextras_Nav_Walker. I have something like this in my header:

<?php if (has_nav_menu('primary_navigation')) : wp_nav_menu(['theme_location' => 'primary_navigation', 'menu_class' => 'nav navbar-nav']); endif; ?>

thre’s no need to reference it directly, since plugin will autoforce itself :slight_smile:

Awesome, that did it! This looks great, thanks for all your work on it!

1 Like

Thanks for catching those. I really rely on autoloadiing since my late night coding can result in weird keystrokes…

I think that this plugin is stable-ish enough to be put out via Composer. It’s been published to packagist as storm2k/sagextras. The dev-master will pull in the latest commits.

Sorry for ripping this up, but I have no freakin’ idea what I can’t get this to work.
Mind if I bother you with a question romero2k? :smile:

Did this:

  1. Cloned this repo into theme root: https://github.com/storm2k/sagextras
  2. Added add_theme_support(‘se-nav-walker’); in lib/config.php
  3. Overwrote this Gist into header.php: https://gist.github.com/johnny-bit/cc8840f148da01c2af52

This is it, right?

How do I know if it works? I tried to remove add_theme_support(‘se-nav-walker’); from config.php, but it didn’t make any difference.

(Wondering because sub menus does not work, and it did in earlier Sage versions).

1 Like

It’s a WordPress plugin. You need to add it to the plugins folder and activate it.

Thanks :slight_smile: Damn, that was awkward. Any chance for one more sub level later on?

Sage’s implementation (which is what this plugin uses) only goes 1 level deep, so the plugin will only go that far as well. This was only about bringing back a Bootstrap-specific piece of Sage as the main theme moves to a platform agnostic setup.

Compatibility with Sage 8.3.0?

I just began a new project using the latest version of Sage. I installed Sagextras and followed documentation for getting Bootstrap’s gallery functionality working. But it’s not affecting the gallery markup, and thus isn’t formatting it accordingly. Any insights?

– Patrick

Probably this: https://github.com/roots/sage/pull/1546/files

Removing 'gallery' restores WP’s default gallery styling, but it still isn’t adding the Bootstrap specific markup to the gallery.

Given that Sage now uses the default HTML5 styling for galleries, my implementation will not work anymore.

Got it. Thanks for letting me know.

Hi @romero2k,
I’m using the latest version of Sage and tried your plugin to get the “old” Bootstrap Nav Walker back. But the Walker isn’t being used automatically for the nav. No other plugins installed except Soil.

What I did:

  • installed the plugin (cloned latest from Git) and activated it
  • added “add_theme_support(‘se-nav-walker’);” to setup.php (since there is no config.php anymore)
  • removed the Soil Walker (//add_theme_support(‘soil-nav-walker’))
  • edited header.php like your Gist

But it seems like the walker-functionality isn’t called at all. The output of the menu is just the default one. When enabling the Soil walker it strips the css classes, but when I disable it and enable yours again I’m back at Wordpress defaults.

I also tried to call the walker manually in header.php but dont know how the “walker” argument should be (tried things like “new WalkerNav”, “new Sagextras_Nav_WalkerNav”).

Any help would be greatly appreciated.

Hi @dsieber,

Most probably some recent change in Soil broke Sageextras one. It actually broke mine in soil-fertilizer (sageextras with sponsored work) too… Well, it could be not Soil update but something different, I yet don’t know :wink:

Either me or @romero2k will probably tackle this in reasonable time.