/** * Removes all items from the current translation basket. */ function delete_all_items() { TranslationProxy_Basket::delete_all_items_from_basket(); }
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; }
static function reset_pro_translation_configuration() { //Todo: [WPML 3.3] Use settings APIs global $sitepress; $sitepress->set_setting('content_translation_languages_setup', false); $sitepress->set_setting('content_translation_setup_complete', false); $sitepress->set_setting('content_translation_setup_wizard_step', false); $sitepress->set_setting('site_id', false); $sitepress->set_setting('access_key', false); $sitepress->set_setting('translator_choice', false); $sitepress->set_setting('icl_lang_status', false); $sitepress->set_setting('icl_balance', false); $sitepress->set_setting('icl_support_ticket_id', false); $sitepress->set_setting('icl_current_session', false); $sitepress->set_setting('last_get_translator_status_call', false); $sitepress->set_setting('last_icl_reminder_fetch', false); $sitepress->set_setting('icl_account_email', false); $sitepress->set_setting('translators_management_info', false); if (class_exists('TranslationProxy_Basket')) { //Cleaning the basket TranslationProxy_Basket::delete_all_items_from_basket(); } global $wpdb; $sql_for_remote_rids = $wpdb->prepare("FROM {$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" $wpdb->query("\tDELETE FROM {$wpdb->prefix}icl_translate_job\n\t\t\t\t\t\tWHERE rid IN (SELECT rid {$sql_for_remote_rids})"); //Delete all translation statuses with status "waiting for translator" or "in progress" $wpdb->query("DELETE {$sql_for_remote_rids}"); //Cleaning up Translation Proxy settings $sitepress->set_setting('icl_html_status', false); $sitepress->set_setting('language_pairs', false); $sitepress->set_setting('icl_translation_projects', false); $sitepress->set_setting('translation_service', false); $sitepress->set_setting('site_id', false); $sitepress->set_setting('access_key', false); $sitepress->set_setting('ts_site_id', false); $sitepress->set_setting('ts_access_key', false); $sitepress->save_settings(); $wpdb->query("TRUNCATE TABLE {$wpdb->prefix}icl_core_status"); $wpdb->query("TRUNCATE TABLE {$wpdb->prefix}icl_content_status"); $wpdb->query("TRUNCATE TABLE {$wpdb->prefix}icl_string_status"); $wpdb->query("TRUNCATE TABLE {$wpdb->prefix}icl_node"); $wpdb->query("TRUNCATE TABLE {$wpdb->prefix}icl_reminders"); $response = array('errors' => 0, 'message' => __('PRO translation has been reset.', 'sitepress')); return $response; }
public function send_basket_commit() { $has_remote_translators = false; try { $response = false; $errors = array(); if (TranslationProxy::is_batch_mode()) { $project = TranslationProxy::get_current_project(); $translators = $_POST['translators']; $has_remote_translators = false; if (is_array($translators)) { foreach ($translators as $translator) { if (!TranslationProxy_Service::is_local_translator($translator)) { $has_remote_translators = true; break; } } } else { $has_remote_translators = true; } if ($project && $has_remote_translators) { $response = $project->commit_batch_job(); if (!empty($project->errors)) { $response = false; } } else { //Local translation only: return true $response = true; } } if ($response) { $is_error = false; TranslationProxy_Basket::delete_all_items_from_basket(); $service_name = TranslationProxy::get_current_service_name(); if (isset($has_remote_translators) && $has_remote_translators) { $response->call_to_action = '<strong>' . sprintf(__('You have sent items to %s. Please check if additional steps are required on their end', 'wpml-translation-management'), $service_name) . '</strong>'; } } else { $response = false; $is_error = true; if (isset($project) && $project) { $errors = $project->errors; } } } catch (Exception $e) { $response = false; $is_error = true; $errors[] = $e->getMessage(); } $result = array('result' => $response, 'is_error' => $is_error, 'errors' => $errors); if (!empty($errors)) { $this->rollback_basket_commit(); wp_send_json_error($result); } else { wp_send_json_success($result); } }
private function action_callback() { if (isset($_GET['clear_basket']) && isset($_GET['clear_basket_nonce']) && $_GET['clear_basket'] == 1) { if (wp_verify_nonce($_GET['clear_basket_nonce'], 'clear_basket')) { TranslationProxy_Basket::delete_all_items_from_basket(); } } if ($this->current_action() == 'delete_selected') { //Delete basket items from post action TranslationProxy_Basket::delete_items_from_basket($_POST['icl_translation_basket_delete']); } elseif ($this->current_action() == 'delete' && isset($_GET['id']) && isset($_GET['item_type'])) { //Delete basket item from post action $delete_basket_item_id = filter_input(INPUT_GET, 'id', FILTER_SANITIZE_NUMBER_INT); $delete_basket_item_type = filter_input(INPUT_GET, 'item_type', FILTER_SANITIZE_STRING); if ($delete_basket_item_id && $delete_basket_item_type) { TranslationProxy_Basket::delete_item_from_basket($delete_basket_item_id, $delete_basket_item_type, true); } } }
private function commit_basket($translation_id) { $basket_networking = wpml_tm_load_basket_networking(); $translator_array = $this->build_translator_array($translation_id); if ($translator_array) { $basket_networking->commit_basket_chunk(array(), TranslationProxy_Basket::get_basket_name(), $translator_array); } $project = TranslationProxy::get_current_project(); $project->commit_batch_job(); TranslationProxy_Basket::delete_all_items_from_basket(); }