function wpml_wcml_3_8_is_required()
{
    if (defined('WCML_VERSION')) {
        $message_id = 'icl_wcml_3_8_is_required';
        if (version_compare(WCML_VERSION, '3.8', '<')) {
            $message = array('id' => $message_id, 'type' => 'icl-admin-message-warning', 'limit_to_page' => 'wpml-wcml', 'admin_notice' => true, 'classes' => array('error'), 'text' => sprintf(__("%sIMPORTANT:%s You are using a version of WooCommerce Multilingual that is not fully compatible with the current WPML version. The %sproducts translation editor has been deactivated%s for this reason.%sPlease upgrade to %sWooCommerce Multilingual 3.8%s to restore the translation editor for products and use all the other functions.", 'sitepress'), '<strong>', '</strong>', '<strong>', '</strong>', '<br /><br />', '<strong><a href="https://wpml.org/?p=867248">', '</a></strong>'));
            ICL_AdminNotifier::add_message($message);
            ?>

            <?php 
            if (isset($_GET['page']) && $_GET['page'] == 'wpml-wcml') {
                ?>
            <script>
                jQuery(document).ready(function () {
                    jQuery('.wcml_details').unbind('click');
                    jQuery('.wcml_products_translation input[type=text], .wcml_products_translation textarea, .wcml_products_translation button').attr('disabled', 'disabled');
                    jQuery('.wcml_products a.wcml_details').css('text-decoration', 'line-through');
                    jQuery('.wcml_products').on('click', 'a.wcml_details', function () {
                        location.href = '#adminmenumain';
                        jQuery('#icl-id-icl_wcml_3_8_is_required').fadeIn(100).fadeOut(100).fadeIn(100).fadeOut(100).fadeIn(100);
                        return false;
                    })
                })
            </script>
            <?php 
            }
            ?>

            <?php 
        } else {
            ICL_AdminNotifier::remove_message($message_id);
        }
    }
}
Exemple #2
0
/**
 * If the given $source is an error type, it will display an instant message
 *
 * @param $source WP_Error|TranslationProxy_Api_Error|Exception
 */
function icl_handle_error($source)
{
    $error = false;
    if (is_translationproxy_api_error($source)) {
        $error = array('message' => $source->getMessage(), 'code' => $source->getCode());
    } elseif (is_exception($source)) {
        $error = array('message' => $source->getMessage(), 'code' => $source->getCode());
    } elseif (is_wp_error($source)) {
        $error = array('message' => $source->get_error_message(), 'data' => $source->get_error_data(), 'code' => $source->get_error_code());
    }
    if ($error) {
        $message = '';
        $message .= '<strong>';
        if (isset($error['code']) && $error['code']) {
            $message .= '#' . $error['code'] . ' ';
        }
        $message .= $error['message'];
        $message .= '</strong>';
        if (isset($error['data'])) {
            foreach ($error['data'] as $data_key => $data_item) {
                if ($data_key == 'details') {
                    $message .= '<br/>Details: ' . $data_item;
                } elseif ($data_key == 'service_id') {
                    $message .= '<br/>Service ID: ' . $data_item;
                } else {
                    $message .= '<br/><pre>' . print_r($data_item, true) . '</pre>';
                }
            }
        }
        ICL_AdminNotifier::displayInstantMessage($message, 'error');
    }
    return $error;
}
 private function missing_php_extensions()
 {
     $extensions = array();
     if (ini_get('allow_url_fopen') !== '1') {
         $extensions['allow_url_fopen'] = array('type' => 'setting', 'type_description' => __('PHP Setting', 'wpml-translation-management'), 'value' => '1');
     }
     if (!extension_loaded('openssl')) {
         $extensions['openssl'] = array('type' => 'extension', 'type_description' => __('PHP Extension', 'wpml-translation-management'));
     }
     if (class_exists('ICL_AdminNotifier') && (!defined('ICL_HIDE_TRANSLATION_SERVICES') || !ICL_HIDE_TRANSLATION_SERVICES)) {
         $wpml_wp_api_check = new WPML_WP_API();
         if (count($extensions) > 0 && $wpml_wp_api_check->is_tm_page()) {
             $message = '';
             $message .= '<p>';
             $message .= __('WPML Translation Management requires the following PHP extensions and settings:', 'wpml-translation-management');
             $message .= '</p>';
             $message .= '<ul>';
             foreach ($extensions as $id => $data) {
                 $message .= '<li>';
                 if ('setting' === $data['type']) {
                     $message .= $data['type_description'] . ': <code>' . $id . '=' . $data['value'] . '</code>';
                 }
                 if ('extension' === $data['type']) {
                     $message .= $data['type_description'] . ': <strong>' . $id . '</strong>';
                 }
                 $message .= '</li>';
             }
             $message .= '</ul>';
             $args = array('id' => 'wpml-tm-missing-extensions', 'group' => 'wpml-tm-requirements', 'msg' => $message, 'type' => 'error', 'admin_notice' => true, 'hide' => true);
             ICL_AdminNotifier::add_message($args);
         } else {
             ICL_AdminNotifier::remove_message_group('wpml-tm-requirements');
         }
     }
 }
 function render()
 {
     global $wp_taxonomies;
     $icl_post_types = $this->sitepress->get_translatable_documents(true);
     $cposts = array();
     $notice = '';
     foreach ($icl_post_types as $k => $v) {
         if (!in_array($k, array('post', 'page'))) {
             $cposts[$k] = $v;
         }
     }
     $cpt_sync_settings = $this->sitepress->get_setting('custom_posts_sync_option');
     foreach ($cposts as $k => $cpost) {
         if (!isset($cpt_sync_settings[$k])) {
             $cposts_sync_not_set[] = $cpost->labels->name;
         }
     }
     if (!empty($cposts_sync_not_set)) {
         $notice = '<p class="updated fade">';
         $notice .= sprintf(__("You haven't set your <a %s>synchronization preferences</a> for these custom posts: %s. Default value was selected.", 'sitepress'), 'href="admin.php?page=' . WPML_TM_FOLDER . '/menu/main.php&sm=mcsetup"', '<i>' . join('</i>, <i>', $cposts_sync_not_set) . '</i>');
         $notice .= '</p>';
     }
     $icl_post_types = $this->sitepress->get_translatable_documents(true);
     if ($icl_post_types) {
         $custom_posts = array();
         $icl_post_types = $this->sitepress->get_translatable_documents(true);
         foreach ($icl_post_types as $k => $v) {
             if (!in_array($k, array('post', 'page'))) {
                 $custom_posts[$k] = $v;
             }
         }
         $slug_settings = $this->sitepress->get_setting('posts_slug_translation');
         foreach ($custom_posts as $k => $custom_post) {
             $_has_slug = isset($custom_post->rewrite['slug']) && $custom_post->rewrite['slug'];
             $_translate = !empty($slug_settings['types'][$k]);
             if ($_has_slug) {
                 $string_id_prepared = $this->wpdb->prepare("SELECT id FROM {$this->wpdb->prefix}icl_strings WHERE name = %s AND value = %s ", array('Url slug: ' . trim($custom_post->rewrite['slug'], '/'), trim($custom_post->rewrite['slug'], '/')));
                 $string_id = $this->wpdb->get_var($string_id_prepared);
                 if ($slug_settings['on'] && $_translate && !$string_id) {
                     $message = sprintf(__("%s slugs are set to be translated, but they are missing their translation", 'sitepress'), $custom_post->labels->name);
                     $notice .= ICL_AdminNotifier::displayInstantMessage($message, 'error', 'below-h2', true);
                 }
             }
         }
     }
     $ctaxonomies = array_diff(array_keys((array) $wp_taxonomies), array('post_tag', 'category', 'nav_menu', 'link_category', 'post_format'));
     $tax_sync_settings = $this->sitepress->get_setting('taxonomies_sync_option');
     foreach ($ctaxonomies as $ctax) {
         if (!isset($tax_sync_settings[$ctax])) {
             $tax_sync_not_set[] = $wp_taxonomies[$ctax]->label;
         }
     }
     if (!empty($tax_sync_not_set)) {
         $notice .= '<p class="updated">';
         $notice .= sprintf(__("You haven't set your <a %s>synchronization preferences</a> for these taxonomies: %s. Default value was selected.", 'sitepress'), 'href="admin.php?page=' . WPML_TM_FOLDER . '/menu/main.php&sm=mcsetup"', '<i>' . join('</i>, <i>', $tax_sync_not_set) . '</i>');
         $notice .= '</p>';
     }
     return $notice;
 }
Exemple #5
0
function wpml_new_duplicated_terms_filter($post_ids, $duplicates_only = true)
{
    require_once ICL_PLUGIN_PATH . '/inc/taxonomy-term-translation/wpml-term-hierarchy-duplication.class.php';
    $hier_dupl = new WPML_Term_Hierarchy_Duplication();
    $taxonomies = $hier_dupl->duplicates_require_sync($post_ids, $duplicates_only);
    if ((bool) $taxonomies) {
        $text = __("The posts you just saved led to the creation of new hierarchical terms.\nTheir hierarchical relationship to one another is not yet synchronized with the original post's terms for the following taxonomies:", 'wpml-translation-management');
        $text = '<p>' . $text . '</p>';
        foreach ($taxonomies as $taxonomy) {
            $text .= '<p><a href="admin.php?page=' . ICL_PLUGIN_FOLDER . '/menu/taxonomy-translation.php&taxonomy=' . $taxonomy . '&sync=1">' . get_taxonomy_labels(get_taxonomy($taxonomy))->name . '</a></p>';
        }
        $message_args = array('id' => 'duplication-tm-dashboard-notification', 'text' => $text, 'type' => 'information', 'group' => 'duplication-notification', 'admin_notice' => true, 'show_once' => true, 'hide_per_user' => true);
        ICL_AdminNotifier::add_message($message_args);
    }
}
 public function promote_wcml_message()
 {
     $promote = false;
     if (class_exists('WooCommerce') && !class_exists('woocommerce_wpml')) {
         global $pagenow;
         $promote = $this->wpml_wp_api->is_tm_page();
         if (isset($_GET['post_type']) && !empty($_GET['post_type'])) {
             $promote = 'product' === $_GET['post_type'] && 'edit.php' === $pagenow;
         }
     }
     if ($promote) {
         $message = '';
         $wcml_link = '<a href="https://wordpress.org/plugins/woocommerce-multilingual" target="_blank">WooCommerce Multilingual.</a>';
         $message .= sprintf(__('Looks like you are running a multilingual WooCommerce site. To easily translate WooCommerce products and categories, you should use %s', 'wpml-translation-management'), $wcml_link);
         $args = array('id' => 'promote-wcml', 'group' => 'promote-wcml', 'msg' => $message, 'type' => 'notice', 'admin_notice' => true, 'hide' => true);
         ICL_AdminNotifier::add_message($args);
     } else {
         ICL_AdminNotifier::remove_message_group('promote-wcml');
     }
 }
function cpt_default_and_st_language_warning()
{
    static $called = false;
    if (!$called) {
        global $sitepress, $sitepress_settings;
        $st_language_code = $sitepress_settings['st']['strings_language'];
        $st_language = $sitepress->get_display_language_name($st_language_code, $sitepress->get_admin_language());
        $st_page_url = admin_url('admin.php?page=wpml-string-translation/menu/string-translation.php');
        $message = 'The strings language in your site is set to %s instead of English. ';
        $message .= 'This means that the original slug will appear in the URL when displaying content in %s.';
        $message .= ' ';
        $message .= '<strong><a href="%s" target="_blank">Read more</a> | ';
        $message .= '<a href="%s#icl_st_sw_form">Change strings language</a></strong>';
        $message = __($message, 'wpml-string-translation');
        $message = sprintf($message, $st_language, $st_language, 'http://wpml.org/faq/string-translation-default-language-not-english/', $st_page_url);
        $fallback_message = _('<a href="%s" target="_blank">How to translate strings when default language is not English</a>');
        $fallback_message = sprintf($fallback_message, 'http://wpml.org/faq/string-translation-default-language-not-english/');
        ICL_AdminNotifier::addMessage('cpt_default_and_st_language_warning', $message, 'icl-admin-message-warning', true, $fallback_message, false, 'cpt-translation');
        $called = true;
    }
}
 public static function check_settings_integrity()
 {
     if (wpml_is_ajax()) {
         return true;
     }
     if (isset($_GET['debug_action']) && $_GET['nonce'] == wp_create_nonce($_GET['debug_action'])) {
         if ($_GET['debug_action'] == 'reset_wpml_settings') {
             $referrer = isset($_SERVER['HTTP_REFERER']) && $_SERVER['HTTP_REFERER'] ? $_SERVER['HTTP_REFERER'] : get_admin_url();
             $current_settings = get_option('icl_sitepress_settings');
             unset($current_settings['setup_complete']);
             unset($current_settings['setup_wizard_step']);
             unset($current_settings['existing_content_language_verified']);
             unset($current_settings['dont_show_help_admin_notice']);
             global $wpdb;
             $wpdb->query('TRUNCATE TABLE ' . $wpdb->prefix . 'icl_translations');
             update_option('icl_sitepress_settings', $current_settings);
             wp_redirect($referrer);
             exit;
         }
     }
     global $wpdb;
     static $result;
     if (isset($result)) {
         return $result;
     }
     $current_settings = get_option('icl_sitepress_settings');
     if (!$current_settings) {
         return true;
     }
     $setup_wizard_step = false;
     if (isset($current_settings['setup_wizard_step'])) {
         $setup_wizard_step = $current_settings['setup_wizard_step'];
     }
     $setup_complete = false;
     $setup_complete_missing = true;
     if (isset($current_settings['setup_complete'])) {
         $setup_complete = $current_settings['setup_complete'];
         $setup_complete_missing = false;
     }
     //Skip checks during first setup wizard
     if ($setup_wizard_step !== false && $setup_wizard_step < 4 || !$setup_complete_missing && $setup_complete === false && $setup_wizard_step == 4) {
         return true;
     }
     $default_language = false;
     $default_language_missing = true;
     if (isset($current_settings['default_language'])) {
         $default_language = $current_settings['default_language'];
         $default_language_missing = false;
     }
     $active_languages_sql = "SELECT * FROM " . $wpdb->prefix . 'icl_languages WHERE active=%d';
     $active_languages_prepared = $wpdb->prepare($active_languages_sql, array(1));
     $active_languages = $wpdb->get_results($active_languages_prepared);
     $existing_translations_sql = "SELECT count(*) FROM " . $wpdb->prefix . 'icl_translations';
     $existing_translations = $wpdb->get_var($existing_translations_sql);
     $show_notice = false;
     $message = '';
     if ((!$setup_complete || !$default_language) && $existing_translations) {
         $message .= '<p>';
         $message .= __('Your WPML settings seem to be corrupted. To avoid corrupting your existing data, we have hidden WPML from this site.', 'sitepress');
         $message .= '</p>';
         $message .= '<p>';
         $message .= __('If this is the first time you install WPML on this site, you may have faced a database or script connection drop, that caused settings to be not completely store.', 'sitepress');
         $message .= __('In this case, you can click on the <strong>Reset Settings</strong> button: this will reset WPML settings and any language translation information, allowing you to restart the wizard.', 'sitepress');
         $message .= '</p>';
         $message .= '<p>';
         $message .= sprintf(__('If you have just upgraded WPML or after starting over you keep getting this message, please contact the <a href="%s">support forum</a> as soon as possible, in order to provide you with a fix to this issue.', 'sitepress'), 'https://wpml.org/forums/');
         $message .= '</p>';
         $message .= '<p>';
         $confirm_message = _x('Are you sure you want to reset WPML Settings?', 'Reset WPML settings', 'sitepress');
         $confirm_message .= ' ';
         $confirm_message .= _x('This will also empty translation information (if any).', 'Reset WPML settings', 'sitepress');
         $message .= '<a href="?icl_reset_settings=1&debug_action=reset_wpml_settings&nonce=' . wp_create_nonce('reset_wpml_settings') . '" class="button" onclick="return window.confirm(\'' . $confirm_message . '\');" >' . __('Reset Settings', 'sitepress') . '</a>';
         $message .= '&nbsp;';
         $message .= '&nbsp;';
         $message .= '&nbsp;';
         $message .= '<a href="https://wpml.org/forums/" class="button">' . __('Contact Support', 'sitepress') . '</a>';
         $message .= '</p>';
         $message .= '<p>';
         $message .= __('Additional details for the support team (there is no need to copy it, as the support team will be able to see it once logged in):', 'sitepress');
         $message .= '</p>';
         $message .= '<p><textarea rows="10" style="width:100%;display:block;" onclick="this.focus();this.select();" readonly="readonly">';
         $message .= str_repeat('=', 50);
         $wpml_plugins_list = SitePress::get_installed_plugins();
         foreach ($wpml_plugins_list as $name => $plugin_data) {
             $plugin_name = $name;
             $file = $plugin_data['file'];
             $message .= PHP_EOL . $plugin_name;
             $message .= ' ' . (isset($plugin_data['plugin']['Version']) ? $plugin_data['plugin']['Version'] : __('Version n/a', 'sitepress'));
             $message .= ' => ';
             if (empty($plugin_data['plugin'])) {
                 $message .= 'Not installed';
             } else {
                 $message .= 'Installed';
             }
             $message .= '/';
             $message .= isset($file) && is_plugin_active($file) ? 'Active' : 'Not Active';
         }
         $message .= PHP_EOL . str_repeat('-', 50);
         $message .= PHP_EOL . 'icl_translations count: ' . ($existing_translations ? $existing_translations : '0');
         $message .= PHP_EOL . 'setup_complete: ' . ($setup_complete ? 'true' : 'false');
         $message .= PHP_EOL . 'setup_complete missing: ' . ($setup_complete_missing ? 'true' : 'false');
         $message .= PHP_EOL . 'default_language: ' . ($default_language ? $default_language : '""');
         $message .= PHP_EOL . 'default_language_missing: ' . ($default_language_missing ? 'true' : 'false');
         $message .= PHP_EOL . PHP_EOL . 'active_languages: ' . PHP_EOL . print_r($active_languages, true);
         $message .= PHP_EOL . PHP_EOL . 'icl_sitepress_settings (serialized): ' . PHP_EOL . serialize($current_settings);
         $message .= PHP_EOL . PHP_EOL . 'icl_sitepress_settings (unserialized): ' . PHP_EOL . print_r($current_settings, true);
         $message .= PHP_EOL . str_repeat('=', 50);
         $message .= '</textarea></p>';
         $show_notice = true;
     }
     //		ICL_AdminNotifier::removeMessage( 'check_settings_integrity' );
     ICL_AdminNotifier::removeMessage('check_settings_integrity_corrupted');
     if ($show_notice) {
         ICL_AdminNotifier::addMessage('check_settings_integrity_corrupted', $message, 'error', false, false, false, 'check_settings_integrity', true);
         ICL_AdminNotifier::displayMessages('check_settings_integrity');
     }
     $result = !$show_notice;
     return $result;
 }
 function display_basket_notification($position)
 {
     if (class_exists('ICL_AdminNotifier') && class_exists('TranslationProxy_Basket')) {
         $positions = TranslationProxy_Basket::get_basket_notification_positions();
         if (isset($positions[$position])) {
             ICL_AdminNotifier::display_messages('translation-basket-notification');
         }
     }
 }
 private function show_3_2_upgrade_notice()
 {
     global $sitepress;
     $upgrade_setting = 'tm_upgrade_3.2';
     if (!$sitepress->get_setting($upgrade_setting)) {
         $args = array('id' => $upgrade_setting, 'msg' => '<p>' . __("We've updated the way to send documents to translation", 'wpml-translation-management') . '</p>' . '<a href="https://wpml.org/version/wpml-3-2/">' . __('WPML 3.2 release notes', 'wpml-translation-management') . '</a>', 'admin_notice' => true, 'hide' => true, 'limit_to_page' => WPML_TM_FOLDER . '/menu/main.php');
         ICL_AdminNotifier::add_message($args);
         $sitepress->set_setting($upgrade_setting, true);
         $sitepress->save_settings();
     }
 }
    } else {
        echo ' dir="ltr" style="text-align:left;direction:ltr;width:100%"';
    }
}
?>
<div class="wrap">

    <div id="icon-wpml" class="icon32"><br /></div>
    <h2><?php 
echo __('String translation', 'wpml-string-translation');
?>
</h2>

	<?php 
if (class_exists('ICL_AdminNotifier')) {
    ICL_AdminNotifier::displayMessages('string-translation');
}
?>

    <?php 
if (isset($icl_st_po_strings) && !empty($icl_st_po_strings)) {
    ?>

        <p><?php 
    printf(__("These are the strings that we found in your .po file. Please carefully review them. Then, click on the 'add' or 'cancel' buttons at the %sbottom of this screen%s. You can exclude individual strings by clearing the check boxes next to them.", 'wpml-string-translation'), '<a href="#add_po_strings_confirm">', '</a>');
    ?>
</p>

        <form method="post" action="<?php 
    echo admin_url("admin.php?page=" . WPML_ST_FOLDER . "/menu/string-translation.php");
    ?>
 /**
  * Ajax handler for the troubleshoot page. Updates the term name on those terms given via the Ajax action.
  */
 public static function wpml_update_term_names_troubleshoot()
 {
     global $wpdb;
     ICL_AdminNotifier::removeMessage('termssuffixnotice');
     $term_names = array();
     $nonce = filter_input(INPUT_POST, '_icl_nonce', FILTER_SANITIZE_STRING);
     if (!wp_verify_nonce($nonce, 'update_term_names_nonce')) {
         die('Wrong Nonce');
     }
     $request_post_terms = filter_input(INPUT_POST, 'terms');
     if ($request_post_terms) {
         $term_names = json_decode(stripcslashes($request_post_terms));
         if (!is_object($term_names)) {
             $term_names = array();
         }
     }
     $updated = array();
     foreach ($term_names as $term_id => $new_name) {
         $res = $wpdb->update($wpdb->terms, array('name' => $new_name), array('term_id' => $term_id));
         if ($res) {
             $updated[] = $term_id;
         }
     }
     wp_send_json_success($updated);
 }
    static function _st_default_and_st_language_warning()
    {
        global $sitepress;
        $string_settings = apply_filters('wpml_get_setting', false, 'st');
        if (isset($string_settings['strings_language'])) {
            ICL_AdminNotifier::removeMessage('_st_default_language_warning');
            static $called = false;
            if (defined('WPML_ST_FOLDER') && !$called) {
                $st_language_code = $string_settings['strings_language'];
                $st_language = $sitepress->get_display_language_name($st_language_code, $sitepress->get_admin_language());
                $page = WPML_ST_FOLDER . '/menu/string-translation.php';
                $st_page_url = admin_url('admin.php?page=' . $page);
                $message = __('The strings language in your site is set to %s instead of English.
					This means that all English texts that are hard-coded in PHP will appear when displaying content in %s.
					<strong><a href="%s" target="_blank">Read more</a> |  <a href="%s#icl_st_sw_form">Change strings language</a></strong>', 'wpml-string-translation');
                $message = sprintf($message, $st_language, $st_language, 'https://wpml.org/faq/string-translation-default-language-not-english/', $st_page_url);
                $fallback_message = __('<a href="%s" target="_blank">How to translate strings when default language is not English</a>', 'wpml-string-translation');
                $fallback_message = sprintf($fallback_message, 'https://wpml.org/faq/string-translation-default-language-not-english/');
                ICL_AdminNotifier::addMessage('_st_default_and_st_language_warning', $message, 'icl-admin-message-warning', true, $fallback_message, false, 'string-translation');
                $called = true;
            }
        }
    }
    /**
     * Add/edit local translator form
     *
     * @param string $action add|edit
     * @param int|object $selected_translator
     *
     * @return mixed
     */
    private function icl_local_edit_translator_form($action = 'add', $selected_translator = 0)
    {
        $blog_users_nt = TranslationManagement::get_blog_not_translators();
        $output = '';
        $return['name'] = __('Local', 'wpml-translation-management');
        $return['description'] = __('Your own translators', 'wpml-translation-management');
        if ($action === 'add' && empty($blog_users_nt)) {
            $alert_message = '<p>';
            $alert_message .= __('All WordPress users are already translators. To add more translators, first create accounts for them.', 'wpml-translation-management');
            $alert_message .= '</p>';
            $return['content'] = '';
            $return['messages'] = ICL_AdminNotifier::display_instant_message($alert_message, 'information', false, true);
            return $return;
        }
        $output .= '<div id="icl_tm_add_user_errors">
        <span class="icl_tm_no_to">' . __('Select user.', 'wpml-translation-management') . '</span>
    </div>
    <input type="hidden" name="icl_tm_action" value="' . $action . '_translator" />' . wp_nonce_field($action . '_translator', $action . '_translator_nonce', true, false);
        if (!$selected_translator) {
            $output .= '<input type="hidden" id="icl_tm_selected_user" name="user_id" />';
            $output .= '<input type="text" id="icl_quick_src_users" placeholder="' . esc_attr__('search', 'wpml-translation-management') . '" />';
            $output .= '&nbsp;<span id="icl_user_src_nf"></span>';
            $output .= '<img style="display:none;margin-left:3px;" src="' . esc_url(admin_url('images/wpspin_light.gif')) . '" class="waiting" alt="" />';
            $output .= '<p>' . __('To add translators, they must first have accounts in WordPress. Translators can have any editing privileges, including subscriber.') . '</p>';
        } else {
            $output .= '<span class="updated fade" style="padding:4px">' . sprintf(__('Editing language pairs for <strong>%s</strong>', 'wpml-translation-management'), esc_html($selected_translator->display_name) . ' (' . $selected_translator->user_login . ')') . '</span>';
            $output .= '<input type="hidden" name="user_id" value="' . $selected_translator->ID . '" />';
        }
        if ($selected_translator) {
            $output .= '<br />

      <div class="icl_tm_lang_pairs"';
            if ($selected_translator) {
                $output .= ' style="display:block"';
            }
            $output .= '>
          <ul>';
            $languages = $this->get_translation_languages();
            foreach ($languages as $from_lang) {
                $lang_from_selected = false;
                if ($selected_translator && 0 < @count($selected_translator->language_pairs[$from_lang['code']])) {
                    $lang_from_selected = true;
                }
                $output .= '<li class="js-icl-tm-lang-from';
                if ($lang_from_selected) {
                    $output .= ' js-lang-from-selected';
                }
                $output .= '">';
                $output .= '<label><input class="icl_tm_from_lang" type="checkbox"';
                if ($lang_from_selected) {
                    $output .= ' checked="checked"';
                }
                $output .= ' />&nbsp;';
                $output .= sprintf(__('From %s', 'wpml-translation-management'), $from_lang['display_name']) . '</label>
              <div class="icl_tm_lang_pairs_to"';
                if ($selected_translator && 0 < @count($selected_translator->language_pairs[$from_lang['code']])) {
                    $output .= ' style="display:block"';
                }
                $output .= '>
                  <small>' . __('to', 'wpml-translation-management') . '</small>
                  <ul>';
                foreach ($languages as $to_lang) {
                    if ($from_lang['code'] === $to_lang['code']) {
                        continue;
                    }
                    $lang_selected = false;
                    if ($selected_translator->ID && isset($selected_translator->language_pairs[$from_lang['code']][$to_lang['code']])) {
                        $lang_selected = true;
                    }
                    $output .= '<li class="js-icl-tm-lang-pair';
                    if ($lang_selected) {
                        $output .= ' js-lang-pair-selected';
                    }
                    $output .= '">
                      <label><input class="icl_tm_to_lang" type="checkbox" name="lang_pairs[' . $from_lang['code'] . '][' . $to_lang['code'] . ']" value="1"';
                    if ($lang_selected) {
                        $output .= ' checked="checked"';
                    }
                    $output .= ' />&nbsp;';
                    $output .= $to_lang['display_name'] . '</label>&nbsp;
                      </li>';
                }
                $output .= '</ul>
              </div>
              </li>';
            }
            $output .= '</ul>';
            $output .= '</div><input class="button-primary" type="submit" value="';
            $output .= $selected_translator ? esc_attr(__('Update', 'wpml-translation-management')) : esc_attr(__('Add as translator', 'wpml-translation-management'));
            $output .= '" />&nbsp;<input type="submit" value="' . __('Cancel', 'wpml-translation-management') . '" name="cancel" class="button-secondary" onclick="history.go(-1); return false;" />';
        }
        $return['content'] = $output;
        return $action == 'edit' ? $output : $return;
    }
 /**
  * Ajax handler for the troubleshoot page. Updates the term name on those terms given via the Ajax action.
  */
 public static function wpml_update_term_names_troubleshoot()
 {
     global $wpdb;
     ICL_AdminNotifier::removeMessage('termssuffixnotice');
     $term_names = array();
     if (isset($_POST['terms']) && $_POST['terms']) {
         $term_names = json_decode(stripcslashes($_POST['terms']));
         if (!is_object($term_names)) {
             $term_names = array();
         }
     }
     $updated = array();
     foreach ($term_names as $term_id => $new_name) {
         $res = $wpdb->update($wpdb->terms, array('name' => $new_name), array('term_id' => $term_id));
         if ($res) {
             $updated[] = $term_id;
         }
     }
     wp_send_json_success($updated);
 }
            ?>
'>
		<?php 
        }
        echo '<p>' . stripslashes($message);
        if ($hide) {
            echo ' <a href="#" class="icl-admin-message-hide">' . __('Dismiss', 'ICanLocalize') . '</a>';
        }
        echo '</p>';
        ?>
		</div>
	<?php 
    }
    public static function displayInstantMessage($message, $type = '', $class = false, $return = false)
    {
        if (!$class) {
            $class = 'icl-' . $type;
            $class .= ' icl-admin-instant-message';
        }
        $class .= ' ' . $type;
        $result = '<div class="' . $class . '">';
        $result .= stripslashes($message);
        $result .= '</div>';
        if (!$return) {
            echo $result;
        }
        return $result;
    }
}
ICL_AdminNotifier::init();
 function administration_menu()
 {
     ICL_AdminNotifier::removeMessage('setup-incomplete');
     $main_page = apply_filters('icl_menu_main_page', basename(ICL_PLUGIN_PATH) . '/menu/languages.php');
     $wpml_setup_is_complete = SitePress_Setup::setup_complete();
     if ($wpml_setup_is_complete) {
         add_menu_page(__('WPML', 'sitepress'), __('WPML', 'sitepress'), 'wpml_manage_languages', $main_page, null, ICL_PLUGIN_URL . '/res/img/icon16.png');
         add_submenu_page($main_page, __('Languages', 'sitepress'), __('Languages', 'sitepress'), 'wpml_manage_languages', basename(ICL_PLUGIN_PATH) . '/menu/languages.php');
         //By Gen, moved Translation management after language, because problems with permissions
         do_action('icl_wpml_top_menu_added');
         $wpml_setup_is_complete = $this->get_setting('existing_content_language_verified') && 2 <= count($this->get_active_languages());
         if ($wpml_setup_is_complete) {
             add_submenu_page($main_page, __('Theme and plugins localization', 'sitepress'), __('Theme and plugins localization', 'sitepress'), 'wpml_manage_theme_and_plugin_localization', basename(ICL_PLUGIN_PATH) . '/menu/theme-localization.php');
             if (!defined('WPML_TM_VERSION')) {
                 add_submenu_page($main_page, __('Translation options', 'sitepress'), __('Translation options', 'sitepress'), 'wpml_manage_translation_options', basename(ICL_PLUGIN_PATH) . '/menu/translation-options.php');
             }
         }
         $wpml_admin_menus_args = array('existing_content_language_verified' => $this->get_setting('existing_content_language_verified'), 'active_languages_count' => count($this->get_active_languages()), 'wpml_setup_is_ok' => $wpml_setup_is_complete);
         do_action('wpml_admin_menus', $wpml_admin_menus_args);
     } else {
         $main_page = basename(ICL_PLUGIN_PATH) . '/menu/languages.php';
         add_menu_page(__('WPML', 'sitepress'), __('WPML', 'sitepress'), 'manage_options', $main_page, null, ICL_PLUGIN_URL . '/res/img/icon16.png');
         add_submenu_page($main_page, __('Languages', 'sitepress'), __('Languages', 'sitepress'), 'wpml_manage_languages', $main_page);
         if (!$this->is_troubleshooting_page() && !SitePress_Setup::languages_table_is_complete()) {
             $troubleshooting_url = admin_url('admin.php?page=' . ICL_PLUGIN_FOLDER . '/menu/troubleshooting.php');
             $troubleshooting_link = '<a href="' . $troubleshooting_url . '" title="' . esc_attr(__('Troubleshooting', 'sitepress')) . '">' . __('Troubleshooting', 'sitepress') . '</a>';
             $message = '';
             $message .= __('WPML is missing some records in the languages tables and it cannot fully work until this issue is fixed.', 'sitepress');
             $message .= '<br />';
             $message .= sprintf(__('Please go to the %s page and click on %s to fix this problem.', 'sitepress'), $troubleshooting_link, __('Fix languages tables', 'sitepress'));
             $message .= '<br />';
             $message .= '<br />';
             $message .= __('This warning will disappear once this issue is fixed.', 'sitepress');
             ICL_AdminNotifier::removeMessage('setup-incomplete');
             ICL_AdminNotifier::addMessage('setup-incomplete', $message, 'error', false, false, false, 'setup', true);
             ICL_AdminNotifier::displayMessages('setup');
         }
     }
     add_submenu_page($main_page, __('Support', 'sitepress'), __('Support', 'sitepress'), 'wpml_manage_support', ICL_PLUGIN_FOLDER . '/menu/support.php');
     $this->troubleshooting_menu(ICL_PLUGIN_FOLDER . '/menu/support.php');
     $this->debug_information_menu(ICL_PLUGIN_FOLDER . '/menu/support.php');
 }
 public function display_instant_message($message, $type = 'information', $class = false, $return = false, $fadeout = false)
 {
     return ICL_AdminNotifier::display_instant_message($message, $type, $class, $return, $fadeout);
 }
Exemple #19
0
/**
 * Handle notification messages for WPML String Translation when default language and ST language is != 'en'
 */
function wp_types_st_language_warning()
{
    global $sitepress, $sitepress_settings;
    if (class_exists('ICL_AdminNotifier') && defined('ICL_SITEPRESS_VERSION')) {
        ICL_AdminNotifier::removeMessage('wp_types_default_language_warning');
        static $called = false;
        if (!$called && isset($sitepress_settings['st'])) {
            $st_language_code = $sitepress_settings['st']['strings_language'];
            $st_language = $sitepress->get_display_language_name($st_language_code, $sitepress->get_admin_language());
            $st_page_url = admin_url('admin.php?page=' . WPML_ST_FOLDER . '/menu/string-translation.php');
            $message = 'The strings language in your site is set to %s instead of English. ';
            $message .= 'This means that all English texts that are hard-coded in PHP will appear when displaying content in %s.';
            $message .= ' ';
            $message .= '<strong><a href="%s" target="_blank">Read more</a> | ';
            $message .= '<a href="%s#icl_st_sw_form">Change strings language</a></strong>';
            $message = __($message, 'wpml-string-translation');
            $message = sprintf($message, $st_language, $st_language, 'http://wpml.org/faq/string-translation-default-language-not-english/', $st_page_url);
            $fallback_message = _('<a href="%s" target="_blank">How to translate strings when default language is not English</a>');
            $fallback_message = sprintf($fallback_message, 'http://wpml.org/faq/string-translation-default-language-not-english/');
            ICL_AdminNotifier::addMessage('wp_types_st_language_warning', $message, 'icl-admin-message icl-admin-message-warning', true, $fallback_message, false, 'wp-types');
            $called = true;
        }
    }
}
 private function service_authentication_notice()
 {
     $message_id = 'current_service_authentication_required';
     if (!$this->is_translators_tab() && $this->service_activation_incomplete()) {
         $current_service_name = TranslationProxy::get_current_service_name();
         if (defined('WPML_TP_DEFAULT_SUID')) {
             $service_tab_name = $current_service_name;
         } else {
             $service_tab_name = __('Translators', 'wpml-translation-management');
         }
         $services_url = "admin.php?page=" . WPML_TM_FOLDER . "/menu/main.php&sm=translators";
         $href_open = '<strong><a href="' . $services_url . '">';
         $href_close = '</a></strong>';
         $services_link = $href_open . $service_tab_name . ' Tab' . $href_close;
         $service_authentication_link = '<strong>' . __('Click here to authenticate', 'wpml-translation-management') . '</strong>';
         $service_deactivation_link = '<strong>' . __('Click here to deactivate', 'wpml-translation-management') . '</strong>';
         if (defined('WPML_TP_DEFAULT_SUID')) {
             $authentication_message = __("You are using a translation service which requires authentication.", 'wpml-translation-management');
             $authentication_message .= '<ul>';
             $authentication_message .= '<li>';
             $authentication_message .= sprintf(__("Please go to %s and use the link %s.", 'wpml-translation-management'), $services_link, $service_authentication_link);
             $authentication_message .= '</li>';
         } else {
             $problem_detected = false;
             if ($this->service_requires_authentication()) {
                 $authentication_message = __("You have selected a translation service which requires authentication.", 'wpml-translation-management');
             } elseif ($this->service_requires_translators()) {
                 $authentication_message = __("You have selected a translation service which requires translators.", 'wpml-translation-management');
                 $service_authentication_link = '<strong>' . __('Add Translator', 'wpml-translation-management') . ' &raquo;</strong>';
             } else {
                 $problem_detected = true;
                 $authentication_message = __("There is a problem with your translation service.", 'wpml-translation-management');
             }
             $authentication_message .= '<ul>';
             $authentication_message .= '<li>';
             if ($this->service_requires_authentication()) {
                 $authentication_message .= sprintf(__("If you wish to use %s, please go to %s and use the link %s.", 'wpml-translation-management'), '<strong>' . $current_service_name . '</strong>', $services_link, $service_authentication_link);
             } elseif ($this->service_requires_translators()) {
                 $authentication_message .= sprintf(__("If you wish to use %s, please go to %s and use the link %s.", 'wpml-translation-management'), '<strong>' . $current_service_name . '</strong>', $services_link, $service_authentication_link);
             } elseif ($problem_detected) {
                 $authentication_message .= sprintf(__("Please contact your administrator.", 'wpml-translation-management'), $services_link, $service_authentication_link);
             }
             $authentication_message .= '</li>';
             $authentication_message .= '<li>';
             $authentication_message .= sprintf(__("If you wish to use only local translators, please go to %s and use the link %s.", 'wpml-translation-management'), $services_link, $service_deactivation_link);
             $authentication_message .= '</li>';
             $authentication_message .= '</ul>';
         }
         $args = array('id' => $message_id, 'group' => 'current_service_authentication', 'msg' => $authentication_message, 'type' => 'error', 'admin_notice' => true, 'hide' => false, 'limit_to_page' => array(WPML_TM_FOLDER . '/menu/main.php'));
         ICL_AdminNotifier::add_message($args);
     } else {
         ICL_AdminNotifier::remove_message($message_id);
     }
 }
    private function build_content_dashboard_documents_options()
    {
        $translate_checked = 'checked="checked"';
        $duplicate_checked = '';
        $do_nothing_checked = '';
        if ($this->is_translation_locked()) {
            $translate_checked = 'disabled="disabled"';
            $do_nothing_checked = 'checked="checked"';
        }
        ?>
        <table class="widefat fixed" cellspacing="0" style="width:100%">
            <thead>
            <tr>
                <th><?php 
        _e('Translation options', 'wpml-translation-management');
        ?>
</th>
            </tr>
            </thead>
            <tbody>
            <tr>
                <td>
                    <table id="icl_tm_languages" class="widefat" style="width:auto;border: none;">
                        <thead>
                        <tr>
                            <td><strong style="font-size: large"><?php 
        _e('All Languages', 'wpml-translation-management');
        ?>
</strong></td>
                            <td>
                                <input type="radio" id="translate-all" value="1" name="radio-action-all" <?php 
        echo $translate_checked;
        ?>
 /> <?php 
        _e('Translate', 'wpml-translation-management');
        ?>
                            </td>
                            <td>
                                <input type="radio" id="duplicate-all" value="2" name="radio-action-all" <?php 
        echo $duplicate_checked;
        ?>
 /> <?php 
        _e('Duplicate content', 'wpml-translation-management');
        ?>
                            </td>
                            <td>
                                <input type="radio" id="update-none" value="0" name="radio-action-all" <?php 
        echo $do_nothing_checked;
        ?>
 /> <?php 
        _e('Do nothing', 'wpml-translation-management');
        ?>
                            </td>
                        </tr>
                        <tr class="blank_row">
                            <td colspan="3" style="height:6px!important;"></td>
                        </tr>
                        </thead>
                        <tbody>
                        <?php 
        foreach ($this->active_languages as $lang) {
            ?>
                            <?php 
            if ($lang['code'] == $this->translation_filter['from_lang']) {
                continue;
            }
            $radio_prefix_html = '<input type="radio" name="tr_action[' . $lang['code'] . ']" ';
            ?>
                            <tr>
                                <td><strong><?php 
            echo $lang['display_name'];
            ?>
</strong></td>
                                <td>
                                    <label>
                                        <?php 
            echo $radio_prefix_html;
            ?>
 value="1" <?php 
            echo $translate_checked;
            ?>
/>
                                        <?php 
            _e('Translate', 'wpml-translation-management');
            ?>
                                    </label>
                                </td>
                                <td>
                                    <label>
                                        <?php 
            echo $radio_prefix_html;
            ?>
 value="2" <?php 
            echo $duplicate_checked;
            ?>
/>
                                        <?php 
            _e('Duplicate content', 'wpml-translation-management');
            ?>
                                    </label>
                                </td>
                                <td>
                                    <label>
                                        <?php 
            echo $radio_prefix_html;
            ?>
 value="0" <?php 
            echo $do_nothing_checked;
            ?>
/>
                                        <?php 
            _e('Do nothing', 'wpml-translation-management');
            ?>
                                    </label>
                                </td>
                            </tr>
                        <?php 
        }
        ?>
                        </tbody>
                    </table>
                    <br/>

                    <input name="iclnonce" type="hidden" value="<?php 
        echo wp_create_nonce('pro-translation-icl');
        ?>
"/>
                    <?php 
        $tm_jobs_submit_disabled = disabled(empty($this->selected_languages) && empty($this->selected_posts), true, false);
        $tm_jobs_submit_caption = __('Add to translation basket', 'wpml-translation-management');
        ?>
                    <input id="icl_tm_jobs_submit" class="button-primary" type="submit" value="<?php 
        echo $tm_jobs_submit_caption;
        ?>
" <?php 
        echo $tm_jobs_submit_disabled;
        ?>
 />

                    <div id="icl_dup_ovr_warn" class="icl_dup_ovr_warn" style="display:none;">
                        <?php 
        $dup_message = '<p>';
        $dup_message .= __('Any existing content (translations) will be overwritten when creating duplicates.', 'wpml-translation-management');
        $dup_message .= '</p>';
        $dup_message .= '<p>';
        $dup_message .= __("When duplicating content, please first duplicate parent pages to maintain the site's hierarchy.", 'wpml-translation-management');
        $dup_message .= '</p>';
        ICL_AdminNotifier::display_instant_message($dup_message, 'error');
        ?>
                    </div>
                    <div style="width: 45%; margin: auto; position: relative; top: -30px;">
                        <?php 
        ICL_AdminNotifier::display_messages('translation-dashboard-under-translation-options');
        ICL_AdminNotifier::remove_message('items_added_to_basket');
        ?>
                    </div>
                </td>
            </tr>
            </tbody>
        </table>
    <?php 
    }
        /**
         * Serves WPML > String translation form submission and adds strings to basket
         *
         * @param array $string_ids identifiers of strings
         * @param       $source_language
         * @param array $target_languages selected target languages
         * @return bool
         * @todo: [WPML 3.3] move to ST and handle with hooks
         */
        public static function add_strings_to_basket($string_ids, $source_language, $target_languages)
        {
            global $wpdb, $sitepress;
            self::get_basket();
            ICL_AdminNotifier::remove_message('the_basket_items_notification');
            /* structure of cart in get_option:
             * [posts]
             *  [element_id]
             *          [to_langs]
             *             [language_code]             fr | pl | de ... with value 1
             * [strings]
             *  [string_id]
             *          [to_langs]
             *             [language_code]
             */
            // no post selected ?
            if (empty($string_ids)) {
                self::$messages[] = array('type' => 'error', 'text' => __('Please select at least one document to translate.', 'wpml-translation-management'));
                self::update_basket();
                return false;
            }
            // no language selected ?
            if (empty($target_languages)) {
                self::$messages[] = array('type' => 'error', 'text' => __('Please select at least one language to translate into.', 'wpml-translation-management'));
                self::update_basket();
                return false;
            }
            if (self::get_basket() && self::get_source_language()) {
                /*we do not add items that are not in the source language of the current basket
                  we cannot yet set its source language though since update_basket would set the basket
                  to false oso long as we do not have any elements in the basket*/
                if ($source_language != self::get_source_language()) {
                    self::$messages[] = array('type' => 'update', 'text' => __('You cannot add strings  in this language to the basket since it already contains posts or strings of another source language!
						Either submit the current basket and then add the post or delete the posts of differing language in the current basket', 'wpml-translation-management'));
                    self::update_basket();
                    return false;
                }
            }
            foreach ($target_languages as $target_language => $selected) {
                if ($target_language == $source_language) {
                    continue;
                }
                $target_language_name = $sitepress->get_display_language_name($target_language);
                foreach ($string_ids as $id) {
                    $send_to_basket = true;
                    $query = "\tSELECT \t{$wpdb->prefix}icl_string_translations.status,\n\t\t\t\t\t\t\t\t\t\t{$wpdb->prefix}icl_strings.value\n\t\t\t\t\t\t\t\tFROM {$wpdb->prefix}icl_string_translations\n\t\t\t\t\t\t\t\tINNER JOIN {$wpdb->prefix}icl_strings\n\t\t\t\t\t\t\t\t\tON {$wpdb->prefix}icl_string_translations.string_id = {$wpdb->prefix}icl_strings.id\n\t\t\t\t\t\t\t\tWHERE {$wpdb->prefix}icl_string_translations.string_id=%d\n\t\t\t\t\t\t\t\t\tAND {$wpdb->prefix}icl_string_translations.language=%s";
                    $string_translation = $wpdb->get_row($wpdb->prepare($query, $id, $target_language));
                    if (!is_null($string_translation) && $string_translation->status == ICL_TM_WAITING_FOR_TRANSLATOR) {
                        self::$messages[] = array('type' => 'update', 'text' => sprintf(__('String "%s" will be ignored for %s, because translation is already waiting for translator.', 'wpml-translation-management'), $string_translation->value, $target_language_name));
                        $send_to_basket = false;
                    }
                    if ($send_to_basket) {
                        self::$basket['string'][$id]['from_lang'] = $source_language;
                        self::$basket['string'][$id]['to_langs'][$target_language] = 1;
                        // set basket language if not already set
                        if (!isset(self::$basket['source_language'])) {
                            self::$basket['source_language'] = $source_language;
                        }
                    }
                }
            }
            self::update_basket();
            return true;
        }
 public function build_header_content()
 {
     if (!$this->active_service) {
         $no_service_selected_information = '<p>';
         $no_service_selected_information .= '<strong>';
         $no_service_selected_information .= __('No Translation Service selected: you can only use local translators.', 'wpml-translation-management');
         $no_service_selected_information .= '</strong>';
         $no_service_selected_information .= '</p>';
         $no_service_selected_information .= '<p>';
         $no_service_selected_information .= __('If you wish to use a translation service for your content, please select one from the available services.', 'wpml-translation-management');
         $no_service_selected_information .= '</p>';
         ICL_AdminNotifier::display_instant_message($no_service_selected_information, 'information');
     }
 }
 private function automatic_service_selection()
 {
     if (defined('DOING_AJAX') || !$this->automatic_service_selection_pages()) {
         return;
     }
     $done = wp_cache_get('done', 'automatic_service_selection');
     ICL_AdminNotifier::remove_message('automatic_service_selection');
     $tp_default_suid = TranslationProxy::get_tp_default_suid();
     if (!$done && $tp_default_suid) {
         $selected_service = TranslationProxy::get_current_service();
         if (isset($selected_service->suid) && $selected_service->suid == $tp_default_suid) {
             return;
         }
         try {
             $service_by_suid = TranslationProxy_Service::get_service_by_suid($tp_default_suid);
         } catch (Exception $ex) {
             $service_by_suid = false;
         }
         if (isset($service_by_suid->id)) {
             $selected_service_id = isset($selected_service->id) ? $selected_service->id : false;
             if (!$selected_service_id || $selected_service_id != $service_by_suid->id) {
                 if ($selected_service_id) {
                     TranslationProxy::deselect_active_service();
                 }
                 $result = TranslationProxy::select_service($service_by_suid->id);
                 if (is_wp_error($result)) {
                     $error_data = $result->get_error_data();
                     $error_data_string = false;
                     foreach ($error_data as $key => $error_data_message) {
                         $error_data_string .= $result->get_error_message() . '<br/>';
                         $error_data_string .= $key . ': <pre>' . print_r($error_data_message, true) . '</pre>';
                         $error_data_string .= $result->get_error_message() . $error_data_string;
                     }
                 }
             }
         } else {
             $error_data_string = __("WPML can't find the translation service. Please contact WPML Support or your translation service provider.", 'wpml-translation-management');
         }
     }
     if (isset($error_data_string)) {
         $automatic_service_selection_args = array('id' => 'automatic_service_selection', 'group' => 'automatic_service_selection', 'msg' => $error_data_string, 'type' => 'error', 'admin_notice' => true, 'hide' => false);
         ICL_AdminNotifier::add_message($automatic_service_selection_args);
     }
     wp_cache_set('done', true, 'automatic_service_selection');
 }
Exemple #25
0
 />
		                <br/><br/>
		                <div class="icl_tm_error" id="icl_dup_ovr_warn" style="display: none">
			                <?php 
    esc_html_e('Any existing content (translations) will be overwritten when creating duplicates.', 'wpml-translation-management');
    ?>
<br/>
			                <?php 
    esc_html_e("When duplicating content, please first duplicate parent pages to maintain the site's hierarchy.", 'wpml-translation-management');
    ?>

		                </div>
	                <?php 
} else {
    $message = _('You currently have no active alternate languages!', 'wpml-translation-management');
    ICL_AdminNotifier::displayInstantMessage($message, 'error');
}
?>
                </td>
            </tr>
        </tbody>
    </table>

    </form>

    <br />
    <?php 
$ICL_Pro_Translation->get_icl_manually_tranlations_box('icl_cyan_box');
// shows only when translation polling is on and there are translations in progress
?>
    public static function display_string_menu($lang_filter)
    {
        global $sitepress;
        $target_status = array();
        $target_rate = array();
        $lang_status = $sitepress->get_setting('icl_lang_status');
        $strings_target_languages = $sitepress->get_active_languages();
        if ($lang_status) {
            foreach ($lang_status as $lang) {
                if ($lang['from'] == $sitepress->get_current_language()) {
                    $target_status[$lang['to']] = $lang['have_translators'];
                    $target_rate[$lang['to']] = $lang['max_rate'];
                }
            }
        }
        ?>
		<form method="post" id="icl_st_send_strings" name="icl_st_send_strings"
		      action="">
			<input type="hidden" name="icl_st_action" value="send_strings"/>
			<input type="hidden" name="strings" value=""/>
			<input type="hidden" name="icl-tr-from"
			       value="<?php 
        echo $lang_filter;
        ?>
"/>
			<input type="hidden" name="icl-basket-language"
			       value="<?php 
        echo TranslationProxy_Basket::get_source_language();
        ?>
"/>

			<table id="icl-tr-opt" class="widefat fixed" cellspacing="0"
			       style="width:100%">
				<thead>
				<tr>
					<th><?php 
        _e('Translation options', 'wpml-translation-management');
        ?>
</th>
				</tr>
				</thead>
				<tbody>
				<tr>
					<td>
						<ul id="icl_tm_languages">
							<?php 
        foreach ($strings_target_languages as $lang) {
            if ($lang['code'] == $lang_filter) {
                continue;
            }
            $is_active_language = $sitepress->is_active_language($lang['code']);
            $checked = checked(true, $is_active_language, false);
            $label_class = $is_active_language ? 'active' : 'non-active';
            ?>
								<li>
									<input type="checkbox"
									       id="translate_to[<?php 
            echo $lang['code'];
            ?>
]"
									       name="translate_to[<?php 
            echo $lang['code'];
            ?>
]"
									       value="1"
									       id="icl_st_translate_to_<?php 
            echo $lang['code'];
            ?>
" <?php 
            echo $checked;
            ?>
									       data-language="<?php 
            echo $lang['code'];
            ?>
"
									/>
									<label
										for="translate_to[<?php 
            echo $lang['code'];
            ?>
]"
										class="<?php 
            echo $label_class;
            ?>
">
										<?php 
            printf(__('Translate to %s', 'wpml-translation-management'), $lang['display_name']);
            ?>
									</label>
									<?php 
            if (isset($target_status[$lang['code']]) && $target_status[$lang['code']]) {
                ?>
										<span style="display: none;"
										      id="icl_st_max_rate_<?php 
                echo $lang['code'];
                ?>
"><?php 
                echo $target_rate[$lang['code']];
                ?>
</span>
										<span style="display: none;"
										      id="icl_st_estimate_<?php 
                echo $lang['code'];
                ?>
_wrap"
										      class="icl_st_estimate_wrap">
		                                    &nbsp;(<?php 
                printf(__('Estimated cost: %s USD', 'wpml-translation-management'), '<span id="icl_st_estimate_' . $lang['code'] . '">0</span>');
                ?>
											)</span>
										<?php 
            }
            ?>
								</li>
								<?php 
        }
        ?>
						</ul>
						<?php 
        echo wpml_nonce_field('icl-string-translation');
        ?>
						<input id="icl_send_strings" class="button-primary"
						       type="submit"
						       value="<?php 
        _e('Add to translation basket', 'wpml-translation-management');
        ?>
"
						       disabled="disabled"
						       data-lang-not-active-message="<?php 
        _e('One of the selected strings is in a language that is not activate. It can not be added to the translation basket.', 'wpml-translation-management');
        ?>
"
						       data-more-than-one-lang-message="<?php 
        _e('Strings in different languages are selected. They can not be added to the translation basket.', 'wpml-translation-management');
        ?>
"
						       data-translation-basket-lang-message="<?php 
        _e('You cannot add strings in this language to the basket since it already contains posts or strings of another source language! Either submit the current basket or delete the posts of differing language in the current basket', 'wpml-translation-management');
        ?>
"
						/>

						<div class="update-nag js-translation-message"
						     style="display:none"></div>

						<div style="width: 45%; margin: auto">
							<?php 
        ICL_AdminNotifier::display_messages('string-translation-under-translation-options');
        ICL_AdminNotifier::remove_message('items_added_to_basket');
        ?>
						</div>
					</td>
				</tr>
				</tbody>
			</table>
		</form>
		<?php 
    }
    /**
     * @param $translation_action
     * @param $source_language
     *
     * @return bool
     */
    private function validate_basket_package_item($translation_action, $source_language)
    {
        ICL_AdminNotifier::remove_message('the_basket_items_notification');
        $package = $this->package;
        $package_id = $package->ID;
        $basket = TranslationProxy_Basket::get_basket();
        $package_is_valid = true;
        $basket_source_language = TranslationProxy_Basket::get_source_language();
        if ($basket && $basket_source_language) {
            if ($source_language != $basket_source_language) {
                TranslationProxy_Basket::add_message(array('type' => 'update', 'text' => __('You cannot add packages in this language to the basket since it already contains posts, packages or strings of another source language!
					Either submit the current basket and then add the post or delete the posts of differing language in the current basket', 'sitepress')));
                TranslationProxy_Basket::update_basket();
                $package_is_valid = false;
            }
        }
        if (!$translation_action) {
            TranslationProxy_Basket::add_message(array('type' => 'error', 'text' => __('Please select at least one language to translate into.', 'sitepress')));
            $package_is_valid = false;
        }
        if (!$package_id) {
            TranslationProxy_Basket::add_message(array('type' => 'error', 'text' => __('Please select at least one document to translate.', 'sitepress')));
            $package_is_valid = false;
            return $package_is_valid;
        }
        return $package_is_valid;
    }
    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 
        }
    }
 /**
  * Cancel translation jobs.
  *
  * @param array $data  Request data
  */
 public function icl_tm_cancel_jobs($data)
 {
     $message = array('id' => 'icl_tm_message_cancel_jobs', 'type' => 'updated');
     if (isset($data['icl_translation_id'])) {
         $this->cancel_translation_request($data['icl_translation_id']);
         $message['text'] = __('Translation requests cancelled.', 'sitepress');
     } else {
         $message['text'] = __('No Translation requests selected.', 'sitepress');
     }
     ICL_AdminNotifier::add_message($message);
 }
 private function display_source_lang_locked_message()
 {
     if ($this->source_language_code && isset($this->active_languages[$this->source_language_code])) {
         $language_name = $this->active_languages[$this->source_language_code]['display_name'];
         $basket_locked_string = '<p>';
         $basket_locked_string .= sprintf(__('Language filtering has been disabled because you already have items in %s in the basket.', 'wpml-translation-management'), $language_name);
         $basket_locked_string .= '<br/>';
         $basket_locked_string .= __('To re-enable it, please empty the basket or send it for translation.', 'wpml-translation-management');
         $basket_locked_string .= '</p>';
         ICL_AdminNotifier::display_instant_message($basket_locked_string, 'information-inline');
     }
 }