本文整理汇总了PHP中ICanLocalizeQuery::cms_create_message方法的典型用法代码示例。如果您正苦于以下问题:PHP ICanLocalizeQuery::cms_create_message方法的具体用法?PHP ICanLocalizeQuery::cms_create_message怎么用?PHP ICanLocalizeQuery::cms_create_message使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ICanLocalizeQuery
的用法示例。
在下文中一共展示了ICanLocalizeQuery::cms_create_message方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ICanLocalizeQuery
function send_comment_to_translation($comment_id, $to_language)
{
global $wpdb, $sitepress_settings, $sitepress;
$iclq = new ICanLocalizeQuery($sitepress_settings['site_id'], $sitepress_settings['access_key']);
$from_lang = $sitepress->get_language_details($this->user_language);
$to_lang = $sitepress->get_language_details($to_language);
$from_lang_server = ICL_Pro_Translation::server_languages_map($from_lang['english_name']);
$to_lang_server = ICL_Pro_Translation::server_languages_map($to_lang['english_name']);
$body = $wpdb->get_var("SELECT comment_content FROM {$wpdb->comments} WHERE comment_ID={$comment_id}");
$rid = $iclq->cms_create_message($body, $from_lang_server, $to_lang_server);
if ($rid > 0) {
// does this comment already exist in the messages status queue?
$msid = $wpdb->get_var("SELECT id FROM {$wpdb->prefix}icl_message_status WHERE object_type='comment' AND object_id={$comment_id}");
if ($msid) {
$wpdb->update($wpdb->prefix . 'icl_message_status', array('rid' => $rid, 'md5' => md5($body), 'status' => MESSAGE_TRANSLATION_IN_PROGRESS), array('id' => $msid));
} else {
$wpdb->insert($wpdb->prefix . 'icl_message_status', array('rid' => $rid, 'object_id' => $comment_id, 'from_language' => $this->user_language, 'to_language' => $to_language, 'md5' => md5($body), 'object_type' => 'comment', 'status' => MESSAGE_TRANSLATION_IN_PROGRESS));
}
}
}
示例2: wpml_send_content_to_translation
/**
* Sends piece of content (string) to professional translation @ ICanLocalize
*
* @since 1.3
* @package WPML
* @subpackage WPML API
*
* @param string $string String
* @param string $from_language Language to translate from
* @param int $content_id Content ID
* @param string $content_type Content Type
* @param string $to_language Language to translate into
*
* @return int request id
* */
function wpml_send_content_to_translation($string, $content_id, $content_type, $from_language, $to_language)
{
global $sitepress, $sitepress_settings, $wpdb;
if (!_wpml_api_allowed_content_type($content_type)) {
return 0;
//WPML_API_INVALID_CONTENT_TYPE
}
if (!$sitepress->get_language_details($from_language) || !$sitepress->get_language_details($to_language)) {
return 0;
// WPML_API_INVALID_LANGUAGE_CODE
}
$from_lang = $sitepress->get_language_details($from_language);
$to_lang = $sitepress->get_language_details($to_language);
$from_lang_server = apply_filters('icl_server_languages_map', $from_lang['english_name']);
$to_lang_server = apply_filters('icl_server_languages_map', $to_lang['english_name']);
$iclq = new ICanLocalizeQuery($sitepress_settings['site_id'], $sitepress_settings['access_key']);
$rid = $iclq->cms_create_message($string, $from_lang_server, $to_lang_server);
if ($rid > 0) {
// does this comment already exist in the messages status queue?
$msid = $wpdb->get_var($wpdb->prepare(" SELECT id\n FROM {$wpdb->prefix}icl_message_status\n WHERE object_type = %s\n AND object_id = %d", $content_type, $content_id));
if ($msid) {
$wpdb->update($wpdb->prefix . 'icl_message_status', array('rid' => $rid, 'md5' => md5($string), 'status' => MESSAGE_TRANSLATION_IN_PROGRESS), array('id' => $msid));
} else {
$wpdb->insert($wpdb->prefix . 'icl_message_status', array('rid' => $rid, 'object_id' => $content_id, 'from_language' => $from_language, 'to_language' => $to_language, 'md5' => md5($string), 'object_type' => $content_type, 'status' => MESSAGE_TRANSLATION_IN_PROGRESS));
}
}
return $rid;
}