/** * 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; }
/** * Get trid value for a specific piece of content * * @since 1.3 * @package WPML * @subpackage WPML API * * @param string $content_type Content type. * @param int $content_id Content ID. * * @return int trid or 0 for error * */ function wpml_get_content_trid($content_type, $content_id) { global $sitepress; if (!_wpml_api_allowed_content_type($content_type)) { return WPML_API_GET_CONTENT_ERROR; //WPML_API_INVALID_CONTENT_TYPE; } $trid = $sitepress->get_element_trid($content_id, $content_type); if (!$trid) { return WPML_API_GET_CONTENT_ERROR; } else { return $trid; } }