public function render() { $all_languages = $this->sitepress->get_languages(); ?> <div id="wpml-change-language-dialog" class="wpml-change-language-dialog" title="<?php _e('Change the language of selected strings', 'wpml-string-translation'); ?> " style="display:none" data-button-text="<?php _e('Apply', 'wpml-string-translation'); ?> " data-cancel-text="<?php _e('Cancel', 'wpml-string-translation'); ?> " > <h2 class="summary js-summary" data-text="<?php _e('The selected strings are currently in %LANG%', 'wpml-string-translation'); ?> "></h2> <?php _e('Change the language to: ', 'wpml-string-translation'); ?> <?php $lang_selector = new WPML_Simple_Language_Selector($this->sitepress); echo $lang_selector->render(); ?> <br /> <span class="spinner"></span> <?php wp_nonce_field('wpml_change_string_language_nonce', 'wpml_change_string_language_nonce'); ?> </div> <?php }
public function render() { $all_languages = $this->sitepress->get_languages(); ?> <div id="wpml-change-language-dialog" class="wpml-change-language-dialog" title="<?php _e('Change the language of selected strings', 'wpml-string-translation'); ?> " style="display:none" data-button-text="<?php _e('Apply', 'wpml-string-translation'); ?> " data-cancel-text="<?php _e('Cancel', 'wpml-string-translation'); ?> " > <h2 class="summary js-summary" data-text="<?php _e('The selected strings are currently in %LANG%', 'wpml-string-translation'); ?> "></h2> <?php _e('Change the language to: ', 'wpml-string-translation'); ?> <?php $lang_selector = new WPML_Simple_Language_Selector($this->sitepress); echo $lang_selector->render(); ?> <br /> <img src="<?php echo ICL_PLUGIN_URL . '/res/img/ajax-loader.gif'; ?> " alt="loading" height="16" width="16" class="wpml_tt_spinner"/> <?php wp_nonce_field('wpml_change_string_language_nonce', 'wpml_change_string_language_nonce'); ?> </div> <?php }
private function get_lang_selector() { $disable = $this->check_if_language_change_is_ok() ? '' : 'disabled="disabled" '; ob_start(); $languages = $this->active_languages; if (!$this->is_package_language_active()) { $languages = array_merge(array($this->sitepress->get_language_details($this->package_language)), $languages); } else { $languages = $this->active_languages; } $selector = new WPML_Simple_Language_Selector($this->sitepress); $selector->render(array('id' => 'icl_package_language', 'name' => 'icl_package_language', 'show_please_select' => false, 'languages' => $languages, 'selected' => $this->package_language, 'disabled' => !$this->check_if_language_change_is_ok(), 'echo' => true)); ?> <span class="spinner"></span> <?php return ob_get_clean(); }
function add_meta_box() { global $wpdb, $sitepress; $metabox = '<div id="wpml-package-admin-bar-popup" style="display:none;position:fixed;z-index:9002;width:200px;padding:10px;border: 1px solid #8CCEEA;background-color:#FFF">'; $wpml_pt_meta = new WPML_Package_Translation_Metabox($this->package, $wpdb, $sitepress, $this->args); $metabox .= $wpml_pt_meta->get_metabox(); $metabox .= '</div>'; $metabox .= $this->add_js(); // This is required when a new package is created but it doesn't have any translated content yet. // https://onthegosystems.myjetbrains.com/youtrack/issue/wpmlst-556 WPML_Simple_Language_Selector::enqueue_scripts(); echo $metabox; }
public function render($domains) { $all_languages = $this->sitepress->get_languages($this->sitepress->get_admin_language()); ?> <div id="wpml-change-domain-language-dialog" class="wpml-change-language-dialog" title="<?php _e('Language of domains', 'wpml-string-translation'); ?> " style="display:none" data-button-text="<?php _e('Apply', 'wpml-string-translation'); ?> " data-cancel-text="<?php _e('Cancel', 'wpml-string-translation'); ?> " > <label for="wpml-domain-select"> <?php _e('Select for which domain to set the language: ', 'wpml-string-translation'); ?> </label> <select id="wpml-domain-select"> <option value="" selected="selected"><?php _e('-- Please select --', 'wpml-string-translation'); ?> </option> <?php foreach ($domains as $domain) { $results = $this->wpdb->get_results($this->wpdb->prepare("\r\n\t\t\t\t\t\t\t\tSELECT language, COUNT(language) AS count\r\n\t\t\t\t\t\t\t\tFROM {$this->wpdb->prefix}icl_strings s\r\n\t\t\t\t\t\t\t\tWHERE context = %s\r\n\t\t\t\t\t\t\t\t\tAND language IN (" . wpml_prepare_in(array_keys($all_languages)) . ")\r\n\t\t\t\t\t\t\t\tGROUP BY language\r\n\t\t\t\t\t\t\t\t", $domain->context), ARRAY_A); foreach ($results as &$result) { $result['display_name'] = $all_languages[$result['language']]['display_name']; } $domain_lang = $this->language_of_domain->get_language($domain->context); if ($domain_lang) { $domain_data = 'data-domain_lang="' . $domain_lang . '" '; } else { $domain_data = 'data-domain_lang="" '; } echo '<option value="' . $domain->context . '" data-langs="' . esc_attr(wp_json_encode($results)) . '"' . $domain_data . '>' . $domain->context . '</option>'; } ?> </select> <div class="js-summary wpml-cdl-summary" style="display:none" > <p class="wpml-cdl-info"> <?php _e('This domain currently has the following strings:', 'wpml-string-translation'); ?> </p> <table class="widefat striped wpml-cdl-table"> <thead> <tr> <td class="manage-column column-cb check-column"><input class="js-all-check" type="checkbox" value="all" /></td> <th><?php _e('Current source language', 'wpml-string-translation'); ?> </th> <th class="num"><?php _e('Number of strings', 'wpml-string-translation'); ?> </th> </tr> </thead> <tbody> </tbody> </table> <div class="js-lang-select-area wpml-cdl-info"> <label for="wpml-source-domain-language-change"><?php _e('Set the source language of these strings to:', 'wpml-string-translation'); ?> </label> <?php $lang_selector = new WPML_Simple_Language_Selector($this->sitepress); echo $lang_selector->render(array('id' => 'wpml-source-domain-language-change')); ?> <label for="wpml-cdl-set-default"> <input id="wpml-cdl-set-default" type="checkbox" class="js-default" value="use-as-default" checked="checked" /> <?php _e('Use this language as the default language for new strings in this domain', 'wpml-string-translation'); ?> </label> </div> </div> <img src="<?php echo ICL_PLUGIN_URL . '/res/img/ajax-loader.gif'; ?> " alt="loading" height="16" width="16" class="wpml_tt_spinner"/> <?php wp_nonce_field('wpml_change_string_domain_language_nonce', 'wpml_change_string_domain_language_nonce'); ?> </div> <?php }
function show_custom_url_base_translation_links() { global $woocommerce_wpml, $sitepress; ?> <script> var inputs = ['woocommerce_product_category_slug', 'woocommerce_product_tag_slug', 'woocommerce_product_attribute_slug', 'product_permalink_structure']; for(i in inputs){ var input = jQuery('input[name="' + inputs[i] + '"]'); if(input.length){ if(inputs[i] == 'product_permalink_structure' && jQuery('input[name="product_permalink"]:checked').val() == '' ){ input = jQuery('input[name="product_permalink"]:checked').closest('.form-table').find('code').eq(0); } input.parent().append('<div class="translation_controls"></div>'); if(inputs[i] == 'woocommerce_product_attribute_slug' && input.val() == '' ){ input.parent().find('.translation_controls').append(' '); }else{ input.parent().find('.translation_controls').append('<a href="<?php echo admin_url('admin.php?page=' . WPML_ST_FOLDER . '/menu/string-translation.php&context=' . urlencode($woocommerce_wpml->url_translation->url_strings_context())); ?> "><?php _e('translations', 'woocommerce-multilingual'); ?> </a>'); } } } </script> <?php $lang_selector = new WPML_Simple_Language_Selector($sitepress); $permalink_options = get_option('woocommerce_permalinks'); $bases = array('tag_base' => 'product_tag', 'category_base' => 'product_cat', 'attribute_base' => 'attribute', 'product_base' => 'product'); foreach ($bases as $key => $base) { switch ($base) { case 'product_tag': $input_name = 'woocommerce_product_tag_slug'; $value = !empty($permalink_options['tag_base']) ? $permalink_options['tag_base'] : $woocommerce_wpml->url_translation->default_product_tag_base; break; case 'product_cat': $input_name = 'woocommerce_product_category_slug'; $value = !empty($permalink_options['category_base']) ? $permalink_options['category_base'] : $woocommerce_wpml->url_translation->default_product_category_base; break; case 'attribute': $input_name = 'woocommerce_product_attribute_slug'; $value = !empty($permalink_options['attribute_base']) ? $permalink_options['attribute_base'] : ''; break; case 'product': $input_name = 'product_permalink_structure'; $value = !empty($permalink_options['product_base']) ? trim($permalink_options['product_base'], '/') : $woocommerce_wpml->url_translation->default_product_base; break; } $language = $this->get_string_language(trim($value, '/'), $woocommerce_wpml->url_translation->url_strings_context(), $woocommerce_wpml->url_translation->url_string_name($base)); if (is_null($language)) { $language = $sitepress->get_default_language(); } echo $lang_selector->render(array('id' => $key . '_language_selector', 'name' => $key . '_language', 'selected' => $language, 'show_please_select' => false)); ?> <script> var input = jQuery('input[name="<?php echo $input_name; ?> "]'); if( '<?php echo $input_name; ?> ' == 'product_permalink_structure' && jQuery('input[name="product_permalink"]:checked').val() == '' ){ input = jQuery('input[name="product_permalink"]:checked').closest('.form-table').find('code').eq(0); } jQuery('#<?php echo $key; ?> _language_selector').appendTo( input.parent().find('.translation_controls') ); </script> <?php } }
public function render($post_type, $custom_post) { $_has_slug = isset($custom_post->rewrite['slug']) && $custom_post->rewrite['slug']; $_on = $this->settings->is_on() && $_has_slug && $this->post_sync_setting->is_sync($post_type); $is_hidden = $_on ? '' : 'hidden'; $_translate = $this->settings->is_translate($post_type); $string_id = null; if ($_has_slug) { list($string_id, $_slug_translations) = WPML_Slug_Translation::get_translations($post_type); if ($this->settings->is_on() && $_translate && !$string_id) { $message = sprintf(__("%s slugs are set to be translated, but they are missing their translation", 'sitepress'), $custom_post->labels->name); ICL_AdminNotifier::displayInstantMessage($message, 'error', 'below-h2', false); } } else { $_slug_translations = false; } if ($_has_slug && $this->settings->is_on()) { ?> <div class="icl_slug_translation_choice <?php echo $is_hidden; ?> "> <p> <label> <input name="translate_slugs[<?php echo $post_type; ?> ][on]" type="checkbox" value="1" <?php checked(1, $_translate, true); ?> /> <?php printf(__('Use different slugs in different languages for %s.', 'sitepress'), $custom_post->labels->name); ?> </label> </p> <table class="js-cpt-slugs <?php if (empty($_translate)) { ?> hidden<?php } ?> "> <?php if ($string_id) { $string = new WPML_ST_String($string_id, $this->wpdb); $string_lang = $string->get_language(); } else { $string_lang = ''; } $string_lang = $string_lang ? $string_lang : $this->sitepress->get_default_language(); $languages = $this->sitepress->get_active_languages(); if (!in_array($string_lang, array_keys($languages))) { $all_languages = $this->sitepress->get_languages(); $languages[$string_lang] = $all_languages[$string_lang]; } $original_slug = WPML_Slug_Translation::get_slug_by_type($post_type); $original_slug = $original_slug ? $original_slug : (isset($custom_post->slug) ? $custom_post->slug : $custom_post->rewrite['slug']); foreach ($languages as $language) { $slug_translation_value = !empty($_slug_translations[$language['code']]['value']) ? $_slug_translations[$language['code']]['value'] : ''; $slug_translation_sample = $original_slug . ' @' . $language['code']; ?> <tr<?php if ($language['code'] == $string_lang) { echo ' style="display:none"'; } ?> > <td> <label for="translate_slugs[<?php echo $post_type; ?> ][langs][<?php echo $language['code']; ?> ]"><?php echo $this->sitepress->get_flag_img($language['code']) . ' ' . $language['display_name']; ?> </label> </td> <td> <input id="translate_slugs[<?php echo $post_type; ?> ][langs][<?php echo $language['code']; ?> ]" class="js-translate-slug" name="translate_slugs[<?php echo $post_type; ?> ][langs][<?php echo $language['code']; ?> ]" type="text" value="<?php echo $slug_translation_value; ?> " placeholder="<?php echo $slug_translation_sample; ?> " data-lang="<?php echo $language['code']; ?> " /> <?php if (isset($_slug_translations[$language['code']]) && $_slug_translations[$language['code']]['status'] != ICL_TM_COMPLETE) { ?> <em class="icl_st_slug_tr_warn"><?php _e("Not marked as 'complete'. Press 'Save' to enable.", 'sitepress'); ?> </em> <?php } ?> </td> </tr> <?php if ($language['code'] == $string_lang) { ?> <tr> <td> <?php $lang_selector = new WPML_Simple_Language_Selector($this->sitepress); $lang_selector->render(array('name' => 'translate_slugs[' . $post_type . '][original]', 'selected' => $language['code'], 'show_please_select' => false, 'echo' => true, 'class' => 'js-translate-slug-original', 'data' => array('slug' => $post_type))); ?> <label for="translate_slugs[<?php echo $post_type; ?> ][langs][<?php echo $language['code']; ?> ]"> <em><?php _e("(original)", 'sitepress'); ?> </em></label> </td> <td><input disabled="disabled" class="disabled" id="translate_slugs[<?php echo $post_type; ?> ][langs][<?php echo $language['code']; ?> ]" name="translate_slugs[<?php echo $post_type; ?> ][langs][<?php echo $language['code']; ?> ]" type="text" value="<?php echo $original_slug; ?> "/> </td> </tr> <?php } } ?> </table> </div> <?php } }
/** * @param array $icl_translation_filter */ public function display($icl_translation_filter = array()) { /** * @var TranslationManagement $iclTranslationManagement * @var WPML_Translation_Job_Factory $wpml_translation_job_factory */ global $iclTranslationManagement, $current_user, $wpml_translation_job_factory, $wpdb; if (isset($_GET['job_id']) && $_GET['job_id'] > 0 || isset($_GET['trid']) && $_GET['trid'] > 0) { $job_id = $this->get_job_id_from_request(); $job_object = $wpml_translation_job_factory->get_translation_job($job_id, false, 0, true); if ($job_object && $job_object->user_can_translate($current_user)) { $translation_editor_ui = new WPML_Translation_Editor_UI($wpdb, $this->sitepress, $iclTranslationManagement, $job_object, new WPML_TM_Job_Action_Factory($wpml_translation_job_factory), new WPML_TM_Job_Layout($wpdb, $this->sitepress->get_wp_api())); $translation_editor_ui->render(); return; } } if (!empty($_GET['resigned'])) { $iclTranslationManagement->add_message(array('type' => 'updated', 'text' => __("You've resigned from this job.", 'wpml-translation-management'))); } if (isset($_SESSION['translation_ujobs_filter'])) { $icl_translation_filter = $_SESSION['translation_ujobs_filter']; } $current_translator = $iclTranslationManagement->get_current_translator(); $can_translate = $current_translator && $current_translator->ID > 0 && $current_translator->language_pairs; $post_link_factory = new WPML_TM_Post_Link_Factory($this->sitepress); if ($can_translate) { $icl_translation_filter['translator_id'] = $current_translator->ID; $icl_translation_filter['include_unassigned'] = true; $element_type_prefix = isset($_GET['element_type']) ? $_GET['element_type'] : 'post'; if (isset($_GET['updated']) && $_GET['updated']) { $tm_post_link_updated = $post_link_factory->view_link($_GET['updated']); if ($iclTranslationManagement->is_external_type($element_type_prefix)) { $tm_post_link_updated = apply_filters('wpml_external_item_link', $tm_post_link_updated, $_GET['updated'], false); } $user_message = __('Translation updated: ', 'wpml-translation-management') . $tm_post_link_updated; $iclTranslationManagement->add_message(array('type' => 'updated', 'text' => $user_message)); } elseif (isset($_GET['added']) && $_GET['added']) { $tm_post_link_added = $post_link_factory->view_link($_GET['added']); if ($iclTranslationManagement->is_external_type($element_type_prefix)) { $tm_post_link_added = apply_filters('wpml_external_item_link', $tm_post_link_added, $_GET['added'], false); } $user_message = __('Translation added: ', 'wpml-translation-management') . $tm_post_link_added; $iclTranslationManagement->add_message(array('type' => 'updated', 'text' => $user_message)); } elseif (isset($_GET['job-cancelled'])) { $user_message = __('Translation has been removed by admin', 'wpml-translation-management'); $iclTranslationManagement->add_message(array('type' => 'error', 'text' => $user_message)); } $translation_jobs = array(); if (!empty($current_translator->language_pairs)) { $_langs_to = array(); if (1 < count($current_translator->language_pairs)) { foreach ($current_translator->language_pairs as $lang => $to) { $langs_from[] = $this->sitepress->get_language_details($lang); $_langs_to = array_merge((array) $_langs_to, array_keys($to)); } $_langs_to = array_unique($_langs_to); } else { $_langs_to = array_keys(current($current_translator->language_pairs)); $lang_from = $this->sitepress->get_language_details(key($current_translator->language_pairs)); $icl_translation_filter['from'] = $lang_from['code']; } if (1 < count($_langs_to)) { foreach ($_langs_to as $lang) { $langs_to[] = $this->sitepress->get_language_details($lang); } } else { $lang_to = $this->sitepress->get_language_details(current($_langs_to)); $icl_translation_filter['to'] = $lang_to['code']; } $job_types = $wpml_translation_job_factory->get_translation_job_types_filter(array(), array('translator_id' => $current_translator->ID, 'include_unassigned' => true)); $translation_jobs = $wpml_translation_job_factory->get_translation_jobs((array) $icl_translation_filter); } } ?> <div class="wrap"> <h2><?php echo __('Translations queue', 'wpml-translation-management'); ?> </h2> <?php if (empty($current_translator->language_pairs)) { ?> <div class="error below-h2"><p><?php _e("No translation languages configured for this user.", 'wpml-translation-management'); ?> </p></div> <?php } ?> <?php do_action('icl_tm_messages'); ?> <?php if (!empty($current_translator->language_pairs)) { ?> <div class="alignright"> <form method="post" name="translation-jobs-filter" id="tm-queue-filter" action="admin.php?page=<?php echo WPML_TM_FOLDER; ?> /menu/translations-queue.php"> <input type="hidden" name="icl_tm_action" value="ujobs_filter" /> <table class=""> <tbody> <tr valign="top"> <td> <select name="filter[type]"> <option value=""><?php _e('All types', 'wpml-translation-management'); ?> </option> <?php foreach ($job_types as $job_type => $job_type_name) { ?> <option value="<?php echo $job_type; ?> " <?php if (!empty($icl_translation_filter['type']) && $icl_translation_filter['type'] == $job_type) { ?> selected="selected"<?php } ?> ><?php echo $job_type_name; ?> </option> <?php } ?> </select> <label> <strong><?php _e('From', 'wpml-translation-management'); ?> </strong> <?php if (1 < count($current_translator->language_pairs)) { $from_select = new WPML_Simple_Language_Selector($this->sitepress); echo $from_select->render(array('name' => 'filter[from]', 'please_select_text' => __('Any language', 'wpml-translation-management'), 'style' => '', 'languages' => $langs_from, 'selected' => isset($icl_translation_filter['from']) ? $icl_translation_filter['from'] : '')); } else { ?> <input type="hidden" name="filter[from]" value="<?php echo esc_attr($lang_from['code']); ?> " /> <?php echo $this->sitepress->get_flag_img($lang_from['code']) . ' ' . $lang_from['display_name']; ?> <?php } ?> </label> <label> <strong><?php _e('To', 'wpml-translation-management'); ?> </strong> <?php if (1 < @count($langs_to)) { $to_select = new WPML_Simple_Language_Selector($this->sitepress); echo $to_select->render(array('name' => 'filter[to]', 'please_select_text' => __('Any language', 'wpml-translation-management'), 'style' => '', 'languages' => $langs_to, 'selected' => isset($icl_translation_filter['to']) ? $icl_translation_filter['to'] : '')); } else { ?> <input type="hidden" name="filter[to]" value="<?php echo esc_attr($lang_to['code']); ?> " /> <?php echo $this->sitepress->get_flag_img($lang_to['code']) . ' ' . $lang_to['display_name']; ?> <?php } ?> </label> <select name="filter[status]"> <option value=""><?php _e('All statuses', 'wpml-translation-management'); ?> </option> <option value="<?php echo ICL_TM_COMPLETE; ?> " <?php if (@intval($icl_translation_filter['status']) == ICL_TM_COMPLETE) { ?> selected="selected"<?php } ?> ><?php echo TranslationManagement::status2text(ICL_TM_COMPLETE); ?> </option> <option value="<?php echo ICL_TM_IN_PROGRESS; ?> " <?php if (@intval($icl_translation_filter['status']) == ICL_TM_IN_PROGRESS) { ?> selected="selected"<?php } ?> ><?php echo TranslationManagement::status2text(ICL_TM_IN_PROGRESS); ?> </option> <option value="<?php echo ICL_TM_WAITING_FOR_TRANSLATOR; ?> " <?php if (@intval($icl_translation_filter['status']) && $icl_translation_filter['status'] == ICL_TM_WAITING_FOR_TRANSLATOR) { ?> selected="selected"<?php } ?> ><?php _e('Available to translate', 'wpml-translation-management'); ?> </option> </select> <input class="button-secondary" type="submit" value="<?php _e('Filter', 'wpml-translation-management'); ?> " /> </td> </tr> </tbody> </table> </form> </div> <?php $actions = apply_filters('wpml_translation_queue_actions', array()); /** * @deprecated Use 'wpml_translation_queue_actions' instead */ $actions = apply_filters('WPML_translation_queue_actions', $actions); ?> <?php if (sizeof($actions) > 0) { ?> <form method="post" name="translation-jobs-action" action="admin.php?page=<?php echo WPML_TM_FOLDER; ?> /menu/translations-queue.php"> <?php } ?> <?php do_action('wpml_xliff_select_actions', $actions, 'action'); /** * @deprecated Use 'wpml_xliff_select_actions' instead */ do_action('WPML_xliff_select_actions', $actions, 'action'); ?> <?php $translation_queue_pagination = new WPML_Translations_Queue_Pagination_UI($translation_jobs, $this->screen_options->get_items_per_page()); $translation_jobs = $translation_queue_pagination->get_paged_jobs(); ?> <?php // pagination - end ?> <?php $blog_translators = wpml_tm_load_blog_translators(); $tm_api = new WPML_TM_API($blog_translators, $iclTranslationManagement); $translation_queue_jobs_model = new WPML_Translations_Queue_Jobs_Model($this->sitepress, $iclTranslationManagement, $tm_api, $post_link_factory, $translation_jobs); $translation_jobs = $translation_queue_jobs_model->get(); $this->show_table($translation_jobs, sizeof($actions) > 0); ?> <div id="tm-queue-pagination" class="tablenav"> <?php $translation_queue_pagination->show(); ?> <?php do_action('wpml_xliff_select_actions', $actions, 'action2'); /** * @deprecated Use 'wpml_xliff_select_actions' instead */ do_action('WPML_xliff_select_actions', $actions, 'action2'); ?> </div> <?php // pagination - end ?> <?php if (sizeof($actions) > 0) { ?> </form> <?php } ?> <?php do_action('wpml_translation_queue_after_display'); ?> <?php } ?> </div> <?php // Check for any bulk actions if (isset($_POST['action']) || isset($_POST["action2"])) { $xliff_version = isset($_POST['doaction']) ? $_POST['action'] : $_POST['action2']; do_action('wpml_translation_queue_do_actions_export_xliff', $_POST, $xliff_version); /** * @deprecated Use 'wpml_translation_queue_do_actions_export_xliff' instead */ do_action('WPML_translation_queue_do_actions_export_xliff', $_POST, $xliff_version); } }