WooCommerce Multilingual – run WooCommerce with WPML - Version 3.4.2

Version Description

  • Accommodated taxonomy translation changes in WPML
Download this release

Release Info

Developer mihaimihai
Plugin Icon 128x128 WooCommerce Multilingual – run WooCommerce with WPML
Version 3.4.2
Comparing to
See all releases

Code changes from version 3.4.1 to 3.4.2

assets/js/scripts.js CHANGED
@@ -322,9 +322,9 @@ jQuery(document).ready(function($){
322
  })
323
 
324
 
325
- $(document).on('submit', '#icl_tt_sync_variations', function(){
326
 
327
- var this_form = $('#icl_tt_sync_variations');
328
  var data = this_form.serialize();
329
  this_form.find('.wpml_tt_spinner').fadeIn();
330
  this_form.find('input[type=submit]').attr('disabled', 'disabled');
@@ -335,7 +335,7 @@ jQuery(document).ready(function($){
335
  dataType: 'json',
336
  data : data,
337
  success: function(response) {
338
- this_form.find('.icl_tt_sycn_preview').html(response.progress);
339
  if(response.go){
340
  this_form.find('input[name=last_post_id]').val(response.last_post_id);
341
  this_form.find('input[name=languages_processed]').val(response.languages_processed);
@@ -354,6 +354,77 @@ jQuery(document).ready(function($){
354
 
355
  });
356
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
357
  var wcml_product_rows_data = new Array();
358
  var wcml_get_product_fields_string = function(row){
359
  var string = '';
322
  })
323
 
324
 
325
+ $(document).on('submit', '#wcml_tt_sync_variations', function(){
326
 
327
+ var this_form = $('#wcml_tt_sync_variations');
328
  var data = this_form.serialize();
329
  this_form.find('.wpml_tt_spinner').fadeIn();
330
  this_form.find('input[type=submit]').attr('disabled', 'disabled');
335
  dataType: 'json',
336
  data : data,
337
  success: function(response) {
338
+ this_form.find('.wcml_tt_sycn_preview').html(response.progress);
339
  if(response.go){
340
  this_form.find('input[name=last_post_id]').val(response.last_post_id);
341
  this_form.find('input[name=languages_processed]').val(response.languages_processed);
354
 
355
  });
356
 
357
+
358
+ $(document).on('submit', '#wcml_tt_sync_assignment', function(){
359
+
360
+ var this_form = $('#wcml_tt_sync_assignment');;
361
+ var parameters = this_form.serialize();
362
+
363
+ this_form.find('.wpml_tt_spinner').fadeIn();
364
+ this_form.find('input').attr('disabled', 'disabled');
365
+
366
+ $('.wcml_tt_sync_row').remove();
367
+
368
+ $.ajax({
369
+ type: "POST",
370
+ dataType: 'json',
371
+ url: ajaxurl,
372
+ data: 'action=wcml_tt_sync_taxonomies_in_content_preview&' + parameters,
373
+ success:
374
+ function(ret){
375
+
376
+ this_form.find('.wpml_tt_spinner').fadeOut();
377
+ this_form.find('input').removeAttr('disabled');
378
+
379
+ if(ret.errors){
380
+ this_form.find('.errors').html(ret.errors);
381
+ }else{
382
+ jQuery('#wcml_tt_sync_preview').html(ret.html);
383
+ }
384
+
385
+ }
386
+
387
+ });
388
+
389
+ return false;
390
+
391
+
392
+ });
393
+
394
+ $(document).on('click', 'form.wcml_tt_do_sync a.submit', function(){
395
+
396
+ var this_form = $('form.wcml_tt_do_sync');
397
+ var parameters = this_form.serialize();
398
+
399
+ this_form.find('.wpml_tt_spinner').fadeIn();
400
+ this_form.find('input').attr('disabled', 'disabled');
401
+
402
+ jQuery.ajax({
403
+ type: "POST",
404
+ dataType: 'json',
405
+ url: ajaxurl,
406
+ data: 'action=wcml_tt_sync_taxonomies_in_content&' + parameters,
407
+ success:
408
+ function(ret){
409
+
410
+ this_form.find('.wpml_tt_spinner').fadeOut();
411
+ this_form.find('input').removeAttr('disabled');
412
+
413
+ if(ret.errors){
414
+ this_form.find('.errors').html(ret.errors);
415
+ }else{
416
+ this_form.closest('.wcml_tt_sync_row').html(ret.html);
417
+ }
418
+
419
+ }
420
+
421
+ });
422
+
423
+ return false;
424
+
425
+
426
+ });
427
+
428
  var wcml_product_rows_data = new Array();
429
  var wcml_get_product_fields_string = function(row){
430
  var string = '';
inc/dependencies.class.php CHANGED
@@ -22,10 +22,8 @@ class WCML_Dependencies{
22
  $allok = true;
23
 
24
  if(!defined('ICL_SITEPRESS_VERSION') || ICL_PLUGIN_INACTIVE){
25
- if(!function_exists('is_multisite') || !is_multisite()) {
26
- $this->missing['WPML'] = $woocommerce_wpml->generate_tracking_link('http://wpml.org/');
27
- $allok = false;
28
- }
29
  } else if(version_compare(ICL_SITEPRESS_VERSION, '3.1.5', '<')){
30
  add_action('admin_notices', array($this, '_old_wpml_warning'));
31
  $allok = false;
22
  $allok = true;
23
 
24
  if(!defined('ICL_SITEPRESS_VERSION') || ICL_PLUGIN_INACTIVE){
25
+ $this->missing['WPML'] = $woocommerce_wpml->generate_tracking_link('http://wpml.org/');
26
+ $allok = false;
 
 
27
  } else if(version_compare(ICL_SITEPRESS_VERSION, '3.1.5', '<')){
28
  add_action('admin_notices', array($this, '_old_wpml_warning'));
29
  $allok = false;
inc/products.class.php CHANGED
@@ -125,10 +125,10 @@ class WCML_Products{
125
  }
126
 
127
  function wc_cart_widget_actions(){
128
- add_action('wp_ajax_woocommerce_get_refreshed_fragments',array($this,'wcml_refresh_fragments'),9);
129
- add_action('wp_ajax_woocommerce_add_to_cart',array($this,'wcml_refresh_fragments'),9);
130
- add_action('wp_ajax_nopriv_woocommerce_get_refreshed_fragments',array($this,'wcml_refresh_fragments'),9);
131
- add_action('wp_ajax_nopriv_woocommerce_add_to_cart',array($this,'wcml_refresh_fragments'),9);
132
  if(!is_admin()){
133
  wp_enqueue_script('wcml-scripts', WCML_PLUGIN_URL . '/assets/js/cart_widget.js', array('jquery'), WCML_VERSION);
134
  }
@@ -2485,7 +2485,7 @@ class WCML_Products{
2485
  }
2486
 
2487
  function wcml_refresh_fragments(){
2488
- global $woocommerce,$woocommerce_wpml;
2489
 
2490
  $woocommerce->cart->calculate_totals();
2491
  $this->wcml_refresh_text_domain();
125
  }
126
 
127
  function wc_cart_widget_actions(){
128
+ add_action('wp_ajax_woocommerce_get_refreshed_fragments',array($this,'wcml_refresh_fragments'),0);
129
+ add_action('wp_ajax_woocommerce_add_to_cart',array($this,'wcml_refresh_fragments'),0);
130
+ add_action('wp_ajax_nopriv_woocommerce_get_refreshed_fragments',array($this,'wcml_refresh_fragments'),0);
131
+ add_action('wp_ajax_nopriv_woocommerce_add_to_cart',array($this,'wcml_refresh_fragments'),0);
132
  if(!is_admin()){
133
  wp_enqueue_script('wcml-scripts', WCML_PLUGIN_URL . '/assets/js/cart_widget.js', array('jquery'), WCML_VERSION);
134
  }
2485
  }
2486
 
2487
  function wcml_refresh_fragments(){
2488
+ global $woocommerce;
2489
 
2490
  $woocommerce->cart->calculate_totals();
2491
  $this->wcml_refresh_text_domain();
inc/terms.class.php CHANGED
@@ -37,11 +37,18 @@ class WCML_Terms{
37
  add_action('wp_ajax_wcml_uningore_taxonomy_translation', array('WCML_Terms', 'wcml_uningore_taxonomy_translation'));
38
 
39
  add_action('created_term', array('WCML_Terms', 'set_flag_for_variation_on_attribute_update'), 10, 3);
40
-
41
- add_action('wpml_taxonomy_translation_bottom', array('WCML_Terms', 'show_variations_sync_button'), 10, 1);
42
- add_filter('wpml_taxonomy_show_tax_sync_button', array('WCMl_Terms', 'hide_tax_sync_button_for_attributes'));
43
-
 
 
 
 
 
44
  add_action('wp_ajax_wcml_sync_product_variations', array('WCML_Terms', 'wcml_sync_product_variations'));
 
 
45
 
46
  if(is_admin()){
47
  add_action('admin_menu', array($this, 'admin_menu_setup'));
@@ -615,19 +622,17 @@ class WCML_Terms{
615
  global $woocommerce_wpml, $sitepress, $wpdb;
616
 
617
  $wcml_settings = $woocommerce_wpml->get_settings();
618
-
619
- $default_language = $sitepress->get_default_language();
620
  $active_languages = $sitepress->get_active_languages();
621
-
622
  $not_translated_count = 0;
623
- foreach($active_languages as $language){
624
- if($language['code'] != $default_language){
625
 
626
  $terms = $wpdb->get_results($wpdb->prepare("
627
  SELECT t1.element_id AS e1, t2.element_id AS e2 FROM {$wpdb->term_taxonomy} x
628
- JOIN {$wpdb->prefix}icl_translations t1 ON x.term_taxonomy_id = t1.element_id AND t1.element_type = %s AND t1.language_code = %s
629
  LEFT JOIN {$wpdb->prefix}icl_translations t2 ON t2.trid = t1.trid AND t2.language_code = %s
630
- ", 'tax_' . $taxonomy, $default_language, $language['code']));
631
  foreach($terms as $term){
632
  if(empty($term->e2)){
633
  $not_translated_count ++;
@@ -635,7 +640,6 @@ class WCML_Terms{
635
 
636
  }
637
  }
638
- }
639
 
640
  $status = $not_translated_count ? self::NEW_TAXONOMY_TERMS : self::ALL_TAXONOMY_TERMS_TRANSLATED;
641
 
@@ -717,8 +721,8 @@ class WCML_Terms{
717
  }
718
 
719
  }
720
-
721
- static function show_variations_sync_button($taxonomy){
722
  global $woocommerce_wpml;
723
 
724
  if(is_admin() && isset($_GET['page']) && $_GET['page'] == 'wpml-wcml' && isset($_GET['tab'])){
@@ -727,62 +731,85 @@ class WCML_Terms{
727
  foreach($attribute_taxonomies as $a){
728
  $attribute_taxonomies_arr[] = 'pa_' . $a->attribute_name;
729
  }
730
-
731
- if(isset( $attribute_taxonomies_arr ) && in_array($taxonomy, $attribute_taxonomies_arr)){
732
-
733
- ?>
734
-
735
- <form id="icl_tt_sync_variations" method="post">
736
- <input type="hidden" name="action" value="wcml_sync_product_variations" />
737
- <input type="hidden" name="taxonomy" value="<?php echo $taxonomy ?>" />
738
- <input type="hidden" name="wcml_nonce" value="<?php echo wp_create_nonce('wcml_sync_product_variations') ?>" />
739
- <input type="hidden" name="last_post_id" value="" />
740
- <input type="hidden" name="languages_processed" value="0" />
741
-
742
- <p>
743
- <input class="button-secondary" type="submit" value="<?php esc_attr_e("Synchronize attributes and update product variations", 'wpml-wcml') ?>" />
744
- <img src="<?php echo ICL_PLUGIN_URL . '/res/img/ajax-loader.gif' ?>" alt="loading" height="16" width="16" class="wpml_tt_spinner" />
745
- </p>
746
- <span class="errors icl_error_text"></span>
747
- <div class="icl_tt_sycn_preview"></div>
748
- </form>
749
-
750
-
751
- <p><?php _e('This will automatically generate variations for translated products corresponding to recently translated attributes.'); ?></p>
752
- <?php if(!empty($wcml_settings['variations_needed'][$taxonomy])): ?>
753
- <p><?php printf(__('Currently, there are %s variations that need to be created.', 'wpml-wcml'), '<strong>' . $wcml_settings['variations_needed'][$taxonomy] . '</strong>') ?></p>
754
- <?php endif; ?>
755
 
756
-
757
- <?php
758
-
759
- }
760
-
761
  }
 
 
762
 
763
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
764
 
 
765
  static function hide_tax_sync_button_for_attributes($value){
766
  global $woocommerce_wpml;
767
-
768
  if(is_admin() && isset($_GET['page']) && $_GET['page'] == 'wpml-wcml' && isset($_GET['tab'])){
769
-
770
  $wcml_settings = $woocommerce_wpml->get_settings();
771
- $attribute_taxonomies = wc_get_attribute_taxonomies();
772
  foreach($attribute_taxonomies as $a){
773
  $attribute_taxonomies_arr[] = 'pa_' . $a->attribute_name;
774
  }
775
-
776
  $taxonomy = isset($_GET['tab']) ? $_GET['tab'] : false;
777
-
778
  if(isset($attribute_taxonomies_arr) && in_array($taxonomy, $attribute_taxonomies_arr)){
779
  $value = false;
780
  }
781
-
782
  }
783
-
784
  return $value;
785
-
786
  }
787
 
788
  static function wcml_sync_product_variations($taxonomy){
@@ -877,6 +904,180 @@ class WCML_Terms{
877
  exit;
878
 
879
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
880
  }
881
 
882
  function shipping_terms($terms, $post_id, $taxonomy){
37
  add_action('wp_ajax_wcml_uningore_taxonomy_translation', array('WCML_Terms', 'wcml_uningore_taxonomy_translation'));
38
 
39
  add_action('created_term', array('WCML_Terms', 'set_flag_for_variation_on_attribute_update'), 10, 3);
40
+
41
+ if ( defined( 'ICL_SITEPRESS_VERSION' ) && version_compare( ICL_SITEPRESS_VERSION, '3.1.8.2', '<=' ) ) {
42
+ // Backward compatibillity for WPML <= 3.1.8.2
43
+ add_action('wpml_taxonomy_translation_bottom', array('WCML_Terms', 'show_variations_sync_button'), 10, 1);
44
+ add_filter('wpml_taxonomy_show_tax_sync_button', array('WCML_Terms', 'hide_tax_sync_button_for_attributes'));
45
+ }else{
46
+ add_filter('wpml_taxonomy_translation_bottom', array('WCML_Terms', 'sync_taxonomy_translations'), 10, 3 );
47
+ }
48
+
49
  add_action('wp_ajax_wcml_sync_product_variations', array('WCML_Terms', 'wcml_sync_product_variations'));
50
+ add_action('wp_ajax_wcml_tt_sync_taxonomies_in_content', array('WCML_Terms', 'wcml_sync_taxonomies_in_content'));
51
+ add_action('wp_ajax_wcml_tt_sync_taxonomies_in_content_preview', array('WCML_Terms', 'wcml_sync_taxonomies_in_content_preview'));
52
 
53
  if(is_admin()){
54
  add_action('admin_menu', array($this, 'admin_menu_setup'));
622
  global $woocommerce_wpml, $sitepress, $wpdb;
623
 
624
  $wcml_settings = $woocommerce_wpml->get_settings();
625
+
 
626
  $active_languages = $sitepress->get_active_languages();
627
+
628
  $not_translated_count = 0;
629
+ foreach($active_languages as $language){
 
630
 
631
  $terms = $wpdb->get_results($wpdb->prepare("
632
  SELECT t1.element_id AS e1, t2.element_id AS e2 FROM {$wpdb->term_taxonomy} x
633
+ JOIN {$wpdb->prefix}icl_translations t1 ON x.term_taxonomy_id = t1.element_id AND t1.element_type = %s
634
  LEFT JOIN {$wpdb->prefix}icl_translations t2 ON t2.trid = t1.trid AND t2.language_code = %s
635
+ ", 'tax_' . $taxonomy, $language['code']));
636
  foreach($terms as $term){
637
  if(empty($term->e2)){
638
  $not_translated_count ++;
640
 
641
  }
642
  }
 
643
 
644
  $status = $not_translated_count ? self::NEW_TAXONOMY_TERMS : self::ALL_TAXONOMY_TERMS_TRANSLATED;
645
 
721
  }
722
 
723
  }
724
+
725
+ static function sync_taxonomy_translations( $html, $taxonomy, $taxonomy_obj ){
726
  global $woocommerce_wpml;
727
 
728
  if(is_admin() && isset($_GET['page']) && $_GET['page'] == 'wpml-wcml' && isset($_GET['tab'])){
731
  foreach($attribute_taxonomies as $a){
732
  $attribute_taxonomies_arr[] = 'pa_' . $a->attribute_name;
733
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
734
 
735
+ ob_start();
736
+ include WCML_PLUGIN_PATH . '/menu/sub/sync-taxonomy-translations.php';
737
+ $html = ob_get_contents();
738
+ ob_end_clean();
739
+
740
  }
741
+
742
+ return $html;
743
 
744
  }
745
+
746
+ // Backward compatibillity for WPML <= 3.1.8.2
747
+ static function show_variations_sync_button($taxonomy){
748
+ global $woocommerce_wpml;
749
+
750
+ if(is_admin() && isset($_GET['page']) && $_GET['page'] == 'wpml-wcml' && isset($_GET['tab'])){
751
+ $wcml_settings = $woocommerce_wpml->get_settings();
752
+ $attribute_taxonomies = wc_get_attribute_taxonomies();
753
+ foreach($attribute_taxonomies as $a){
754
+ $attribute_taxonomies_arr[] = 'pa_' . $a->attribute_name;
755
+ }
756
+
757
+ if(isset( $attribute_taxonomies_arr ) && in_array($taxonomy, $attribute_taxonomies_arr)){
758
+
759
+ ?>
760
+
761
+ <form id="wcml_tt_sync_variations" method="post">
762
+ <input type="hidden" name="action" value="wcml_sync_product_variations" />
763
+ <input type="hidden" name="taxonomy" value="<?php echo $taxonomy ?>" />
764
+ <input type="hidden" name="wcml_nonce" value="<?php echo wp_create_nonce('wcml_sync_product_variations') ?>" />
765
+ <input type="hidden" name="last_post_id" value="" />
766
+ <input type="hidden" name="languages_processed" value="0" />
767
+
768
+ <p>
769
+ <input class="button-secondary" type="submit" value="<?php esc_attr_e("Synchronize attributes and update product variations", 'wpml-wcml') ?>" />
770
+ <img src="<?php echo ICL_PLUGIN_URL . '/res/img/ajax-loader.gif' ?>" alt="loading" height="16" width="16" class="wpml_tt_spinner" />
771
+ </p>
772
+ <span class="errors icl_error_text"></span>
773
+ <div class="wcml_tt_sycn_preview"></div>
774
+ </form>
775
+
776
+
777
+ <p><?php _e('This will automatically generate variations for translated products corresponding to recently translated attributes.'); ?></p>
778
+ <?php if(!empty($wcml_settings['variations_needed'][$taxonomy])): ?>
779
+ <p><?php printf(__('Currently, there are %s variations that need to be created.', 'wpml-wcml'), '<strong>' . $wcml_settings['variations_needed'][$taxonomy] . '</strong>') ?></p>
780
+ <?php endif; ?>
781
+
782
+
783
+ <?php
784
+
785
+ }
786
+
787
+ }
788
+
789
+ }
790
 
791
+ // Backward compatibillity for WPML <= 3.1.8.2
792
  static function hide_tax_sync_button_for_attributes($value){
793
  global $woocommerce_wpml;
794
+
795
  if(is_admin() && isset($_GET['page']) && $_GET['page'] == 'wpml-wcml' && isset($_GET['tab'])){
796
+
797
  $wcml_settings = $woocommerce_wpml->get_settings();
798
+ $attribute_taxonomies = wc_get_attribute_taxonomies();
799
  foreach($attribute_taxonomies as $a){
800
  $attribute_taxonomies_arr[] = 'pa_' . $a->attribute_name;
801
  }
802
+
803
  $taxonomy = isset($_GET['tab']) ? $_GET['tab'] : false;
804
+
805
  if(isset($attribute_taxonomies_arr) && in_array($taxonomy, $attribute_taxonomies_arr)){
806
  $value = false;
807
  }
808
+
809
  }
810
+
811
  return $value;
812
+
813
  }
814
 
815
  static function wcml_sync_product_variations($taxonomy){
904
  exit;
905
 
906
 
907
+ }
908
+
909
+ static function wcml_sync_taxonomies_in_content_preview(){
910
+ global $wp_taxonomies;
911
+
912
+ $html = $message = $errors = '';
913
+
914
+
915
+ if(isset($wp_taxonomies[$_POST['taxonomy']])){
916
+ $object_types = $wp_taxonomies[$_POST['taxonomy']]->object_type;
917
+
918
+ foreach($object_types as $object_type){
919
+
920
+ $html .= self::render_assignment_status($object_type, $_POST['taxonomy'], $preview = true);
921
+
922
+ }
923
+
924
+ }else{
925
+ $errors = sprintf(__('Invalid taxonomy %s', 'wpml-wcml'), $_POST['taxonomy']);
926
+ }
927
+
928
+
929
+ echo json_encode(array('html' => $html, 'message'=> $message, 'errors' => $errors));
930
+ exit;
931
+ }
932
+
933
+ public static function wcml_sync_taxonomies_in_content(){
934
+ global $wp_taxonomies;
935
+
936
+ $html = $message = $errors = '';
937
+
938
+ if(isset($wp_taxonomies[$_POST['taxonomy']])){
939
+ $html .= self::render_assignment_status($_POST['post'], $_POST['taxonomy'], $preview = false);
940
+
941
+ }else{
942
+ $errors .= sprintf(__('Invalid taxonomy %s', 'wpml-wcml'), $_POST['taxonomy']);
943
+ }
944
+
945
+
946
+ echo json_encode(array('html' => $html, 'errors' => $errors));
947
+ exit;
948
+
949
+
950
+ }
951
+
952
+ public static function render_assignment_status($object_type, $taxonomy, $preview = true){
953
+ global $sitepress, $wp_post_types, $wp_taxonomies,$wpdb;
954
+
955
+ $default_language = $sitepress->get_default_language();
956
+ $posts = get_posts( array( 'post_type' => $object_type, 'suppress_filters' => false, 'posts_per_page' => -1 ) );
957
+
958
+ foreach($posts as $post){
959
+
960
+ $terms = wp_get_post_terms($post->ID, $taxonomy);
961
+
962
+ $term_ids = array();
963
+ foreach($terms as $term){
964
+ $term_ids[] = $term->term_id;
965
+ }
966
+
967
+ $trid = $sitepress->get_element_trid($post->ID, 'post_' . $post->post_type);
968
+ $translations = $sitepress->get_element_translations($trid, 'post_' . $post->post_type, true, true);
969
+
970
+ foreach($translations as $language => $translation){
971
+
972
+ if($language != $default_language && $translation->element_id){
973
+
974
+ $terms_of_translation = wp_get_post_terms($translation->element_id, $taxonomy);
975
+
976
+ $translation_term_ids = array();
977
+ foreach($terms_of_translation as $term){
978
+
979
+ $term_id_original = icl_object_id($term->term_id, $taxonomy, false, $default_language );
980
+ if(!$term_id_original || !in_array($term_id_original, $term_ids)){
981
+ // remove term
982
+
983
+ if($preview){
984
+ $needs_sync = true;
985
+ break(3);
986
+ }
987
+
988
+ $current_terms = wp_get_post_terms($translation->element_id, $taxonomy);
989
+ $updated_terms = array();
990
+ foreach($current_terms as $cterm){
991
+ if($cterm->term_id != $term->term_id){
992
+ $updated_terms[] = is_taxonomy_hierarchical($taxonomy) ? $term->term_id : $term->name;
993
+ }
994
+ if(!$preview){
995
+ wp_set_post_terms($translation->element_id, $updated_terms, $taxonomy);
996
+ }
997
+
998
+ }
999
+
1000
+
1001
+ }else{
1002
+ $translation_term_ids[] = $term_id_original;
1003
+ }
1004
+
1005
+ }
1006
+
1007
+ foreach($term_ids as $term_id){
1008
+
1009
+ if(!in_array($term_id, $translation_term_ids)){
1010
+ // add term
1011
+
1012
+ if($preview){
1013
+ $needs_sync = true;
1014
+ break(3);
1015
+ }
1016
+ $terms_array = array();
1017
+ $term_id_translated = icl_object_id($term_id, $taxonomy, false, $language);
1018
+
1019
+ // not using get_term
1020
+ $translated_term = $wpdb->get_row($wpdb->prepare("
1021
+ SELECT * FROM {$wpdb->terms} t JOIN {$wpdb->term_taxonomy} x ON x.term_id = t.term_id WHERE t.term_id = %d AND x.taxonomy = %s", $term_id_translated, $taxonomy));
1022
+
1023
+ if( $translated_term ){
1024
+ if(is_taxonomy_hierarchical($taxonomy)){
1025
+ $terms_array[] = $translated_term->term_id;
1026
+ } else {
1027
+ $terms_array[] = $translated_term->name;
1028
+ }
1029
+ }
1030
+
1031
+
1032
+ if(!$preview){
1033
+ wp_set_post_terms($translation->element_id, $terms_array, $taxonomy, true);
1034
+ }
1035
+
1036
+ }
1037
+
1038
+ }
1039
+
1040
+ }
1041
+
1042
+
1043
+ }
1044
+
1045
+
1046
+ }
1047
+
1048
+ $out = '';
1049
+
1050
+
1051
+ if($preview){
1052
+
1053
+ $out .= '<div class="wcml_tt_sync_row">';
1054
+ if(!empty($needs_sync)){
1055
+ $out .= '<form class="wcml_tt_do_sync">';
1056
+ $out .= '<input type="hidden" name="post" value="' . $object_type . '" />';
1057
+ $out .= '<input type="hidden" name="taxonomy" value="' . $taxonomy . '" />';
1058
+ $out .= sprintf(__('Some translated %s have different %s assignments.', 'wpml-wcml'),
1059
+ '<strong>' . mb_strtolower($wp_post_types[$object_type]->labels->name) . '</strong>',
1060
+ '<strong>' . mb_strtolower($wp_taxonomies[$taxonomy]->labels->name) . '</strong>');
1061
+ $out .= '&nbsp;<a class="submit button-secondary" href="#">' . sprintf(__('Update %s for all translated %s', 'wpml-wcml'),
1062
+ '<strong>' . mb_strtolower($wp_taxonomies[$taxonomy]->labels->name) . '</strong>',
1063
+ '<strong>' . mb_strtolower($wp_post_types[$object_type]->labels->name) . '</strong>') . '</a>' .
1064
+ '&nbsp;<img src="'. ICL_PLUGIN_URL . '/res/img/ajax-loader.gif" alt="loading" height="16" width="16" class="wpml_tt_spinner" />';
1065
+ $out .= "</form>";
1066
+ }else{
1067
+ $out .= sprintf(__('All %s have the same %s assignments.', 'wpml-wcml'),
1068
+ '<strong>' . mb_strtolower($wp_taxonomies[$taxonomy]->labels->name) . '</strong>',
1069
+ '<strong>' . mb_strtolower($wp_post_types[$object_type]->labels->name) . '</strong>');
1070
+ }
1071
+ $out .= "</div>";
1072
+
1073
+ }else{
1074
+
1075
+ $out .= sprintf(__('Successfully updated %s for all translated %s.', 'wpml-wcml'), $wp_taxonomies[$taxonomy]->labels->name, $wp_post_types[$object_type]->labels->name);
1076
+
1077
+ }
1078
+
1079
+ return $out;
1080
+
1081
  }
1082
 
1083
  function shipping_terms($terms, $post_id, $taxonomy){
menu/sub/sync-taxonomy-translations.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div class="icl_tt_main_bottom" style="display: none;">
2
+ <br/>
3
+ <?php if ( isset($attribute_taxonomies_arr) && in_array($taxonomy, $attribute_taxonomies_arr) ): ?>
4
+
5
+ <form id="wcml_tt_sync_variations" method="post">
6
+ <input type="hidden" name="action" value="wcml_sync_product_variations" />
7
+ <input type="hidden" name="taxonomy" value="<?php echo $taxonomy ?>" />
8
+ <input type="hidden" name="wcml_nonce" value="<?php echo wp_create_nonce('wcml_sync_product_variations') ?>" />
9
+ <input type="hidden" name="last_post_id" value="" />
10
+ <input type="hidden" name="languages_processed" value="0" />
11
+
12
+ <p>
13
+ <input class="button-secondary" type="submit" value="<?php esc_attr_e("Synchronize attributes and update product variations", 'wpml-wcml') ?>" />
14
+ <img src="<?php echo ICL_PLUGIN_URL . '/res/img/ajax-loader.gif' ?>" alt="loading" height="16" width="16" class="wpml_tt_spinner" />
15
+ </p>
16
+ <span class="errors icl_error_text"></span>
17
+ <div class="wcml_tt_sycn_preview"></div>
18
+ </form>
19
+
20
+
21
+ <p><?php _e('This will automatically generate variations for translated products corresponding to recently translated attributes.','wpml-wcml'); ?></p>
22
+ <?php if(!empty($wcml_settings['variations_needed'][$taxonomy])): ?>
23
+ <p><?php printf(__('Currently, there are %s variations that need to be created.', 'wpml-wcml'), '<strong>' . $wcml_settings['variations_needed'][$taxonomy] . '</strong>') ?></p>
24
+ <?php endif; ?>
25
+
26
+ <?php else: ?>
27
+
28
+ <form id="wcml_tt_sync_assignment">
29
+ <input type="hidden" name="taxonomy" value="<?php echo $taxonomy ?>"/>
30
+
31
+ <p>
32
+ <input class="button-secondary" type="submit" value="<?php printf( __( "Synchronize %s assignment in content", 'wpml-wcml' ), $taxonomy_obj->labels->name ) ?>"/>
33
+ <img src="<?php echo ICL_PLUGIN_URL . '/res/img/ajax-loader.gif' ?>" alt="loading" height="16" width="16" class="wpml_tt_spinner"/>
34
+ </p>
35
+ <span class="errors icl_error_text"></span>
36
+ </form>
37
+ <div id="wcml_tt_sync_preview"></div>
38
+
39
+
40
+ <p><?php printf( __( 'This action lets you automatically apply the %s taxonomy to your content in different languages. It will scan the original content and apply the same taxonomy to translated content.', 'wpml-wcml' ), '<i>' . $taxonomy_obj->labels->singular_name . '</i>' ); ?></p>
41
+
42
+
43
+ <?php endif; ?>
44
+
45
+ </div>
readme.txt CHANGED
@@ -5,7 +5,7 @@ Tags: CMS, woocommerce, commerce, ecommerce, e-commerce, products, WPML, multili
5
  License: GPLv2
6
  Requires at least: 3.0
7
  Tested up to: 4.0
8
- Stable tag: 3.4.1
9
 
10
  Allows running fully multilingual e-commerce sites using WooCommerce and WPML.
11
 
@@ -77,6 +77,9 @@ In order for the checkout and store pages to appear translated, you need to crea
77
 
78
  == Changelog ==
79
 
 
 
 
80
  = 3.4.1 =
81
  * Bug fix: A variable product was somtimes breaking the shopping cart
82
  * Fixes added for translating custom fields that are textareas
5
  License: GPLv2
6
  Requires at least: 3.0
7
  Tested up to: 4.0
8
+ Stable tag: 3.4.2
9
 
10
  Allows running fully multilingual e-commerce sites using WooCommerce and WPML.
11
 
77
 
78
  == Changelog ==
79
 
80
+ = 3.4.2 =
81
+ * Accommodated taxonomy translation changes in WPML
82
+
83
  = 3.4.1 =
84
  * Bug fix: A variable product was somtimes breaking the shopping cart
85
  * Fixes added for translating custom fields that are textareas
wpml-woocommerce.php CHANGED
@@ -5,12 +5,12 @@
5
  Description: Allows running fully multilingual e-Commerce sites with WooCommerce and WPML. <a href="http://wpml.org/documentation/related-projects/woocommerce-multilingual/">Documentation</a>.
6
  Author: OnTheGoSystems
7
  Author URI: http://www.onthegosystems.com/
8
- Version: 3.4.1
9
  */
10
 
11
 
12
  if(defined('WCML_VERSION')) return;
13
- define('WCML_VERSION', '3.4.1');
14
  define('WCML_PLUGIN_PATH', dirname(__FILE__));
15
  define('WCML_PLUGIN_FOLDER', basename(WCML_PLUGIN_PATH));
16
  define('WCML_PLUGIN_URL', plugins_url() . '/' . WCML_PLUGIN_FOLDER);
5
  Description: Allows running fully multilingual e-Commerce sites with WooCommerce and WPML. <a href="http://wpml.org/documentation/related-projects/woocommerce-multilingual/">Documentation</a>.
6
  Author: OnTheGoSystems
7
  Author URI: http://www.onthegosystems.com/
8
+ Version: 3.4.2
9
  */
10
 
11
 
12
  if(defined('WCML_VERSION')) return;
13
+ define('WCML_VERSION', '3.4.2');
14
  define('WCML_PLUGIN_PATH', dirname(__FILE__));
15
  define('WCML_PLUGIN_FOLDER', basename(WCML_PLUGIN_PATH));
16
  define('WCML_PLUGIN_URL', plugins_url() . '/' . WCML_PLUGIN_FOLDER);