本文整理汇总了PHP中ICanLocalizeQuery::error方法的典型用法代码示例。如果您正苦于以下问题:PHP ICanLocalizeQuery::error方法的具体用法?PHP ICanLocalizeQuery::error怎么用?PHP ICanLocalizeQuery::error使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ICanLocalizeQuery
的用法示例。
在下文中一共展示了ICanLocalizeQuery::error方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ICanLocalizeQuery
$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) {
$types[] = 'post_' . $pt;
示例2: ICanLocalizeQuery
/**
* Sends the translation snapshot to ICanLocalize.
*
* @param $array $params The parameters to be added when sending the snapshot
*/
function send_translation_snapshot_to_icl($params)
{
global $sitepress, $sitepress_settings;
$params['accesskey'] = $sitepress_settings['access_key'];
$params['website_id'] = $sitepress_settings['site_id'];
require_once ICL_PLUGIN_PATH . '/lib/Snoopy.class.php';
require_once ICL_PLUGIN_PATH . '/lib/xml2array.php';
require_once ICL_PLUGIN_PATH . '/lib/icl_api.php';
$icl_query = new ICanLocalizeQuery();
$request = ICL_API_ENDPOINT . "/translation_snapshots/create_by_cms.xml";
$response = $icl_query->_request($request, 'POST', $params);
if (!$response) {
error_log('Translation Analytics: Could not send translation snapshot:\\n' . $icl_query->error());
}
}