本文整理汇总了PHP中TranslationManagement::save_job_fields_from_post方法的典型用法代码示例。如果您正苦于以下问题:PHP TranslationManagement::save_job_fields_from_post方法的具体用法?PHP TranslationManagement::save_job_fields_from_post怎么用?PHP TranslationManagement::save_job_fields_from_post使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TranslationManagement
的用法示例。
在下文中一共展示了TranslationManagement::save_job_fields_from_post方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: icl_upgrade_2_0_0_steps
//.........这里部分代码省略.........
$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);
$TranslationManagement->save_job_fields_from_post($job_id, $post);
}
}
}
}
}
if ($processing) {
update_option('icl_temp_upgrade_data', array('step' => 2, 'offset' => intval($offset + 100)));
$stepper->setNextStep(2);
} else {
update_option('icl_temp_upgrade_data', array('step' => 3, 'offset' => 1.0E+20));
}
$message = $processing ? __('Processing translations...', 'sitepress') : __('Finalizing upgrade...', 'sitepress');
return array('message' => $message);
break;
case 3:
// removing the plugins text table; importing data into a Sitepress setting
$results = $wpdb->get_results("SELECT * FROM {$wpdb->prefix}icl_plugins_texts");
if (!empty($results)) {
foreach ($results as $row) {
$cft[$row->attribute_name] = $row->translate + 1;
}
if (isset($cft)) {
$iclsettings['translation-management']['custom_fields_translation'] = $cft;
$sitepress->save_settings($iclsettings);
}
$wpdb->query("DROP TABLE {$wpdb->prefix}icl_plugins_texts");
}
$iclsettings['language_selector_initialized'] = 1;
if (get_option('_force_mp_post_http')) {
$iclsettings['troubleshooting_options']['http_communication'] = intval(get_option('_force_mp_post_http'));
delete_option('_force_mp_post_http');
}
// set default translators
if (isset($sitepress_settings['icl_lang_status'])) {
foreach ($sitepress_settings['icl_lang_status'] as $lpair) {
if (!empty($lpair['translators'])) {
$iclsettings['default_translators'][$lpair['from']][$lpair['to']] = array('id' => $lpair['translators'][0]['id'], 'type' => 'icanlocalize');
}
}
}
$sitepress->save_settings($iclsettings);
$iclsettings['migrated_2_0_0'] = 1;
$sitepress->save_settings($iclsettings);
delete_option('icl_temp_upgrade_data');
return array('message' => __('Done', 'sitepress'), 'completed' => 1);
break;
default:
return array('error' => __('Missing step', 'sitepress'), 'stop' => 1);
}
}