本文整理匯總了PHP中ICanLocalizeQuery::update_cms_id方法的典型用法代碼示例。如果您正苦於以下問題:PHP ICanLocalizeQuery::update_cms_id方法的具體用法?PHP ICanLocalizeQuery::update_cms_id怎麽用?PHP ICanLocalizeQuery::update_cms_id使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類ICanLocalizeQuery
的用法示例。
在下文中一共展示了ICanLocalizeQuery::update_cms_id方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: ICanLocalizeQuery
case 'icl_cms_id_fix':
$iclq = new ICanLocalizeQuery($sitepress_settings['site_id'], $sitepress_settings['access_key']);
$p = $wpdb->get_row("SELECT t.* FROM {$wpdb->prefix}icl_translations t JOIN {$wpdb->prefix}icl_translation_status s ON t.translation_id=s.translation_id\n WHERE t.element_type LIKE 'post\\_%' AND t.source_language_code IS NOT NULL AND s.translation_service='icanlocalize' LIMIT {$_REQUEST['offset']}, 1");
if (!empty($p)) {
$original_id = $wpdb->get_var($wpdb->prepare("SELECT element_id FROM {$wpdb->prefix}icl_translations WHERE trid=%d AND source_language_code IS NULL", $p->trid));
if ($p->element_type == 'post_page') {
$permalink = get_option('home') . '?page_id=' . $original_id;
} else {
$permalink = get_option('home') . '?p=' . $original_id;
}
$_lang_details = $sitepress->get_language_details($p->source_language_code);
$from_language = ICL_Pro_Translation::server_languages_map($_lang_details['english_name']);
$_lang_details = $sitepress->get_language_details($p->language_code);
$to_language = ICL_Pro_Translation::server_languages_map($_lang_details['english_name']);
$cms_id = sprintf('%s_%d_%s_%s', preg_replace('#^post_#', '', $p->element_type), $original_id, $p->source_language_code, $p->language_code);
$ret = $iclq->update_cms_id(compact('permalink', 'from_language', 'to_language', 'cms_id'));
if ($ret != $cms_id && $iclq->error()) {
echo json_encode(array('errors' => 1, 'message' => $iclq->error(), 'cont' => 0));
} else {
echo json_encode(array('errors' => 0, 'message' => 'OK', 'cont' => 1));
}
} else {
echo json_encode(array('errors' => 0, 'message' => __('Done', 'sitepress'), 'cont' => 0));
}
exit;
//break;
//break;
case 'icl_cleanup':
global $sitepress, $wpdb, $wp_post_types;
$post_types = array_keys($wp_post_types);
foreach ($post_types as $pt) {