Code Snippet problem with UberMenu install in GeneratePress.
-
I’m attempting to install the UberMenu Plugin to a site running the GeneratePress theme. Generatepress recommends using Code Snippets to add the following code. Note: This code has been working for many previous GP/UberMenu sites:
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 );
}When I Save & Activate the snippet, I receive the following error:
The snippet has been deactivated due to an error on line 3:
Cannot redeclare function generate_navigation_position.I’m confused since the first line of the of the script checks for the existence of the function.
To simplify testing, I created a VM with the latest WP (Version 5.4.1), GeneratePress (Version: 2.4.2), Code Snippets (Version: 2.14.0) and UberMenu (Version 3.6.1). No customization was performed. I can cut/paste the code from either the GP or UberMenu documentation and it 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.phpI 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
The topic ‘Code Snippet problem with UberMenu install in GeneratePress.’ is closed to new replies.