';
break;
case 'validate_language_domain':
if(false === strpos($_POST['url'],'?')){$url_glue='?';}else{$url_glue='&';}
$url = $_POST['url'] . $url_glue . '____icl_validate_domain=1';
$client = new WP_Http();
$response = $client->request($url, 'timeout=15');
if(!is_wp_error($response) && ($response['response']['code']=='200') && ($response['body'] == '')){
echo 1;
}else{
echo 0;
}
break;
case 'icl_navigation_form':
$iclsettings = $this->get_settings();
$iclsettings['modules']['cms-navigation']['page_order'] = $_POST['icl_navigation_page_order'];
$iclsettings['modules']['cms-navigation']['show_cat_menu'] = $_POST['icl_navigation_show_cat_menu'];
if($_POST['icl_navigation_cat_menu_title']){
$iclsettings['modules']['cms-navigation']['cat_menu_title'] = stripslashes($_POST['icl_navigation_cat_menu_title']);
icl_register_string('WPML', 'Categories Menu', stripslashes($_POST['icl_navigation_cat_menu_title']));
}
$iclsettings['modules']['cms-navigation']['cat_menu_page_order'] = $_POST['icl_navigation_cat_menu_page_order'];
$iclsettings['modules']['cms-navigation']['cat_menu_contents'] = $_POST['icl_blog_menu_contents'];
$iclsettings['modules']['cms-navigation']['heading_start'] = stripslashes($_POST['icl_navigation_heading_start']);
$iclsettings['modules']['cms-navigation']['heading_end'] = stripslashes($_POST['icl_navigation_heading_end']);
$iclsettings['modules']['cms-navigation']['cache'] = $_POST['icl_navigation_caching'];
$iclsettings['modules']['cms-navigation']['breadcrumbs_separator'] = stripslashes($_POST['icl_breadcrumbs_separator']);
$this->save_settings($iclsettings);
// clear the cms navigation caches
$this->icl_cms_nav_offsite_url_cache->clear();
@mysql_query("TRUNCATE {$wpdb->prefix}icl_cms_nav_cache");
echo '1|';
break;
case 'icl_clear_nav_cache':
// clear the cms navigation caches
$this->icl_cms_nav_offsite_url_cache->clear();
@mysql_query("TRUNCATE {$wpdb->prefix}icl_cms_nav_cache");
echo '1|';
case 'send_translation_request':
global $iclTranslationManagement, $current_user;
$post_ids = explode(',',$_POST['post_ids']);
$target_languages = explode('#', $_POST['target_languages']);
$post_types = $_POST['icl_post_type'];
get_currentuserinfo();
$translator_id = isset($_POST['translator_id']) ? $_POST['translator_id'] : $current_user->ID;
foreach($post_ids as $post_id){
if(isset($_POST['tn_note_'.$post_id]) && trim($_POST['tn_note_'.$post_id])){
update_post_meta($post_id, '_icl_translator_note', $_POST['tn_note_'.$post_id]);
}
foreach($target_languages as $to_lang){
$from_lang = $wpdb->get_var($wpdb->prepare("SELECT language_code FROM {$wpdb->prefix}icl_translations WHERE element_id=%d AND element_type=%s",
$post_id, 'post_'.$post_types[$post_id]));
$data = array(
'translate_from' => $from_lang,
'translate_to' => array($to_lang=>1),
'iclpost' => array($post_id),
'service' => 'icanlocalize',
'iclnonce' => wp_create_nonce('pro-translation-icl')
);
$jd = $iclTranslationManagement->send_jobs($data);
$resp[] = array(
'post_id' => $post_id,
'status' => !empty($jd)
);
}
/*
$resp[] = array(
'post_id'=>$post_id,
'status'=>$ICL_Pro_Translation->send_post($post_id, $target_languages, $translator_id)
);
*/
}
echo json_encode($resp);
break;
case 'get_translator_status':
if(!$this->icl_account_configured()) break;
$iclsettings = $this->get_settings();
if(isset($_POST['cache'])) {
$last_call = $iclsettings['last_get_translator_status_call'];
if ($time - $last_call < 24 * 60 * 60) {
break;
}
}
$iclsettings['last_get_translator_status_call'] = time();
$this->get_icl_translator_status($iclsettings);
$this->save_settings($iclsettings);
echo json_encode($iclsettings['icl_lang_status']);
break;
case 'get_language_status_text':
if(!$this->icl_account_configured()) break;
$iclsettings = $this->get_settings();
if(!isset($_POST['cache'])) {
$iclsettings = $this->get_settings();
$this->get_icl_translator_status($iclsettings);
$this->save_settings($iclsettings);
}
echo '1|' . $_POST['id'] . '|' . $this->get_language_status_text($_POST['from_lang'], $_POST['to_lang']);
break;
case 'set_post_to_date':
$nid = (int) $_POST['post_id'];
$md5 = $wpdb->get_var("SELECT md5 FROM {$wpdb->prefix}icl_node WHERE nid={$nid}");
$wpdb->query("UPDATE {$wpdb->prefix}icl_content_status SET md5 = '{$md5}' WHERE nid='{$nid}'");
echo __('Needs update','sitepress');
echo '|';
echo __('Complete','sitepress');
break;
case 'icl_st_save_translation':
$icl_st_complete = isset($_POST['icl_st_translation_complete'])?$_POST['icl_st_translation_complete']:ICL_STRING_TRANSLATION_NOT_TRANSLATED;
if ( get_magic_quotes_gpc() ){
$_POST = stripslashes_deep( $_POST );
}
echo icl_add_string_translation($_POST['icl_st_string_id'], $_POST['icl_st_language'], stripslashes($_POST['icl_st_translation']), $icl_st_complete);
echo '|';
global $icl_st_string_translation_statuses;
echo $icl_st_string_translation_statuses[icl_update_string_status($_POST['icl_st_string_id'])];
break;
case 'icl_st_delete_strings':
$arr = explode(',',$_POST['value']);
__icl_unregister_string_multi($arr);
break;
case 'icl_st_send_strings':
$arr = explode(',',$_POST['strings']);
icl_translation_send_strings($arr, explode('#',$_POST['languages']));
echo '1';
break;
case 'icl_st_send_strings_all':
icl_translation_send_untranslated_strings(explode(',',$_POST['languages']));
echo '1';
break;
case 'icl_save_theme_localization_type':
$icl_tl_type = (int)$_POST['icl_theme_localization_type'];
$iclsettings['theme_localization_type'] = $icl_tl_type;
if($icl_tl_type==1){
icl_st_scan_theme_files();
}
$this->save_settings($iclsettings);
echo '1|'.$icl_tl_type;
break;
case 'icl_tl_rescan':
$scan_stats = icl_st_scan_theme_files();
if($_POST['icl_load_mo']){
$mo_files = icl_st_get_mo_files(TEMPLATEPATH);
foreach((array)$mo_files as $m){
$i = preg_match('#[-]?([a-z_]+)\.mo$#i', $m, $matches);
if($i && $lang = $wpdb->get_var("SELECT code FROM {$wpdb->prefix}icl_locale_map WHERE locale='".$matches[1]."'")){
$tr_pairs = icl_st_load_translations_from_mo($m);
foreach($tr_pairs as $original=>$translation){
foreach($this->settings['st']['theme_localization_domains'] as $tld){
$string_id = icl_get_string_id($original, 'theme ' . $tld);
if($string_id){
break;
}
}
if(!$wpdb->get_var{"SELECT id FROM {$wpdb->prefix}icl_string_translations WHERE string_id={$string_id} AND language='{$lang}'"}){
icl_add_string_translation($string_id, $lang, $translation, ICL_STRING_TRANSLATION_COMPLETE);
}
}
}
}
}
echo '1|'.$scan_stats;
break;
case 'icl_tl_rescan_p':
set_time_limit(0);
if(preg_replace('#M$#', '', ini_get('memory_limit')) < 128) ini_set('memory_limit', '128M');
$plugins = array();
foreach((array)$_POST['plugin'] as $plugin){
$plugins[] = array('file'=>$plugin, 'mu'=>0); // regular plugins
}
foreach((array)$_POST['mu-plugin'] as $plugin){
$plugins[] = array('file'=>$plugin, 'mu'=>1); //mu plugins
}
$scan_stats = '';
foreach($plugins as $p){
$plugin = $p['file'];
if(false !== strpos($plugin, '/') && !$p['mu']){
$plugin = dirname($plugin);
}
if($p['mu']){
$plugin_path = WPMU_PLUGIN_DIR . '/' . $plugin;
}else{
$plugin_path = WP_PLUGIN_DIR . '/' . $plugin;
}
$scan_stats .= icl_st_scan_plugin_files($plugin_path);
if($_POST['icl_load_mo'] && !$p['mu']){
$mo_files = icl_st_get_mo_files($plugin_path);
foreach($mo_files as $m){
$i = preg_match('#[-]([a-z_]+)\.mo$#i', $m, $matches);
if($i && $lang = $wpdb->get_var("SELECT code FROM {$wpdb->prefix}icl_locale_map WHERE locale='".$matches[1]."'")){
$tr_pairs = icl_st_load_translations_from_mo($m);
foreach($tr_pairs as $original=>$translation){
$string_id = icl_get_string_id($original, 'plugin ' . basename($plugin_path));
if(!$wpdb->get_var{"SELECT id FROM {$wpdb->prefix}icl_string_translations WHERE string_id={$string_id} AND language='{$lang}'"}){
icl_add_string_translation($string_id, $lang, $translation, ICL_STRING_TRANSLATION_COMPLETE);
}
}
}
}
}
}
echo '1|' . $scan_stats;
break;
case 'save_ct_user_pref':
$users = $wpdb->get_col("SELECT id FROM {$wpdb->users}");
foreach($users as $uid){
if(isset($_POST['icl_enable_comments_translation'][$uid])){
update_usermeta($uid, 'icl_enable_comments_translation', 1);
}else{
delete_usermeta($uid, 'icl_enable_comments_translation');
}
if(isset($_POST['icl_enable_replies_translation'][$uid])){
update_usermeta($uid, 'icl_enable_replies_translation', 1);
}else{
delete_usermeta($uid, 'icl_enable_replies_translation');
}
}
echo '1|';
break;
case 'get_original_comment':
$comment_id = $_POST['comment_id'];
$trid = $this->get_element_trid($comment_id, 'comment');
$res = $wpdb->get_row("SELECT element_id, language_code FROM {$wpdb->prefix}icl_translations WHERE trid='{$trid}' AND element_type='comment' AND element_id <> {$comment_id} ");
$original_cid = $res->element_id;
$comment = $wpdb->get_row("SELECT * FROM {$wpdb->comments} WHERE comment_ID={$original_cid}");
$comment->language_code = $res->language_code;
if($res->language_code == $IclCommentsTranslation->user_language){
$comment->translated_version = 1;
}else{
$comment->translated_version = 0;
$comment->anchor_text = __('Back to translated version', 'sitepress');
}
echo json_encode($comment);
break;
case 'dismiss_help':
$iclsettings['dont_show_help_admin_notice'] = true;
$this->save_settings($iclsettings);
break;
case 'dismiss_page_estimate_hint':
$iclsettings['dismiss_page_estimate_hint'] = !$this->settings['dismiss_page_estimate_hint'];
$this->save_settings($iclsettings);
break;
case 'toggle_pt_controls':
$iclsettings['hide_professional_translation_controls'] = $_POST['value'];
$this->save_settings($iclsettings);
break;
case 'dismiss_upgrade_notice':
$iclsettings['hide_upgrade_notice'] = implode('.', array_slice(explode('.', ICL_SITEPRESS_VERSION), 0, 3));
$this->save_settings($iclsettings);
break;
case 'setup_got_to_step1':
$iclsettings['existing_content_language_verified'] = 0;
$iclsettings['setup_wizard_step'] = 1;
@mysql_query("TRUNCATE TABLE {$wpdb->prefix}icl_translations");
$this->save_settings($iclsettings);
break;
case 'setup_got_to_step2':
$iclsettings['setup_wizard_step'] = 2;
$this->save_settings($iclsettings);
break;
case 'setup_got_to_step3':
$iclsettings['setup_wizard_step'] = 3;
$this->save_settings($iclsettings);
break;
case 'toggle_show_translations':
$iclsettings = $this->get_settings();
$iclsettings['show_translations_flag'] = intval(!$iclsettings['show_translations_flag']);
$this->save_settings($iclsettings);
break;
case 'icl_messages':
$iclsettings = $this->get_settings();
if($iclsettings['site_id'] && $iclsettings['access_key'] && empty($iclsettings['icl_anonymous_user'])){
$iclq = new ICanLocalizeQuery($iclsettings['site_id'], $iclsettings['access_key']);
$output = '';
if (isset($_POST['refresh']) && $_POST['refresh'] == 1) {
$reminders = $iclq->get_reminders(true);
} else {
$reminders = $iclq->get_reminders();
}
$count = 0;
foreach($reminders as $r) {
$message = $r->message;
$message = str_replace('[', '<', $message);
$message = str_replace(']', '>', $message);
$url = $r->url;
$anchor_pos = strpos($url, '#');
if ($anchor_pos !== false) {
$url = substr($url, 0, $anchor_pos);
}
if(false !== strpos($url,'?')){
$url_glue = '&';
}else{
$url_glue = '?accesskey='.$this->settings['access_key'] . '&compact=1';
}
$output .= $message . ' - ' . $this->create_icl_popup_link(ICL_API_ENDPOINT. $url . $url_glue . '&message_id=' . $r->id. '&TB_iframe=true') . __('View', 'sitepress') . '';
if ($r->can_delete == '1') {
$on_click = 'dismiss_message(' . $r->id . ');';
$output .= ' -