本文整理汇总了PHP中TranslationManagement::set_page_url方法的典型用法代码示例。如果您正苦于以下问题:PHP TranslationManagement::set_page_url方法的具体用法?PHP TranslationManagement::set_page_url怎么用?PHP TranslationManagement::set_page_url使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TranslationManagement
的用法示例。
在下文中一共展示了TranslationManagement::set_page_url方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: save_post_translation
//.........这里部分代码省略.........
global $wp_rewrite;
if (!isset($wp_rewrite)) {
$wp_rewrite = new WP_Rewrite();
}
kses_remove_filters();
$postarr = apply_filters('icl_pre_save_pro_translation', $postarr);
$new_post_id = wp_insert_post($postarr);
do_action('icl_pro_translation_saved', $new_post_id);
// associate custom taxonomies by hand
if (!empty($postarr['tax_input'])) {
foreach ($postarr['tax_input'] as $taxonomy => $tags) {
if ($wp_taxonomies[$taxonomy]->hierarchical) {
wp_set_post_terms($new_post_id, $tags, $taxonomy);
} else {
wp_set_post_terms($new_post_id, $translated_taxs[$taxonomy], $taxonomy);
}
}
}
// set stickiness
if ($is_original_sticky && $sitepress_settings['sync_sticky_flag']) {
stick_post($new_post_id);
} else {
if ($original_post_details->post_type == 'post' && $is_update) {
unstick_post($new_post_id);
//just in case - if this is an update and the original post stckiness has changed since the post was sent to translation
}
}
foreach ((array) $sitepress_settings['translation-management']['custom_fields_translation'] as $cf => $op) {
if ($op == 1) {
$sitepress->_sync_custom_field($translation['original_id'], $new_post_id, $cf);
} elseif ($op == 2 && isset($translation['field-' . $cf])) {
$field_translation = $translation['field-' . $cf];
$field_type = $translation['field-' . $cf . '-type'];
if ($field_type == 'custom_field') {
$field_translation = str_replace('�A;', "\n", $field_translation);
// always decode html entities eg decode & to &
$field_translation = html_entity_decode($field_translation);
update_post_meta($new_post_id, $cf, $field_translation);
}
}
}
// set specific custom fields
$copied_custom_fields = array('_top_nav_excluded', '_cms_nav_minihome');
foreach ($copied_custom_fields as $ccf) {
$val = get_post_meta($translation['original_id'], $ccf, true);
update_post_meta($new_post_id, $ccf, $val);
}
// sync _wp_page_template
if ($sitepress_settings['sync_page_template']) {
$_wp_page_template = get_post_meta($translation['original_id'], '_wp_page_template', true);
update_post_meta($new_post_id, '_wp_page_template', $_wp_page_template);
}
if (!$new_post_id) {
return false;
}
if (!$is_update) {
$wpdb->update($wpdb->prefix . 'icl_translations', array('element_id' => $new_post_id), array('translation_id' => $translation_id));
}
update_post_meta($new_post_id, '_icl_translation', 1);
TranslationManagement::set_page_url($new_post_id);
global $iclTranslationManagement;
$ts = array('status' => ICL_TM_COMPLETE, 'needs_update' => 0, 'translation_id' => $translation_id);
$translator_id = $wpdb->get_var($wpdb->prepare("SELECT translator_id FROM {$wpdb->prefix}icl_translation_status WHERE translation_id=%d", $translation_id));
if (!$translator_id) {
foreach ($sitepress_settings['icl_lang_status'] as $lpair) {
if ($lpair['from'] == $original_post_details->language_code && $lpair['to'] == $lang_code && isset($lpair['translators'][0]['id'])) {
$ts['translator_id'] = $lpair['translators'][0]['id'];
break;
}
}
}
// update translation status
$iclTranslationManagement->update_translation_status($ts);
// add new translation job
//$translation_package = $iclTranslationManagement->create_translation_package(get_post($translation['original_id']));
//$job_id = $iclTranslationManagement->add_translation_job($tinfo->rid, $tinfo->translator_id, $translation_package);
$job_id = $iclTranslationManagement->get_translation_job_id($trid, $lang_code);
// save the translation
$iclTranslationManagement->mark_job_done($job_id);
$parts = explode('_', $translation['original_id']);
if ($parts[0] != 'external') {
$iclTranslationManagement->save_job_fields_from_post($job_id, get_post($new_post_id));
$this->_content_fix_links_to_translated_content($new_post_id, $lang_code, "post_{$original_post_details->post_type}");
if (function_exists('icl_st_fix_links_in_strings')) {
icl_st_fix_links_in_strings($new_post_id);
}
// Now try to fix links in other translated content that may link to this post.
$sql = "SELECT\r\n tr.element_id\r\n FROM\r\n {$wpdb->prefix}icl_translations tr\r\n JOIN\r\n {$wpdb->prefix}icl_translation_status ts\r\n ON\r\n tr.translation_id = ts.translation_id\r\n WHERE\r\n ts.links_fixed = 0 AND tr.element_type = 'post_{$original_post_details->post_type}' AND tr.language_code = '{$lang_code}' AND tr.element_id IS NOT NULL";
$needs_fixing = $wpdb->get_results($sql);
foreach ($needs_fixing as $id) {
if ($id->element_id != $new_post_id) {
// fix all except the new_post_id. We have already done this.
$this->_content_fix_links_to_translated_content($id->element_id, $lang_code, "post_{$original_post_details->post_type}");
}
}
// if this is a parent page then make sure it's children point to this.
$this->fix_translated_children($translation['original_id'], $new_post_id, $lang_code);
}
return true;
}
示例2: save_post_translation
//.........这里部分代码省略.........
}
$_POST['trid'] = $trid;
$_POST['lang'] = $lang_code;
$_POST['skip_sitepress_actions'] = true;
global $wp_rewrite;
if (!isset($wp_rewrite)) {
$wp_rewrite = new WP_Rewrite();
}
kses_remove_filters();
$postarr = apply_filters('icl_pre_save_pro_translation', $postarr);
$new_post_id = wp_insert_post($postarr);
do_action('icl_pro_translation_saved', $new_post_id);
// set stickiness
if ($is_original_sticky && $sitepress_settings['sync_sticky_flag']) {
stick_post($new_post_id);
} else {
if ($original_post_details->post_type == 'post' && $is_update) {
unstick_post($new_post_id);
//just in case - if this is an update and the original post stckiness has changed since the post was sent to translation
}
}
foreach ((array) $sitepress_settings['translation-management']['custom_fields_translation'] as $cf => $op) {
if ($op == 1) {
$sitepress->_sync_custom_field($translation['original_id'], $new_post_id, $cf);
} elseif ($op == 2 && isset($translation['field-' . $cf])) {
$field_translation = $translation['field-' . $cf];
$field_type = $translation['field-' . $cf . '-type'];
if ($field_type == 'custom_field') {
$field_translation = str_replace('�A;', "\n", $field_translation);
// always decode html entities eg decode & to &
$field_translation = html_entity_decode($field_translation);
update_post_meta($new_post_id, $cf, $field_translation);
}
}
}
// set specific custom fields
$copied_custom_fields = array('_top_nav_excluded', '_cms_nav_minihome');
foreach ($copied_custom_fields as $ccf) {
$val = get_post_meta($translation['original_id'], $ccf, true);
update_post_meta($new_post_id, $ccf, $val);
}
// sync _wp_page_template
if ($sitepress_settings['sync_page_template']) {
$_wp_page_template = get_post_meta($translation['original_id'], '_wp_page_template', true);
update_post_meta($new_post_id, '_wp_page_template', $_wp_page_template);
}
// sync post format
if ($sitepress_settings['sync_post_format']) {
$_wp_post_format = get_post_format($translation['original_id']);
set_post_format($new_post_id, $_wp_post_format);
}
if (!$new_post_id) {
return false;
}
if (!$is_update) {
$wpdb->update($wpdb->prefix . 'icl_translations', array('element_id' => $new_post_id), array('translation_id' => $translation_id));
}
update_post_meta($new_post_id, '_icl_translation', 1);
TranslationManagement::set_page_url($new_post_id);
global $iclTranslationManagement;
$ts = array('status' => ICL_TM_COMPLETE, 'needs_update' => 0, 'translation_id' => $translation_id);
$translator_id = $wpdb->get_var($wpdb->prepare("SELECT translator_id FROM {$wpdb->prefix}icl_translation_status WHERE translation_id=%d", $translation_id));
if (!$translator_id) {
$lang_status = TranslationProxy_Translator::get_language_pairs();
foreach ($lang_status as $languages_pair) {
if ($languages_pair['from'] == $original_post_details->language_code && $languages_pair['to'] == $lang_code && isset($languages_pair['translators'][0]['id'])) {
$ts['translator_id'] = $languages_pair['translators'][0]['id'];
break;
}
}
}
// update translation status
$iclTranslationManagement->update_translation_status($ts);
// add new translation job
//$translation_package = $iclTranslationManagement->create_translation_package(get_post($translation['original_id']));
//$job_id = $iclTranslationManagement->add_translation_job($translation_info->rid, $translation_info->translator_id, $translation_package);
$job_id = $iclTranslationManagement->get_translation_job_id($trid, $lang_code);
// save the translation
$iclTranslationManagement->mark_job_done($job_id);
$parts = explode('_', $translation['original_id']);
if ($parts[0] != 'external') {
$iclTranslationManagement->save_job_fields_from_post($job_id, get_post($new_post_id));
$this->_content_fix_links_to_translated_content($new_post_id, $lang_code, "post_{$original_post_details->post_type}");
// Now try to fix links in other translated content that may link to this post.
$sql = "SELECT\n tr.element_id\n FROM\n {$wpdb->prefix}icl_translations tr\n JOIN\n {$wpdb->prefix}icl_translation_status ts\n ON\n tr.translation_id = ts.translation_id\n WHERE\n ts.links_fixed = 0 AND tr.element_type = %s AND tr.language_code = %s AND tr.element_id IS NOT NULL";
$sql_prepared = $wpdb->prepare($sql, array('post_' . $original_post_details->post_type, $lang_code));
$needs_fixing = $wpdb->get_results($sql_prepared);
foreach ($needs_fixing as $id) {
if ($id->element_id != $new_post_id) {
// fix all except the new_post_id. We have already done this.
$this->_content_fix_links_to_translated_content($id->element_id, $lang_code, "post_{$original_post_details->post_type}");
}
}
// if this is a parent page then make sure it's children point to this.
$this->fix_translated_children($translation['original_id'], $new_post_id, $lang_code);
}
WPML_Translation_Job_Terms::save_terms_from_job($job_id, $lang_code);
do_action('icl_pro_translation_completed', $new_post_id);
return true;
}