本文整理汇总了PHP中ICanLocalizeQuery::cms_requests方法的典型用法代码示例。如果您正苦于以下问题:PHP ICanLocalizeQuery::cms_requests方法的具体用法?PHP ICanLocalizeQuery::cms_requests怎么用?PHP ICanLocalizeQuery::cms_requests使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ICanLocalizeQuery
的用法示例。
在下文中一共展示了ICanLocalizeQuery::cms_requests方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: strtotime
function poll_for_translations($force = false)
{
global $sitepress_settings, $sitepress, $wpdb;
if (!$force) {
// Limit to once per hour
$toffset = strtotime(current_time('mysql')) - @intval($sitepress_settings['last_picked_up']) - 3600;
if ($toffset < 0 || $force) {
return 0;
}
}
$iclq = new ICanLocalizeQuery($sitepress_settings['site_id'], $sitepress_settings['access_key']);
$pending = $iclq->cms_requests();
$fetched = 0;
if (!empty($pending)) {
foreach ($pending as $doc) {
if (empty($doc['cms_id'])) {
// it's a string
$target = $wpdb->get_var($wpdb->prepare("SELECT target FROM {$wpdb->prefix}icl_core_status WHERE rid=%d", $doc['id']));
$__ld = $sitepress->get_language_details($target);
$language = $this->server_languages_map($__ld['english_name']);
$ret = $this->process_translated_string($doc['id'], $language);
if ($ret) {
$fetched++;
}
} else {
// decode cms_id
$int = preg_match('#(.+)_([0-9]+)_([^_]+)_([^_]+)#', $doc['cms_id'], $matches);
$_element_type = $matches[1];
$_element_id = $matches[2];
$_original_lang = $matches[3];
$_lang = $matches[4];
$trid = $sitepress->get_element_trid($_element_id, 'post_' . $_element_type);
$translation = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->prefix}icl_translations WHERE trid=%d AND language_code=%s", $trid, $_lang));
$ret = $this->add_translated_document($translation->translation_id, $doc['id']);
if ($ret) {
$fetched++;
}
}
}
}
$iclsettings['last_picked_up'] = strtotime(current_time('mysql'));
$sitepress->save_settings($iclsettings);
return $fetched;
}