Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Enrico Battocchi

    (@lopo)

    Hi,
    it’s not compatible yet, thanks for the suggestion, I’ll try to apply.

    It would be great if this was compatible with WPML since all our posts are in multiple languages.

    Plugin Author:

    As a good start, In case of WPML compatible workspace something like this should do the trick to reach all siblings WPML/ Translated posts and do whatever your plugin in does with the original post.

    First call, check if there is translations, just a root function example for the second function below:

    function ua_wpml_clone stuff($post_id){
       $translated_ids = ua_wpml_get_translated_ids($post_id);
       if(!isset($translated_ids[0])){
          // No translations;
       } else {
          // Loop the $translated_ids and clone each of them
       }
    }

    The WPML check function:

    REMARK, You must pass post_type, and the post_type name, in this example a Woocommerce product is in use, and pasted directly into the function ('post_product' and 'product') for easier understanding this “$trid” is in use.

    function ua_wpml_get_translated_ids($post_id){
    
    	global $sitepress;
    	$translated_ids = Array();
    	if(!isset($sitepress)) return $translated_ids;
    
    	$trid = $sitepress->get_element_trid($post_id, 'post_product');
    	$translations = $sitepress->get_element_translations($trid, 'product');
    	foreach( $translations as $lang=>$translation){
    		$translated_ids[] = $translation->element_id;
    	}
    	return $translated_ids;
    }

    Hope this is a good start. Great if your plugin would be WPML friendly!

    Yes, please make it WPML compatible for standart pages and posts.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Compatible with WPML plugin?’ is closed to new replies.