/**
  * @param string   $cms_id
  * @param bool|TranslationProxy_Service $translation_service
  *
  * @return int|null translation id for the given cms_id's target
  */
 public function get_translation_id($cms_id, $translation_service = false)
 {
     list($post_type, $element_id, , $target_lang) = $this->parse_cms_id($cms_id);
     $translation = $this->wpdb->get_row($this->wpdb->prepare("\n\t\t\t\t\t\t\t\t\t\t\t\t\tSELECT t.translation_id, j.job_id, t.element_id\n\t\t\t\t\t\t\t\t\t\t\t\t\tFROM {$this->wpdb->prefix}icl_translations t\n\t\t\t\t\t\t\t\t\t\t\t\t\tJOIN {$this->wpdb->prefix}icl_translations o\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tON o.trid = t.trid\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tAND o.element_type = t.element_type\n\t\t\t\t\t\t\t\t\t\t\t\t\tLEFT JOIN {$this->wpdb->prefix}icl_translation_status st\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tON st.translation_id = t.translation_id\n\t\t\t\t\t\t\t\t\t\t\t\t\tLEFT JOIN {$this->wpdb->prefix}icl_translate_job j\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tON j.rid = st.rid\n\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE o.element_id=%d\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tAND t.language_code=%s\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tAND o.element_type LIKE %s\n\t\t\t\t\t\t\t\t\t\t\t\t\tLIMIT 1", $element_id, $target_lang, '%_' . $post_type));
     $translation_id = $this->maybe_cleanup_broken_row($translation, $translation_service);
     if ($translation_service && !isset($translation_id) && $translation_service) {
         $job_id = $this->job_factory->create_local_post_job($element_id, $target_lang);
         $job = $this->job_factory->get_translation_job($job_id, false, false, true);
         $translation_id = $job ? $job->get_translation_id() : 0;
         if ($translation_id) {
             $this->tm_records->icl_translation_status_by_translation_id($translation_id)->update(array('status' => ICL_TM_IN_PROGRESS, 'translation_service' => $translation_service->id));
         }
     }
     return $translation_id;
 }