本文整理汇总了PHP中TranslationManagement::get_element_translation方法的典型用法代码示例。如果您正苦于以下问题:PHP TranslationManagement::get_element_translation方法的具体用法?PHP TranslationManagement::get_element_translation怎么用?PHP TranslationManagement::get_element_translation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TranslationManagement
的用法示例。
在下文中一共展示了TranslationManagement::get_element_translation方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: end
/**
* @param WP_Post|WPML_Package $post
* @param $target_languages
* @param int $translator_id
* @param $job_id
*
* @return bool|int
*/
function send_post($post, $target_languages, $translator_id, $job_id)
{
global $sitepress, $iclTranslationManagement;
$this->maybe_init_translation_management($iclTranslationManagement);
if (is_numeric($post)) {
$post = get_post($post);
}
if (!$post) {
return false;
}
$post_id = $post->ID;
$post_type = $post->post_type;
$element_type_prefix = $iclTranslationManagement->get_element_type_prefix_from_job_id($job_id);
$element_type = $element_type_prefix . '_' . $post_type;
$note = get_post_meta($post_id, '_icl_translator_note', true);
if (!$note) {
$note = null;
}
$err = false;
$res = false;
$source_language = $sitepress->get_language_for_element($post_id, $element_type);
$target_language = is_array($target_languages) ? end($target_languages) : $target_languages;
if (empty($target_language) || $target_language === $source_language) {
return false;
}
$translation = $this->tmg->get_element_translation($post_id, $target_language, $element_type);
if (!$translation) {
// translated the first time
$err = true;
}
if (!$err && ($translation->needs_update || $translation->status == ICL_TM_NOT_TRANSLATED || $translation->status == ICL_TM_WAITING_FOR_TRANSLATOR)) {
$tp_networking = wpml_tm_load_tp_networking();
$project = $tp_networking->get_current_project();
if ($iclTranslationManagement->is_external_type($element_type_prefix)) {
$job_object = new WPML_External_Translation_Job($job_id);
} else {
$job_object = new WPML_Post_Translation_Job($job_id);
$job_object->load_terms_from_post_into_job();
}
list($err, $project, $res) = $job_object->send_to_tp($project, $translator_id, $this->cms_id_helper, $this->tmg, $note);
if ($err) {
$this->enqueue_project_errors($project);
}
}
return $err ? false : $res;
//last $ret
}