This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

This thread is resolved. Here is a description of the problem and solution.

Problem:
When I use the WP Menu Sync feature to clone English menus into other languages, everything works great except not ALL the postmeta for the nav_menu_items are not copied over. Specifically, Ubermenu.

Ubermenu has just 2 meta keys (as far as I can tell) for each custom menu item :

_ubermenu_settings

_ubermenu_custom_item_type

These aren't getting duped over when the new nav_menu_items are created, which means they become "Custom Link" menu types - which loses their functionality and breaks the menu layout.

Solution:
We did not manage yet to implement Ubermenu menu sync in WPML menu sync actions,
but we have a custom plugin that can help to sync menu properties on Ubermenu save action here:
https://gist.github.com/srdjan-jcc/2bab3671ffd1295fe1a02751e55ead23. You can create a "Ubermenu Multilingual" folder at you wp-content foldar and save this file as "index.php" inside that folder.

Short instructions:
1. Create menus in other languages using WPML sync menu (plugin will work only with existing translations)
2. Install plugin
3. Edit original menu using Ubermenu GUI

When menu items are synced
When saving original menu (using Ubermenu GUI), plugin will copy non-translatable properties to menus in other languages.

Translatable menu item properties
List of translatable properties will determine which properties will not be overwritten.
Can be filtered to add more properties like this:

add_filter( 'wpml_ubermenu_translatable_properties', 'my_ubermenu_translatable_properties' );
 
function my_ubermenu_translatable_properties( $properties ){
 
    // add some
    $properties[] = 'missing_text';
 
    // reset completely
    $properties = array(
        'custom_content',
        'submenu_footer_content',
        'empty_results_message',
        'icon_title'
    );
 
    return $properties;
 
}

WPML String Translation
Translatable properties can be translated using WPML String Translation.
Strings will appear under 'Ubermenu items' context.

To enable WPML ST - user must define constant before is defined in plugin:

define( 'WPML_UBERMENU_ENABLE_STRING_TRANSLATION', true );

You may also edit definition argument in plugin itself.

Tagged: 

This topic contains 17 replies, has 2 voices.

Last updated by Twig 1 year ago.

Assigned support staff: Diego Pereira.

Author Posts
August 1, 2018 at 1:09 pm #2602028

Twig

Hi -

When I use the WP Menu Sync feature to clone English menus into other languages, everything works great except not ALL the postmeta for the nav_menu_items are not copied over. Specifically, Ubermenu (I'm sure you know about this plugin - I think it's pretty much #1 meganav plugin for WP)

Ubermenu has just 2 meta keys (as far as I can tell) for each custom menu item :
_ubermenu_settings
_ubermenu_custom_item_type

These aren't getting duped over when the new nav_menu_items are created, which means they become "Custom Link" menu types - which loses their functionality and breaks the menu layout.

I did some tests and it seems that simply copying these two fields over for each nav item fixes the problem.

Could you look at adding this into the WP Menu Sync feature? It would be a real time-saver instead of people having to manually re-create their menu items for all their localized sites.

Thanks

August 1, 2018 at 2:47 pm #2602444

Diego Pereira
Supporter

Languages: English (English ) Spanish (Español ) Portuguese (Brazil) (Português )

Timezone: America/Sao_Paulo (GMT-03:00)

Hello @Twig, welcome to the WPML support Forum!

Please try the steps below:
- Go to WPML > languages > Custom Fields Translation
- Click on Show System Fields
- Search for the Ubermenu meta fields
- Select the "Copy" or "Copy-once" option and click on save

Please let me know if it worked for you.

All the best,
Diego

August 1, 2018 at 4:01 pm #2602648

Twig

Hi Diego -

Thanks for the quick reply and the idea. Unfortunately I already tried that, and it doesn't work. I think the custom field "copy" operation doesn't apply when the WP Menu Sync runs (only when the pages/posts/customs are duplicated using the Translation Manager

I watched the wp_postmeta table as the sync was running; it copies the core nav menu options (links, classes etc.) but does not copy the _ubermenu* options, despite me having set to "COPY" on the settings page

Any advice? It would be really helpful to get it working in core - otherwise I'll have to somehow tie the menu items between languages together so I can write a custom sql query to do the meta insert

Thanks!

Also - I see a warnging on this forum that says "You have disabled notifications for the Support forum on your account page settings. Please enable these so that you can receive notifications from this topic." but I don't see an option in my profile to control notifications? I want to get an email notice when you reply to this thread please.

August 1, 2018 at 6:15 pm #2603025

Diego Pereira
Supporter

Languages: English (English ) Spanish (Español ) Portuguese (Brazil) (Português )

Timezone: America/Sao_Paulo (GMT-03:00)

Hi there,

The plugin is not listed at our list of compatible plugins: https://wpml.org/documentation/plugins-compatibility

In this case we need to install the plugin on a clean installation. If it is possible to reproduce the issue, I can forward it to our compatibility team, who will do some tests and contact the author of the plugin to make it 100% compatible.

I created a clean installation with a default theme and WPML already configured. Please install the plugin and create a menu in the same way as your website. You can access the dashboard through this link: hidden link

Please let me if it worked. I will do some more tests on the clean installation and forward it to our team.

PS: Please check if you have a "Notify me of follow-up replies via email" checkbox above the submit button on this page.

Regards,
Diego

August 1, 2018 at 6:27 pm #2603032

Twig

Thanks! I'll try installing and testing Ubermenu on that dashboard link.

Meantime - you can see from my screenshots below that I have alerts checked; but I still get that weird message - and I do not have any such option on my Account screen.

Ideas on how I can get notified? If we need to delete/re-initialize my WPML account, that's fine.

August 1, 2018 at 6:59 pm #2603128

Twig

Ok - I have set up your sandbox and the same issue is present. Latest versions of all plugins.

English version - see how the menu dropdowns are in 4 columns?
hidden link

Portuguese version: Ubermenu is active but the nav_menu_item custom fields did not get copied, so the dropdown is just one long list
hidden link

I had selected the 2 custom system fields (_ubermenu_settings and _ubermenu_custom_menu_type) in the Settings page before I did the sync, didn't copy them.

If I manually inject the custom fields, the menu items are fixed. You can tell if it works because the menu items say "UberMenu Column" etc. instead of "Custom Link"

Thanks

August 1, 2018 at 7:10 pm #2603140

Diego Pereira
Supporter

Languages: English (English ) Spanish (Español ) Portuguese (Brazil) (Português )

Timezone: America/Sao_Paulo (GMT-03:00)

Hi there,

Thanks a lot! I will do some tests, if I do not find a solution I will forward it to our compatibility team. I'll send you feedback soon.

About the notifications, please check Account -> Newsletter settings. I added a screenshot.

Regards,
Diego

August 1, 2018 at 7:21 pm #2603161

Twig

Ah got it! Newsletter - who knew 🙂

Thanks for looking into it. The good news is that the Ubermenu author has worked with WPML to make it compatible:
hidden link

I think the only issue are these missing settings (custom fields) - the rest of the menu cloning works great.

August 2, 2018 at 4:16 pm #2606183

Twig

I was wondering also if, like when pages are duplicated, there was a way to have a nav_menu_item have a custom system field like "_duplicate_of" with the ID of the parent nav_menu_item? (I.e. the one in english)

Then it would be trivial for a function to copy the required meta fields between linked menu items...

August 2, 2018 at 4:47 pm #2606263

Diego Pereira
Supporter

Languages: English (English ) Spanish (Español ) Portuguese (Brazil) (Português )

Timezone: America/Sao_Paulo (GMT-03:00)

Hi there,

Thanks! I forwarded the details to our Themes & Plugins Compatibility Team and they will contact the author. Please note that this process may take a while as it depends on how soon the author will reply to our efforts to contact him.

It would be great if you can also contact the author asking him to reply us. You could also refer them to our Go Global program so that we can help them make their product compatible with WPML: https://wpml.org/documentation/theme-compatibility/go-global-program/

This may help expedite the process.

Kind Regards,
Diego

August 2, 2018 at 5:03 pm #2606382

Twig

Thanks Diego!
I just submitted a ticket to SevenSparks doing just that, with a link back to this ticket.

I really hope the two teams can sort this one little detail out - then I think Ubermenu + WPML will play nicely together.

August 2, 2018 at 5:44 pm #2606563

Diego Pereira
Supporter

Languages: English (English ) Spanish (Español ) Portuguese (Brazil) (Português )

Timezone: America/Sao_Paulo (GMT-03:00)

Great, thanks!! 🙂

August 2, 2018 at 6:14 pm #2606640

Twig

Even more interesting - I think the whole problem could be fixed by just running:

do_action( 'wpml_sync_all_custom_fields', POST_ID );

for each nav_menu_item POST_ID in the default language! (Assuming the required fields have already been marked as "COPY" or "COPY ONCE" in Translation Manager -> System Fields)

Seems to me that this hook could be run as part of the Sync Menu function, and fix the problem. Clearly WPML knows internally which menu items go with which, across languages.

Is there a hook available for "post_wp_menu_sync" that I could use as a workaround?

August 2, 2018 at 7:10 pm #2606849

Diego Pereira
Supporter

Languages: English (English ) Spanish (Español ) Portuguese (Brazil) (Português )

Timezone: America/Sao_Paulo (GMT-03:00)

Hi there, thanks! I will forward this suggestion to our compatibility team.

Here is the list of all hooks available:
- https://wpml.org/documentation/support/wpml-coding-api/wpml-hooks-reference/

This can also be useful:
- https://wpml.org/documentation/support/wpml-coding-api/

Kind Regards,
Diego

August 3, 2018 at 12:28 pm #2609534

Twig

FYI - this is the response from the Ubermenu plugin author to my ticket (Chris @ SevenSpark)

"Yup, you're exactly right - that should just require copying over all the menu item metadata (as opposed to only the WP core menu item metadata fields). We've actually worked with WPML before via that program, and were previously told that the syncing was too complex to handle. But it's great to hear that they're working on it now! They have my contact information so they are able to get in touch when they need to, and happy to help if I can :)"