Menu trouble after deactivating and activating
-
Hi, beautiful plugin, wonderful to see all the work on it and the simplicity with which it works. Thank you.
I am/was using: WP 3.7.1. & polylang 1.2.1 & custom made theme
I have an odd little problem. I had your plugin working, completely, on my site with the current theme.
I added an archive template for a custom post type (archive-portfolio.php) that was already working without problems. The archive page didn’t work. I deactivated polylang to see if it might have something to do with that. The archive worked. I thought “aha”.
I turned polylang back on thinking I’d just have to change a setting or the permalink structure to get it to work, and the english menu stopped working. (Default is dutch)
The menu still exists, I try to choose the right location for it (Main menu in English), I click save. But it doesn’t commit the change.
I made a new menu, doesn’t work either. There is another location available but all menu’s will only take the dutch/default locations and none of the English one.
I’ve tried activating and deactivating the plugin again. Nothing changes.
A new update came out of polylang, I updated, nothing changed. I can’t assign a menu to any of the english versions of ‘location’.
I don’t know if I explained myself clearly but I hope so. Anyone who has a suggestion of where I might look: I’m open to them!
Thank you.
-
You’re the second to report such kind of issue. The first using a very popular theme I use during my tests…
Did you update from 1.1.6 to 1.2.1 before it happened?
Hi Chouby, thank you for your response.
No, 1.2.1. was actually my first version. I’d only been working with it for a few days.Is your theme a child theme?
No, it’s a complete custom build, which could be the problem of course.
Except that it worked at first and the only change I made to the theme between it working and not working was to add the archive page.
When I removed the archive page from the server, to test if that was the culprit, the problem remained.Does it work if you use another theme?
Just in case, how do you register your nav menus?Not at first but if I tick the box again and save again then it does commit the change.
This is how I register my menus:
if ( ! function_exists( 'my_menus' ) ) { function my_menus() { $locations = array( 'primary_menu' => __( 'Main menu', 'mytheme' ), 'mobile_menu' => __( 'Menu on mobile devices', 'mytheme' ) ); register_nav_menus( $locations ); } add_action( 'init', 'my_menus' ); }and this is how I call one in the header:
wp_nav_menu( array( 'theme_location' => 'primary_menu') );Do you see anything unusual?
My functions file is very basic.
BTW one other, possibly related oddity (or not), is that the archive page (that I originally turned polylang off for) has continued to work even with polylang on.
It’s partly why I wondered if removing that file from the server would do anything but it hasn’t.Chouby, I do realise you can’t test for what people put in their custom made themes and that there are, quite possibly too many variables here to have a real idea of what is happening but if you do have an insight, I’d be happy to try it.
Otherwise, I could easily put in a workaround.
And if for some reason you want more information from me, of course let me know.
I much appreciate your efforts here.Sorry, to clarify:
Not at first but if I tick the box again and save again then it does commit the change.
This is true if I use another theme, not for my own theme (then I wouldn’t have bothered you with it 🙂 ).
Yes, you registered the menus as usual. I strongly believe that there is a bug in Polylang (or at least a conflict with something is usual as you are the second to report such issue since 1.2 is out), even if can’t reproduce it on my test site.
If you would like to help me debug this, I would like you to try this:
In your wp-config.php, replace:define('WP_DEBUG', false);by
define('WP_DEBUG', true); define('SCRIPT_DEBUG', true); define('WP_DEBUG_LOG', true); define('WP_DEBUG_DISPLAY', false);This will allow to log messages in wp-content/debug.log
Then if you could just activate (and de-activate it as soon as activated) the following plugin:
<?php /* Plugin Name: test menu */ add_action('admin_init', 'pll_admin_init_1', 1); add_action('admin_init', 'pll_admin_init_100', 100); function pll_admin_init_1() { error_log('step 1'); $pll_nav_menu_locations = get_nav_menu_locations(); error_log(print_r($pll_nav_menu_locations, true)); if (is_array($pll_nav_menu_locations)) { error_log('translations'); foreach ($pll_nav_menu_locations as $loc => $menu) { error_log($loc); global $polylang; if (!empty($polylang)) { $translations = $polylang->model->get_translations('term', $menu); error_log(print_r($translations, true)); } } } } function pll_admin_init_100() { error_log('step 100'); $pll_nav_menu_locations = get_nav_menu_locations(); error_log(print_r($pll_nav_menu_locations, true)); global $_wp_registered_nav_menus; error_log(print_r($_wp_registered_nav_menus, true)); error_log('menus'); $nav_menus = get_terms('nav_menu'); error_log(print_r($nav_menus, true)); }This should log some content of your database about nav menus and their translation to the file wp-content/debug.log
Maybe you should do this with no other plugins activated except Polylang and your theme. Once you’ve the debug.log file, you can put your config.php in its original state.
Hopefully the content of the debug.log file will help me understand what happens
Of course, hope this helps:
[15-Nov-2013 14:47:30] step 1 [15-Nov-2013 14:47:30] Array ( [primary_menu] => 82 [primary] => 82 [primary_english_menu] => 130 ) [15-Nov-2013 14:47:30] translations [15-Nov-2013 14:47:30] primary_menu [15-Nov-2013 14:47:30] Array ( [nl] => 82 ) [15-Nov-2013 14:47:30] primary [15-Nov-2013 14:47:30] Array ( [nl] => 82 ) [15-Nov-2013 14:47:30] primary_english_menu [15-Nov-2013 14:47:30] Array ( [nl] => 130 ) [15-Nov-2013 14:47:30] step 100 [15-Nov-2013 14:47:30] Array ( [primary_menu] => 82 [primary] => 82 [primary_english_menu] => 130 ) [15-Nov-2013 14:47:30] Array ( [primary_menu] => Main menu Nederlands [primary_menu___en] => Main menu English [mobile_menu] => Menu on mobile devices Nederlands [mobile_menu___en] => Menu on mobile devices English ) [15-Nov-2013 14:47:30] menus [15-Nov-2013 14:47:30] Array ( [0] => stdClass Object ( [term_id] => 230 [name] => english [slug] => english [term_group] => 0 [term_taxonomy_id] => 232 [taxonomy] => nav_menu [description] => [parent] => 0 [count] => 3 ) [1] => stdClass Object ( [term_id] => 82 [name] => hoofdmenu [slug] => hoofdmenu [term_group] => 0 [term_taxonomy_id] => 83 [taxonomy] => nav_menu [description] => [parent] => 0 [count] => 7 ) [2] => stdClass Object ( [term_id] => 130 [name] => hoofdmenu - Engels [slug] => hoofdmenu-engels [term_group] => 0 [term_taxonomy_id] => 132 [taxonomy] => nav_menu [description] => [parent] => 0 [count] => 7 ) ) [15-Nov-2013 14:47:34] step 1 [15-Nov-2013 14:47:34] Array ( [primary_menu] => 82 [primary] => 82 [primary_english_menu] => 130 ) [15-Nov-2013 14:47:34] translations [15-Nov-2013 14:47:34] primary_menu [15-Nov-2013 14:47:34] Array ( [nl] => 82 ) [15-Nov-2013 14:47:34] primary [15-Nov-2013 14:47:34] Array ( [nl] => 82 ) [15-Nov-2013 14:47:34] primary_english_menu [15-Nov-2013 14:47:34] Array ( [nl] => 130 ) [15-Nov-2013 14:47:34] step 100 [15-Nov-2013 14:47:34] Array ( [primary_menu] => 82 [primary] => 82 [primary_english_menu] => 130 ) [15-Nov-2013 14:47:34] Array ( [primary_menu] => Main menu Nederlands [primary_menu___en] => Main menu English [mobile_menu] => Menu on mobile devices Nederlands [mobile_menu___en] => Menu on mobile devices English ) [15-Nov-2013 14:47:34] menus [15-Nov-2013 14:47:34] Array ( [0] => stdClass Object ( [term_id] => 230 [name] => english [slug] => english [term_group] => 0 [term_taxonomy_id] => 232 [taxonomy] => nav_menu [description] => [parent] => 0 [count] => 3 ) [1] => stdClass Object ( [term_id] => 82 [name] => hoofdmenu [slug] => hoofdmenu [term_group] => 0 [term_taxonomy_id] => 83 [taxonomy] => nav_menu [description] => [parent] => 0 [count] => 7 ) [2] => stdClass Object ( [term_id] => 130 [name] => hoofdmenu - Engels [slug] => hoofdmenu-engels [term_group] => 0 [term_taxonomy_id] => 132 [taxonomy] => nav_menu [description] => [parent] => 0 [count] => 7 ) )Oh yes!
The bug is a combination of two factors.
During your theme development, you probably made tests with different names for your menus i.e
'primary'and'primary_english_menu'which do not exist anymore in your theme but are still stored in DB (but only for the default language).Polylang does not store a menu per location in translated language but only the information that the menu hoofdmenu – Engels is the translation of the menu hoofdmenu (when you affect them to the same location in different languages).
Now what happens when you attempt to save your location:
primary_menu => hoofdmenu
primary_menu___en => hoofdmenu - Engels
That’s OK, the translations are stored
Then
primary => hoofdmenu (kept from DB)
nothing in front (primary___endoes not exit)
KO! Polylang deletes the translation of the menu hoofdmenuTo conclude, for you:
There is a quick fix if you don’t mind loosing the other theme parameters (such as background, etc…), go in your DB, look for the option theme_mod_your_theme and just delete it.For me, I have to rewrite this to make it more robust!
Thank you very much for your tests! That was great help.
Hey! I’m so glad you figured it out.
And I was glad to help but really: thank you!
Thank you very much.
(And indeed that fixed it. 🙂 )
NaomiI have the same issues.
I am using polylang with bizway. The menus used to work great, but now after upgrading to version 1.2.1 the admin panel won’t save the language option I am attaching to each menu. Basically it only saves the language option for the default language.I’ve tried to delete the table you suggested from the DB but this doesn’t fix the issue.
This is what I have in theme_mods:
a:1:{s:18:”nav_menu_locations”;a:1:{s:11:”custom_menu”;i:60;}}
That’s not exactly the same issue… As your problem is probably caused by an interrupted upgrade (most probably due to a conflict with another plugin). @naomiblindeman got these issues while developping a new theme.
Did you make a database backup before upgrading?
Just updated to version 1.2.3 and the issue has been resolved!
Thank you.
The topic ‘Menu trouble after deactivating and activating’ is closed to new replies.