public static function get_current_service_name() { if (icl_do_not_promote()) { return __('Translation Service', 'sitepress'); } $translation_service = self::get_current_service(); if ($translation_service) { return $translation_service->name; } return false; }
private function build_content_dashboard_remote_translations_controls() { // shows only when translation polling is on and there are translations in progress $this->build_content_dashboard_fetch_translations_box(); $active_service = icl_do_not_promote() ? false : TranslationProxy::get_current_service(); $service_dashboard_info = TranslationProxy::get_service_dashboard_info(); if ($active_service && $service_dashboard_info) { ?> <div class="icl_cyan_box"> <h3><?php echo $active_service->name . ' ' . __('account status', 'wpml-translation-management'); ?> </h3> <?php echo $service_dashboard_info; ?> </div> <?php } }
public function build_content_translators() { global $sitepress, $iclTranslationManagement, $wpdb, $current_user; $selected_translator = $iclTranslationManagement->get_selected_translator(); $active_service = $this->active_service; $service_name = $this->service_name; if (current_user_can('list_users')) { add_filter('icl_translation_services_button', array($this, 'icl_local_add_translator_button')); add_filter('icl_translation_services_button', array('TranslationProxy', 'get_current_service_info')); $only_local_translators = $active_service && (!TranslationProxy_Service::is_authenticated($active_service) || $active_service && !$active_service->has_translator_selection); ?> <div id="icl-your-translators"> <?php if ($active_service && TranslationProxy::translator_selection_available()) { if ($only_local_translators) { $translation_dashboard_url = "admin.php?page=" . WPML_TM_FOLDER . "/menu/main.php&sm=dashboard"; $translation_dashboard_link = sprintf('<a href="%s">' . __('Translation Dashboard', 'wpml-translation-management') . '</a>', $translation_dashboard_url); $service_html = '<p>'; $service_html .= sprintf(__('This section is for selecting WPML (local) translators only. If you wish to use %s, please go to %s.'), '<strong>' . $service_name . '</strong>', $translation_dashboard_link); $service_html .= '</p>'; } else { $service_html = TranslationProxy::get_service_translators_info(); } ICL_AdminNotifier::display_instant_message($service_html); } if ($selected_translator && $selected_translator->ID) { // Edit form echo '<h3>' . __('Edit translator', 'wpml-translation-management') . '</h3>'; echo '<form id="icl_tm_adduser" method="post" action="">' . "\r\n"; echo $this->icl_local_edit_translator_form('edit', $selected_translator) . "\r\n"; echo '</form>' . "\r\n"; } else { // Services add translator form // Services hook $services_buttons = apply_filters('icl_translation_services_button', array()); if (!empty($services_buttons)) { if (!$only_local_translators) { // Toggle button echo '<input type="submit" class="button secondary" id="icl_add_translator_form_toggle" value="' . __('Add Translator', 'wpml-translation-management') . ' »" />' . "\r\n"; } // Toggle div start $form_classes = array('translator-form-wrapper'); if (!isset($_GET['service']) && !$only_local_translators) { $form_classes[] = 'hidden'; } echo '<div id="icl_add_translator_form_wrapper" class="' . implode(' ', $form_classes) . '">'; // Open form echo '<form id="icl_tm_adduser" method="post" action="">'; // 'From' and 'To' languages dropdowns $languages = $sitepress->get_active_languages(); $from = '<label>' . __('From language:', 'wpml-translation-management') . ' <select name="from_lang" id="edit-from">' . "\r\n" . '<option value="0">' . __('Choose', 'wpml-translation-management') . '</option>' . "\r\n"; $to = '<label>' . __('To language:', 'wpml-translation-management') . ' <select name="to_lang" id="edit-to">' . "\r\n" . '<option value="0">' . __('Choose', 'wpml-translation-management') . '</option>' . "\r\n"; foreach ($languages as $language) { // select language from request $selected_from = isset($_GET['icl_lng']) && $_GET['icl_lng'] == $language['code'] ? ' selected="selected"' : ''; $from .= '<option ' . $selected_from . ' value="' . $language['code'] . '"' . @strval($selected_from) . '>' . $language['display_name'] . '</option>' . "\r\n"; $to .= '<option value="' . $language['code'] . '"' . '>' . $language['display_name'] . '</option>' . "\r\n"; } echo $from . '</select></label>' . "\r\n"; echo $to . '</select></label>' . "\r\n"; if (!$only_local_translators) { // Services radio boxes echo '<h4 style="margin-bottom:5px;">' . __('Select translation service', 'wpml-translation-management') . '</h4>' . "\r\n"; } else { echo '<h4 style="margin-bottom:5px;">' . __('Select translators', 'wpml-translation-management') . '</h4>' . "\r\n"; } foreach ($services_buttons as $service => $button) { if ($only_local_translators && $service != 'local') { continue; } if (!isset($button['has_translator_selection']) || $button['has_translator_selection']) { $selected = $only_local_translators && $service == 'local' || isset($_GET['service']) && $_GET['service'] == $service ? ' checked="checked"' : ''; $title = array(); $has_translator_selection = isset($service['has_translator_selection']) ? $service['has_translator_selection'] : false; echo '<div style="margin-bottom:5px;">'; $display = $only_local_translators && $service == 'local' ? ' style="display:none;"' : ''; echo '<input type="radio" id="radio-' . $service . '" name="services" data-has_translator_selection="' . $has_translator_selection . '" value="' . $service . '"' . $selected . $display . ' />'; if (isset($button['name']) && $button['name']) { $title[] = '<label for="radio-' . $service . '"' . $display . '> ' . $button['name']; } if (isset($button['description']) && $button['description']) { $title[] = $button['description']; } if (isset($button['more_link']) && $button['more_link']) { $title[] = $button['more_link']; } echo implode(' - ', $title) . "\r\n"; echo '</label>'; echo isset($button['content']) && $button['content'] ? $button['content'] . "\r\n" : ''; echo isset($button['messages']) && $button['messages'] ? $button['messages'] . "\r\n" : ''; if (isset($button['setup_url']) && $button['setup_url']) { echo '<input type="hidden" id="' . $service . '_setup_url" name="' . $service . '_setup_url" value="' . $button['setup_url'] . '" />' . "\r\n"; } echo '</div>'; } } echo '<br style="clear:both;" />'; echo '<input id="icl_add_translator_submit" class="button-primary" type="submit" value="' . esc_attr(__('Add translator', 'wpml-translation-management')) . '" />' . "\r\n"; echo '</form>' . "\r\n"; echo '</div>' . "\r\n"; } else { _e('No add translator interface available', 'wpml-translation-management'); } } // Translators lists // Local translators $blog_users_t = $iclTranslationManagement->get_blog_translators(); if (TranslationProxy::translator_selection_available()) { $other_service_translators = TranslationProxy_Translator::translation_service_translators_list(); } ?> <?php if (!empty($blog_users_t) || !empty($other_service_translators)) { ?> <h3><?php _e('Current translators', 'wpml-translation-management'); ?> </h3> <table class="widefat fixed" cellspacing="0"> <thead> <?php $this->translators_head_foot_row(); ?> </thead> <tfoot> <?php $this->translators_head_foot_row(); ?> </tfoot> <tbody class="list:user user-list"> <?php if (!empty($blog_users_t)) { foreach ($blog_users_t as $bu) { ?> <?php if (!isset($trstyle) || $trstyle) { $trstyle = ''; } else { $trstyle = ' class="alternate"'; } if ($current_user->ID == $bu->ID) { $edit_link = 'profile.php'; } else { $edit_link = esc_url(add_query_arg('wp_http_referer', urlencode(esc_url(stripslashes($_SERVER['REQUEST_URI']))), "user-edit.php?user_id={$bu->ID}")); } $language_pairs = get_user_meta($bu->ID, $wpdb->prefix . 'language_pairs', true); ?> <tr<?php echo $trstyle; ?> > <td class="column-title"> <strong><a class="row-title" href="<?php echo $edit_link; ?> "><?php echo $bu->user_login; ?> </a></strong> <div class="row-actions"> <a class="edit" href="admin.php?page=<?php echo WPML_TM_FOLDER; ?> /menu/main.php&sm=translators&icl_tm_action=remove_translator&remove_translator_nonce=<?php echo wp_create_nonce('remove_translator'); ?> &user_id=<?php echo $bu->ID; ?> "><?php _e('Remove', 'wpml-translation-management'); ?> </a> | <a class="edit" href="admin.php?page=<?php echo WPML_TM_FOLDER; ?> /menu/main.php&sm=translators&icl_tm_action=edit&user_id=<?php echo $bu->ID; ?> "> <?php _e('Language pairs', 'wpml-translation-management'); ?> </a> </div> </td> <td> <?php $langs = $sitepress->get_active_languages(); ?> <ul> <?php foreach ($language_pairs as $from => $lp) { ?> <?php $tos = array(); foreach ($lp as $to => $null) { if (isset($langs[$to])) { $tos[] = $langs[$to]['display_name']; } elseif ($to) { $_lang = $sitepress->get_language_details($to); if ($_lang) { $tos[] = '<i>' . $_lang['display_name'] . __(' (inactive)', 'wpml-translation-management') . '</i>'; } } } ?> <li><?php @printf(__('%s to %s', 'wpml-translation-management'), $langs[$from]['display_name'], join(', ', $tos)); ?> </li> <?php } ?> </ul> </td> <td> Local </td> <td> <a href="admin.php?page=<?php echo WPML_TM_FOLDER; ?> /menu/main.php&sm=translators&icl_tm_action=edit&user_id=<?php echo $bu->ID; ?> "><?php _e('edit languages', 'wpml-translation-management'); ?> </a> </td> </tr> <?php } } ?> <?php if (!empty($other_service_translators)) { foreach ($other_service_translators as $rows) { ?> <?php if (!isset($trstyle) || $trstyle) { $trstyle = ''; } else { $trstyle = ' class="alternate"'; } $language_pairs = isset($rows['langs']) ? $rows['langs'] : ''; ?> <tr<?php echo $trstyle; ?> > <td class="column-title"> <strong><?php echo isset($rows['name']) ? $rows['name'] : ''; ?> </strong> <div class="row-actions"> <?php echo isset($rows['action']) ? $rows['action'] : ''; ?> </div> </td> <td> <?php $langs = $sitepress->get_active_languages(); if (is_array($language_pairs)) { ?> <ul> <?php foreach ($language_pairs as $from => $lp) { $from = isset($langs[$from]['display_name']) ? $langs[$from]['display_name'] : $from; $tos = array(); foreach ($lp as $to) { $tos[] = isset($langs[$to]['display_name']) ? $langs[$to]['display_name'] : $to; } ?> <li><?php printf(__('%s to %s', 'wpml-translation-management'), $from, join(', ', $tos)); ?> </li> <?php } ?> </ul> <?php } ?> </td> <td> <?php echo isset($rows['type']) ? icl_do_not_promote() ? __('Translation Service', 'sitepress') : $rows['type'] : ''; ?> </td> <td> <?php echo isset($rows['action']) ? $rows['action'] : ''; ?> </td> </tr> <?php } } ?> </tbody> </table> <?php } else { $message = __("You haven't added any translator accounts yet.", 'wpml-translation-management'); ICL_AdminNotifier::display_instant_message($message, 'warning'); } wp_nonce_field('get_users_not_trans_nonce', 'get_users_not_trans_nonce'); } //if ( current_user_can('list_users') ) ?> </div> <?php }
static function menu() { global $wpdb, $sitepress; if (!class_exists('TranslationManagement')) { return; } $site_id = $sitepress->get_setting('site_id'); $access_key = $sitepress->get_setting('access_key'); ?> <h4><?php _e('Translation Management', 'sitepress'); ?> </h4> <?php $current_service_name = TranslationProxy::get_current_service_name(); if ($site_id && $access_key) { ?> <p> <input id="icl_sync_jobs" type="button" class="button-secondary" value="<?php echo sprintf(__('Synchronize translation jobs with %s', 'sitepress'), $current_service_name); ?> "/><br/> <small style="margin-left:10px;"><?php echo sprintf(__('Fixes links between translation entries in the database and %s.', 'sitepress'), $current_service_name); ?> </small> </p> <p> <input id="icl_cms_id_fix" type="button" class="button-secondary" value="<?php _e('CMS ID fix', 'sitepress'); ?> "/> <span id="icl_cms_id_fix_prgs" style="display: none;"><?php $fixing_count_sql = "\n\t\t\t\t\t\tSELECT COUNT(*)\n\t\t\t\t\t\tFROM {$wpdb->prefix}icl_translations t\n\t\t\t\t\t\tJOIN {$wpdb->prefix}icl_translation_status s\n\t\t\t\t\t\t\tON t.translation_id=s.translation_id\n\t\t\t\t\t\tWHERE t.element_type LIKE 'post\\_%'\n\t\t\t\t\t\t\tAND t.source_language_code IS NOT NULL\n\t\t\t\t\t\t\tAND s.translation_service=%s\n\t\t\t\t\t\t"; $fixing_count_prepared = $wpdb->prepare($fixing_count_sql, array($current_service_name)); $fixing_count = $wpdb->get_var($fixing_count_prepared); printf(__('fixing %s/%d', 'sitepress'), '<span id="icl_cms_id_fix_prgs_cnt">0</span>', $fixing_count); ?> </span><br/> <small style="margin-left:10px;"><?php _e("Updates translation in progress with new style identifiers for documents. The new identifiers depend on the document being translated and the languages so it's not possible to get out of sync when translations are being deleted locally.", 'sitepress'); ?> </small> </p> <p> <input id="icl_sync_cancelled" type="button" class="button-secondary" value="<?php echo sprintf(__('Check cancelled jobs on %s', 'sitepress'), $current_service_name); ?> "/><br/> <small style="margin-left:10px;"><?php echo sprintf(__('When using the translation pickup mode cancelled jobs on %s need to be synced manually.', 'sitepress'), $current_service_name); ?> </small> </p> <div id="icl_sync_cancelled_resp" class="clear"></div> <input type="hidden" id="icl_ts_t2c" value=""/> <?php } ?> <br clear="all"/> <?php if (SitePress_Setup::setup_complete()) { $translation_service_name = $current_service_name; //Todo: [WPML 3.3] Move JS to an external resource $translation_service_checkbox_js_code = "if(jQuery(this).attr('checked')) "; $translation_service_checkbox_js_code .= "jQuery('#icl_reset_pro_but').removeClass('button-primary-disabled'); "; $translation_service_checkbox_js_code .= "else jQuery('#icl_reset_pro_but').addClass('button-primary-disabled');"; $translation_service_button_js_code = "if(!jQuery('#icl_reset_pro_check').attr('checked') || !confirm('"; $translation_service_button_js_code .= esc_js(__('Are you sure you want to reset the PRO translation configuration?', 'sitepress')); $translation_service_button_js_code .= "')) return false;"; ?> <br/> <div class="icl_cyan_box"> <h3><?php _e('Reset PRO translation configuration', 'sitepress'); ?> </h3> <div class="icl_form_errors"> <?php echo sprintf(__("Resetting your %s account will interrupt any translation jobs that you have in progress.", 'wpml-translation-management'), $translation_service_name); ?> <br/> <?php echo sprintf(__("Only use this function if your current %s account doesn't include any jobs, or if the account was deleted.", 'wpml-translation-management'), $translation_service_name); ?> </div> <p style="padding:6px;"> <label> <input onchange="<?php echo $translation_service_checkbox_js_code; ?> " id="icl_reset_pro_check" type="checkbox" value="1"/> <?php echo sprintf(__('I am about to reset the %s project settings.', 'sitepress'), $translation_service_name); ?> </label> </p> <a id="icl_reset_pro_but" onclick="<?php echo $translation_service_button_js_code; ?> " href="admin.php?page=<?php echo basename(ICL_PLUGIN_PATH); ?> /menu/troubleshooting.php&debug_action=reset_pro_translation_configuration&nonce=<?php echo wp_create_nonce('reset_pro_translation_configuration'); ?> " class="button-primary button-primary-disabled"> <?php _e('Reset PRO translation configuration', 'sitepress'); ?> </a> </div> <br clear="all"/> <?php } //Todo: [WPML 3.2.1] implement this if (1 == 2 && !icl_do_not_promote()) { ?> <div class="icl_cyan_box"> <a name="icl-connection-test"></a> <h3><?php _e('Translation Proxy connection test', 'sitepress'); ?> </h3> <?php if (isset($_GET['icl_action']) && $_GET['icl_action'] == 'icl-connection-test') { ?> <?php //TODO: [WPML 3.2.1] Handle with TP ?> <?php } ?> <a class="button" href="admin.php?page=<?php echo ICL_PLUGIN_FOLDER; ?> /menu/troubleshooting.php&ts=<?php echo time(); ?> &icl_action=icl-connection-test#icl-connection-test"><?php _e('Connect', 'sitepress'); ?> </a> </div> <br clear="all"/> <?php } }