Archived topic
trouble integrating UberMenu 3 from sevenspark
10 replies · Started by Drew on February 6, 2018
I've been trying to integrate the ubermenu 3 plugin from Sevenspark per their integration guide here: http://sevenspark.com/docs/ubermenu-3/theme-integration/generatepress
I've discovered that attempts to insert the necessary functions via code snippets plugin is throwing errors. According to the devs at sevenspark, it requires using a child theme in order to override the pluggable function.
I'm not excited about the idea of creating a child theme expressly for using a single plugin and am wondering if you have any other suggestions on how to go about using those functions (perhaps working them in as a hook?).
Many thanks,
Drew
What are the errors you're encountering?
You really should be using a child theme, it bring other benefits too, like making customizations that survive a theme update.
You can place the following in your child theme 'functions.php'. You may or may not need the inner 'div', I use it to allow a full width menu bar, but contain the menu items to the 'contained width' of the site:
/* Replace GeneratePress's main navigation menu with UberMenu */
function generate_navigation_position() {
if (function_exists('ubermenu')) {
echo '<div class="ubernav-container">';
echo '<div class="grid-container">';
ubermenu('main' , array('theme_location' => 'primary'));
echo '</div>';
echo '</div>';
}
}
The error message is:
Cannot redeclare generate_navigation_position() (previously declared in
/nas/content/staging/morikami/wp-content/themes/generatepress/inc/structure/navigation.php:20)
...and according to the plugin dev "you need to add the code in a child theme in order to override the pluggable function."
I really want to avoid using a child theme, that was one of the primary features of using GP to begin with. Adding one now only erases part of the customizations already added so that only makes another tedious step of comparing each settings panel in the customizer to look for changes.
You might be able to put it in GP's own functions.php, but it WILL be wiped out by a theme update.
Many thanks Simon, I'm well versed on all of that. What I'm looking for from Tom is to hopefully find a different solution.
Their code in the docs isn't correct.
It should be:
if ( ! function_exists( 'generate_navigation_position' ) ) {
function generate_navigation_position() {
if( function_exists( 'ubermenu' ) ){
ubermenu( 'main' , array( 'theme_location' => 'primary' ) );
}
}
}
Gotcha and to confirm, using this in the snippet plugin should work, correct?
Yup.
Awesome, I will do that on my end plus forward this along to the ubermenu dev - thanks guys!
Glad we could help :)