本文整理汇总了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) {