Пример #1
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;
        }
    }
}
Пример #2
0
 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;
 }
Пример #3
0
 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');
 }
function cpt_warnings()
{
    if (!defined('WPML_ST_PATH')) {
        return;
    }
    global $sitepress_settings;
    ICL_AdminNotifier::removeMessage('cpt_default_and_st_language_warning');
    if ($sitepress_settings['st']['strings_language'] != 'en') {
        cpt_default_and_st_language_warning();
    }
}
 /**
  * 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;
            }
        }
    }
 /**
  * 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);
 }