public function set_language($domain, $lang) { $this->language_of_domain[$domain] = $lang; $string_settings = $this->sitepress->get_setting('st'); $string_settings['lang_of_domain'] = $this->language_of_domain; $this->sitepress->set_setting('st', $string_settings, true); }
function ajax_set_xliff_options() { check_ajax_referer('icl_xliff_options_form_nonce', 'security'); $newlines = intval($_POST['icl_xliff_newlines']); $this->sitepress->set_setting("xliff_newlines", $newlines, true); $version = intval($_POST['icl_xliff_version']); $this->sitepress->set_setting("tm_xliff_version", $version, true); wp_send_json_success(array('message' => 'OK', 'newlines_saved' => $newlines, 'version_saved' => $version)); }
/** * @param string $class */ private function mark_command_as_executed($class) { $id = call_user_func(array($class, 'get_command_id')); $this->string_settings[$id . '_has_run'] = true; $this->sitepress->set_setting('st', $this->string_settings, true); wp_cache_flush(); }
function reset_pro_translation_configuration() { $translation_service_name = $this->TranslationProxy->get_current_service_name(); $this->sitepress->set_setting('content_translation_languages_setup', false); $this->sitepress->set_setting('content_translation_setup_complete', false); $this->sitepress->set_setting('content_translation_setup_wizard_step', false); $this->sitepress->set_setting('translator_choice', false); $this->sitepress->set_setting('icl_lang_status', false); $this->sitepress->set_setting('icl_balance', false); $this->sitepress->set_setting('icl_support_ticket_id', false); $this->sitepress->set_setting('icl_current_session', false); $this->sitepress->set_setting('last_get_translator_status_call', false); $this->sitepress->set_setting('last_icl_reminder_fetch', false); $this->sitepress->set_setting('icl_account_email', false); $this->sitepress->set_setting('translators_management_info', false); $this->sitepress->set_setting('site_id', false); $this->sitepress->set_setting('access_key', false); $this->sitepress->set_setting('ts_site_id', false); $this->sitepress->set_setting('ts_access_key', false); if (class_exists('TranslationProxy_Basket')) { //Cleaning the basket TranslationProxy_Basket::delete_all_items_from_basket(); } $sql_for_remote_rids = $this->wpdb->prepare("FROM {$this->wpdb->prefix}icl_translation_status\n\t\t\t\t\t\t\t\t \t\t\t\tWHERE translation_service != 'local'\n\t\t\t\t\t\t\t\t \t\t\t\t\tAND translation_service != 0\n\t\t\t\t\t\t\t\t\t\t\t\t\tAND status IN ( %d, %d )", ICL_TM_WAITING_FOR_TRANSLATOR, ICL_TM_IN_PROGRESS); //Delete all translation service jobs with status "waiting for translator" or "in progress" $this->wpdb->query("DELETE FROM {$this->wpdb->prefix}icl_translate_job WHERE rid IN (SELECT rid {$sql_for_remote_rids})"); //Delete all translation statuses with status "waiting for translator" or "in progress" $this->wpdb->query("DELETE {$sql_for_remote_rids}"); //Cleaning up Translation Proxy settings $this->sitepress->set_setting('icl_html_status', false); $this->sitepress->set_setting('language_pairs', false); if (!$this->TranslationProxy->has_preferred_translation_service()) { $this->sitepress->set_setting('translation_service', false); $this->sitepress->set_setting('icl_translation_projects', false); } $this->sitepress->save_settings(); $this->wpdb->query("TRUNCATE TABLE {$this->wpdb->prefix}icl_core_status"); $this->wpdb->query("TRUNCATE TABLE {$this->wpdb->prefix}icl_content_status"); $this->wpdb->query("TRUNCATE TABLE {$this->wpdb->prefix}icl_string_status"); $this->wpdb->query("TRUNCATE TABLE {$this->wpdb->prefix}icl_node"); $this->wpdb->query("TRUNCATE TABLE {$this->wpdb->prefix}icl_reminders"); if ($this->TranslationProxy->has_preferred_translation_service() && $translation_service_name) { $confirm_message = 'The translation process with %1$s was reset.'; } elseif ($translation_service_name) { $confirm_message = 'Your site was successfully disconnected from %1$s. Go to the translators tab to connect a new %1$s account or use a different translation service.'; } else { $confirm_message = 'PRO translation has been reset.'; } $response = sprintf(__($confirm_message, 'wpml-translation-management'), $translation_service_name); return $response; }
public function maybe_migrate_string_name() { global $wpdb; $slug_settings = $this->sitepress->get_setting('posts_slug_translation'); if (!isset($slug_settings['string_name_migrated'])) { $queryable_post_types = get_post_types(array('publicly_queryable' => true)); foreach ($queryable_post_types as $type) { $post_type_obj = get_post_type_object($type); $slug = trim($post_type_obj->rewrite['slug'], '/'); if ($slug) { // First check if we should migrate from the old format URL slug: slug $string_id = $wpdb->get_var($wpdb->prepare("SELECT id\r\r\n\t\t\t\t\t\t\t\t\t\t\tFROM {$wpdb->prefix}icl_strings\r\r\n\t\t\t\t\t\t\t\t\t\t\tWHERE name = %s AND value = %s", 'URL slug: ' . $slug, $slug)); if ($string_id) { // migrate it to URL slug: post_type $st_update['name'] = 'URL slug: ' . $type; $wpdb->update($wpdb->prefix . 'icl_strings', $st_update, array('id' => $string_id)); } } } $slug_settings['string_name_migrated'] = true; $this->sitepress->set_setting('posts_slug_translation', $slug_settings, true); } }