/**
  * Saves all taxonomy term data from a job to the database.
  *
  * @param $job_id Integer
  * @param $target_language_code String
  */
 public static function save_terms_from_job($job_id, $target_language_code)
 {
     /** @var SitePress $sitepress */
     global $sitepress;
     if ($sitepress->get_setting('tm_block_retranslating_terms')) {
         self::set_translated_term_values($job_id, false);
     }
     $terms = self::get_terms_affected_by_job_new_format($job_id);
     foreach ($terms as $term) {
         $new_term_action = new WPML_Update_Term_Action(array('term' => base64_decode($term->field_data_translated), 'lang_code' => $target_language_code, 'trid' => $term->trid, 'taxonomy' => $term->taxonomy));
         $new_term_action->execute();
     }
 }
 function save_terms_to_post()
 {
     /** @var SitePress $sitepress */
     global $sitepress, $wpdb;
     $lang_code = $this->get_language_code();
     if ($sitepress->get_setting('tm_block_retranslating_terms')) {
         $this->load_terms_from_post_into_job(true);
     }
     $terms = $this->get_terms_in_job_rows();
     foreach ($terms as $term) {
         $new_term_action = new WPML_Update_Term_Action($wpdb, $sitepress, array('term' => base64_decode($term->field_data_translated), 'lang_code' => $lang_code, 'trid' => $term->trid, 'taxonomy' => $term->taxonomy));
         $new_term_action->execute();
     }
     $term_helper = wpml_get_term_translation_util();
     $term_helper->sync_terms($this->get_original_element_id(), $this->get_language_code());
 }
 /**
  * Creates a new term from an argument array.
  * @param array $args
  * @return array|bool
  * Returns either an array containing the term_id and term_taxonomy_id of the term resulting from this database
  * write or false on error.
  */
 public static function create_new_term($args)
 {
     global $wpdb, $sitepress;
     /** @var string $taxonomy */
     $taxonomy = false;
     /** @var string $lang_code */
     $lang_code = false;
     /**
      * Sets whether translations of posts are to be updated by the newly created term,
      * should they be missing a translation still.
      * During debug actions designed to synchronise post and term languages this should not be set to true,
      * doing so introduces the possibility of removing terms from posts before switching
      * them with their translation in the correct language.
      * @var  bool
      */
     $sync = false;
     extract($args, EXTR_OVERWRITE);
     require_once dirname(__FILE__) . '/wpml-update-term-action.class.php';
     $new_term_action = new WPML_Update_Term_Action($wpdb, $sitepress, $args);
     $new_term = $new_term_action->execute();
     if ($sync && $new_term && $taxonomy && $lang_code) {
         self::sync_taxonomy_terms_language($taxonomy);
     }
     return $new_term;
 }