cyberhobo / wordpress-geo-mashup

Official repository for Geo Mashup, the plugin that makes WordPress into a GeoCMS. Documentation:
https://github.com/cyberhobo/wordpress-geo-mashup/wiki/Getting-Started
66 stars 15 forks source link

Copy location for WPML translation posts #750

Closed cyberhobo closed 7 years ago

cyberhobo commented 8 years ago

Suggested by Vuk Vukovic in an email:

It is not possible to duplicate locations from default language posts to 
other translations languages.

This is happening because you are using custom tables for locations as  
custom fields. WPML is following WP codex for that cases and duplicating 
post meta data from WP native tables.

Possible solution lies in when WPML duplicate a post, it uses WP API to 
create or update the post.

Therefore you can hook to "save_post" action, find the original post ID 
(is a post meta field in the duplicated post, with the ID of the original) 
and use this to duplicate the custom data.

You should look for "_icl_lang_duplicate_of": the value is the original 
post ID.
cyberhobo commented 7 years ago

Working with Vuk, we decided to use existing post meta features in both plugins rather than the _icf_lang_duplicate_of approach described above.

To get it working:

  1. Enable Settings / Geo Mashup / Overall / Copy Geodata Meta Fields.
  2. Install and activate the WPML Translation Management plugin.
  3. In WPML / Translation Management / Multilingual Content Management / Custom Field Translation switch these fields to Copy from original to translation: geo_address, geo_date, geo_latitude, geo_longitude.
cyberhobo commented 7 years ago

There is still a problem with post duplication, because WPML inserts metadata directly into the database without firing WP hooks in that case. Vuk has indicated this will not be fixed anytime soon.