本文整理汇总了PHP中SitePress::get_element_translations方法的典型用法代码示例。如果您正苦于以下问题:PHP SitePress::get_element_translations方法的具体用法?PHP SitePress::get_element_translations怎么用?PHP SitePress::get_element_translations使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SitePress
的用法示例。
在下文中一共展示了SitePress::get_element_translations方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: init_original_post
private function init_original_post()
{
// we do not need the original document of the job here
// but the document with the same trid and in the $this->job->source_language_code
$this->all_translations = $this->sitepress->get_element_translations($this->job->trid, $this->job->original_post_type);
$this->original_post = false;
foreach ($this->all_translations as $t) {
if ($t->language_code === $this->job->source_language_code) {
$this->original_post = $this->sitepressTM->get_post($t->element_id, $this->job->element_type_prefix);
//if this fails for some reason use the original doc from which the trid originated
$this->original_post = $this->original_post ? $this->original_post : $this->sitepressTM->get_post($this->job->original_doc_id, $this->job->element_type_prefix);
break;
}
}
}
示例2:
function get_post_translations()
{
$element_type = $this->package->get_package_element_type();
$trid = $this->sitepress->get_element_trid($this->package->ID, $element_type);
return $this->sitepress->get_element_translations($trid, $element_type);
}
示例3: icl_upgrade_2_0_0_steps
function icl_upgrade_2_0_0_steps($step, $stepper)
{
global $wpdb, $sitepress, $wp_post_types, $sitepress_settings;
if (!isset($sitepress)) {
$sitepress = new SitePress();
}
$TranslationManagement = new TranslationManagement();
$default_language = $sitepress->get_default_language();
define('ICL_TM_DISABLE_ALL_NOTIFICATIONS', true);
// make sure no notifications are being sent
//if(defined('icl_upgrade_2_0_0_runonce')){
// return;
//}
//define('icl_upgrade_2_0_0_runonce', true);
// fix source_language_code
// assume that the lowest element_id is the source language
ini_set('max_execution_time', 300);
$post_types = array_keys($wp_post_types);
foreach ($post_types as $pt) {
$types[] = 'post_' . $pt;
}
$temp_upgrade_data = get_option('icl_temp_upgrade_data', array('step' => 0, 'offset' => 0));
switch ($step) {
case 1:
// if the tables are missing, call the plugin activation routine
$table_name = $wpdb->prefix . 'icl_translation_status';
if ($wpdb->get_var("SHOW TABLES LIKE '{$table_name}'") != $table_name) {
icl_sitepress_activate();
}
$wpdb->query("ALTER TABLE `{$wpdb->prefix}icl_translations` CHANGE `element_type` `element_type` VARCHAR( 32 ) NOT NULL DEFAULT 'post_post'");
$wpdb->query("ALTER TABLE `{$wpdb->prefix}icl_translations` CHANGE `element_id` `element_id` BIGINT( 20 ) NULL DEFAULT NULL ");
// fix source_language_code
// all source documents must have null
if (isset($types)) {
$wpdb->query($wpdb->prepare("UPDATE {$wpdb->prefix}icl_translations SET source_language_code = NULL\n\t\t\t\t\tWHERE element_type IN('" . join("','", $types) . "') AND source_language_code = '' AND language_code=%s", $default_language));
// get translated documents with missing source language
$res = $wpdb->get_results($wpdb->prepare("\n\t\t\t\t\tSELECT translation_id, trid, language_code\n\t\t\t\t\tFROM {$wpdb->prefix}icl_translations\n\t\t\t\t\tWHERE (source_language_code = '' OR source_language_code IS NULL)\n\t\t\t\t\t\tAND element_type IN('" . join("','", $types) . "')\n\t\t\t\t\t\tAND language_code <> %s\n\t\t\t\t\t\t", $default_language));
foreach ($res as $row) {
$wpdb->query($wpdb->prepare("UPDATE {$wpdb->prefix}icl_translations SET source_language_code = %s WHERE translation_id=%d", $default_language, $row->translation_id));
}
}
$temp_upgrade_data['step'] = 2;
update_option('icl_temp_upgrade_data', $temp_upgrade_data);
return array('message' => __('Processing translations...', 'sitepress'));
break;
case 2:
$limit = 100;
$offset = $temp_upgrade_data['offset'];
$processing = FALSE;
//loop existing translations
if (isset($types)) {
$res = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->prefix}icl_translations\n WHERE element_type IN(" . wpml_prepare_in($types) . " )\n AND source_language_code IS NULL LIMIT %d OFFSET %d", array($limit, $offset)));
foreach ($res as $row) {
$processing = TRUE;
// grab translations
$translations = $sitepress->get_element_translations($row->trid, $row->element_type);
$md5 = 0;
$table_name = $wpdb->prefix . 'icl_node';
if ($wpdb->get_var("SHOW TABLES LIKE '{$table_name}'") == $table_name) {
list($md5, $links_fixed) = $wpdb->get_row($wpdb->prepare("\n\t\t\t\t\t\t\tSELECT md5, links_fixed FROM {$wpdb->prefix}icl_node\n\t\t\t\t\t\t\tWHERE nid = %d\n\t\t\t\t\t\t", $row->element_id), ARRAY_N);
}
if (!$md5) {
$md5 = $TranslationManagement->post_md5($row->element_id);
}
$translation_package = $TranslationManagement->create_translation_package($row->element_id);
foreach ($translations as $lang => $t) {
if (!$t->original) {
// determine service and status
$service = 'local';
$needs_update = 0;
list($rid, $status, $current_md5) = $wpdb->get_row($wpdb->prepare("\n\t\t\t\t\t\t\t\tSELECT c.rid, n.status , c.md5\n\t\t\t\t\t\t\t\tFROM {$wpdb->prefix}icl_content_status c\n\t\t\t\t\t\t\t\t\tJOIN {$wpdb->prefix}icl_core_status n ON c.rid = n.rid\n\t\t\t\t\t\t\t\tWHERE c.nid = %d AND target = %s\n\t\t\t\t\t\t\t\tORDER BY rid DESC\n\t\t\t\t\t\t\t\tLIMIT 1\n\t\t\t\t\t\t\t", $row->element_id, $lang), ARRAY_N);
$translator_id = false;
if ($rid) {
if ($current_md5 != $md5) {
$needs_update = 1;
}
if ($status == 3) {
$status = 10;
} else {
$status = 2;
}
$service = 'icanlocalize';
foreach ($sitepress_settings['icl_lang_status'] as $lpair) {
if ($lpair['from'] == $row->language_code && $lpair['to'] == $lang && isset($lpair['translators'][0]['id'])) {
$translator_id = $lpair['translators'][0]['id'];
break;
}
}
} else {
$status = 10;
$translator_id = $wpdb->get_var($wpdb->prepare("SELECT post_author FROM {$wpdb->posts} WHERE ID=%d", $t->element_id));
$tlp = get_user_meta($translator_id, $wpdb->prefix . 'language_pairs', true);
$tlp[$row->language_code][$lang] = 1;
$TranslationManagement->edit_translator($translator_id, $tlp);
}
// add translation_status record
list($newrid) = $TranslationManagement->update_translation_status(array('translation_id' => $t->translation_id, 'status' => $status, 'translator_id' => $translator_id, 'needs_update' => $needs_update, 'md5' => $md5, 'translation_service' => $service, 'translation_package' => serialize($translation_package), 'links_fixed' => intval(isset($links_fixed) ? $links_fixed : 0)));
$job_id = $TranslationManagement->add_translation_job($newrid, $translator_id, $translation_package);
if ($job_id && $status == 10) {
$post = get_post($t->element_id);
//.........这里部分代码省略.........
示例4: get_translations
public function get_translations()
{
$trid = $this->sitepress->get_element_trid($this->wp_post->ID, $this->element_type);
return $this->sitepress->get_element_translations($trid, $this->element_type);
}