';
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 '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]));
foreach($target_languages as $_lg){
$translator[$_lg] = 0 ;
}
$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'),
'translator' => $translator
);
$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 = @intval($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|' . intval($_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_theme_localization_type':
$icl_tl_type = @intval($_POST['icl_theme_localization_type']);
$iclsettings['theme_localization_type'] = $icl_tl_type;
$iclsettings['theme_localization_load_textdomain'] = @intval($_POST['icl_theme_localization_load_td']);
$iclsettings['gettext_theme_domain_name'] = $_POST['textdomain_value'];
if($icl_tl_type==1){
icl_st_scan_theme_files();
}elseif($icl_tl_type==2){
$parent_theme = get_template_directory();
$child_theme = get_stylesheet_directory();
$languages_folders = array();
if($found_folder = icl_tf_determine_mo_folder($parent_theme)){
$languages_folders['parent'] = $found_folder;
}
if($parent_theme != $child_theme && $found_folder = icl_tf_determine_mo_folder($child_theme)){
$languages_folders['child'] = $found_folder;
}
$iclsettings['theme_language_folders'] = $languages_folders;
}
$this->save_settings($iclsettings);
echo '1|'.$icl_tl_type;
break;
case 'icl_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_user_meta($uid, 'icl_enable_comments_translation', 1);
}else{
delete_user_meta($uid, 'icl_enable_comments_translation');
}
if(isset($_POST['icl_enable_replies_translation'][$uid])){
update_user_meta($uid, 'icl_enable_replies_translation', 1);
}else{
delete_user_meta($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($wpdb->prepare("SELECT element_id, language_code FROM {$wpdb->prefix}icl_translations WHERE trid=%d AND element_type='comment' AND element_id <> %d ", $trid, $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 '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(!empty($this->settings['icl_disable_reminders'])) break;
if(!empty($iclsettings['site_id']) && !empty($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 . ', \'' . wp_create_nonce('icl_delete_message_nonce') . '\');';
$output .= ' -