/**
  * Fixes parents of translations for hierarchical post types
  *
  * User changed parent for a post in $post_type and we are setting proper parent for $translation_id in
  * $language_code_translated language
  *
  * @param string $post_type - post_type that should have the translated parents fixed
  */
 private function maybe_fix_translated_parent($post_type)
 {
     if ($this->sync_parent) {
         $sync_helper = wpml_get_hierarchy_sync_helper();
         $sync_helper->sync_element_hierarchy($post_type);
     }
 }
 public function ajax_sync_save()
 {
     if (!wpml_is_action_authenticated('wpml_tt_sync_hierarchy')) {
         wp_send_json_error('Wrong Nonce');
     }
     $sync_helper = wpml_get_hierarchy_sync_helper('term');
     list($taxonomy, $ref_lang) = $this->get_req_data();
     if ($taxonomy) {
         $sync_helper->sync_element_hierarchy($taxonomy, $ref_lang);
         wp_send_json_success(1);
     } else {
         wp_send_json_error('No taxonomy in request!');
     }
 }
 private function get_need_sync_all_terms($translated_taxonomies, $post_ids)
 {
     $hierarchy_sync_helper = wpml_get_hierarchy_sync_helper('term');
     $post_ids_in = wpml_prepare_in((array) $post_ids, '%d');
     $taxonomies_in = wpml_prepare_in($translated_taxonomies);
     $this->wpdb->get_col("SELECT DISTINCT tt.taxonomy\n\t\t\t\t\t\t FROM {$this->wpdb->term_taxonomy} tt\n\t\t\t\t\t\t JOIN {$this->wpdb->term_relationships} tr\n\t\t\t\t\t\t  ON tt.term_taxonomy_id = tr.term_taxonomy_id\n\t\t\t\t\t\t WHERE tr.object_id IN ({$post_ids_in}) AND tt.taxonomy IN ({$taxonomies_in})");
     foreach ($translated_taxonomies as $key => $tax) {
         $unsynced_terms = $hierarchy_sync_helper->get_unsynced_elements($tax, $this->sitepress->get_default_language());
         if ((bool) $unsynced_terms === false) {
             unset($translated_taxonomies[$key]);
         }
     }
     return $translated_taxonomies;
 }