Site logo

Archived topic

ubermenu and generatepress

13 replies · Started by xdaniel on March 7, 2018

Viewing posts 1–14 of 14

Hi GP-Team,

I tried to install ubermenu by this tutorial: https://sevenspark.com/docs/ubermenu-3/theme-integration/generatepress using code snippets instead of a child theme. When I try to activate the snippet, I got the following error:

Cannot redeclare generate_navigation_position() (previously declared in /var/www/.../wp-content/themes/generatepress/inc/structure/navigation.php:20)

Does the snippet not work with newer versions of GeneratePress?

Best, Daniel

They need to update their code.

It should be this:

if ( ! function_exists( 'generate_navigation_position' ) ) {
    function generate_navigation_position(){
        if( function_exists( 'ubermenu' ) ){
            ubermenu( 'main' , array( 'theme_location' => 'primary' ) );
        }
    }
}
 
/* Stop the theme from filtering the menu output */
add_action( 'wp_head' , 'stop_generatepress_menu_filter' );
function stop_generatepress_menu_filter(){
    remove_filter( 'walker_nav_menu_start_el', 'generate_nav_dropdown', 10, 4 );
}

Yes Tom, that works! Thanks a lot. Hope your businness growth and you can keep this great support.

https://celtic-rock.de

I'll inform the guys from uber.

Thank you! :)

The site I'm working on will be needing a mega menu, which will be more complicated than the simple CSS solution provided by GP. I'm attempting to install UberMenu, and found that the UberMenu plugin doc still has the original old snippet code. I tried using your update, and snippets took the code request. However, when I try to activate the snippet, the activate button goes halfway with a question mark. Hovering on the button displays "An error occurred when attempting to activate".

Any suggestions? Including looking at other Mega Menu plugins... I have tried Max Mega Menu, but ran into enough anomalies to want to check out other options. I'm even considering using the GP CSS version as a starting point and manually adding CSS extensions.

Thanks,
Don

Actually, UberMenu did update their doc and now has the same snippet cards as the ones you provided. However, when I try a "Save and Activate" from the snippet editor, the dialog displays:

The snippet has been deactivated due to an error on line 3:
Cannot redeclare function generate_navigation_position.

Thanks,
Don

Yes, I did use your update. To try and narrow the problem, I created a VM with the latest WP, GeneratePress (free version), Code Snippets and UberMenu. I can cut/paste the code using your reference and it still fails. Here's a couple of screen shots:

https://drive.google.com/open?id=13sttIJet4xm-ZwH4-DxDoZbh8Twa1cAN

https://drive.google.com/open?id=1BUmqDUOHMP7pJuwdAU4ZFdYMs7whJfJq

I also scanned the website for files that contain the offending function, and got these two hits:

[root@jbm-web-centos8 ~]# grep -rlw -e "generate_navigation_position" /var/www/html
/var/www/html/wp-content/themes/generatepress/inc/customizer/helpers.php
/var/www/html/wp-content/themes/generatepress/inc/structure/navigation.php

I took a look at the modules, and didn't see anything amiss, but I'm not competent with php.

Could this be a bug with Code Snippets?

Thanks,
Don

I installed the GP child theme on my test VM - not the development system I've been using for months. Too chicken at this point. I've also added the following to the child theme's functions.php file:

/* Replace the theme's menu with UberMenu */
function generate_navigation_position(){
    if( function_exists( 'ubermenu' ) ){
        ubermenu( 'main' , array( 'theme_location' => 'primary' ) );
    }
}
 
/* Stop the theme from filtering the menu output */
add_action( 'wp_head' , 'stop_generatepress_menu_filter' );
function stop_generatepress_menu_filter(){
    remove_filter( 'walker_nav_menu_start_el', 'generate_nav_dropdown', 10, 4 );
}

I don't see any errors when I access pages on the site. Is there an easy way to see if the ubermenu function has been installed correctly? Note: I don't have an actual ubermenu license for this test vm...

Thanks,
Don

Back to the Code Snippet error. I found this statement when looking at the php function_exists doc:

"function_exists will return false for functions disabled with the disable_functions ini directive. However those functions are still declared so trying to define them yourself will fail."

Is is possible GP is issuing a disable_functions at some point?

Thanks,
Don

With help from the UberMenu developer, I was able to verify that the child theme install method does work as intended.

Weird problem with Code Snippets.

Thanks
Don

Glad you got it working :)

This archived topic is closed to new replies.