/** * Renders the Settings/Media Library Assistant "Language" tab * * @since 2.11 * * @return array ( 'message' => '', 'body' => '' ) */ public static function mla_render_language_tab() { $page_content = array('message' => '', 'body' => '<h2>' . __('Language', 'media-library-assistant') . '</h2>'); /* * Check for submit buttons to change or reset settings. * Initialize page messages and content. */ if (!empty($_REQUEST['mla-language-options-save'])) { check_admin_referer(MLACore::MLA_ADMIN_NONCE_ACTION, MLACore::MLA_ADMIN_NONCE_NAME); $page_content = self::_save_language_settings(); } elseif (!empty($_REQUEST['mla-language-options-reset'])) { check_admin_referer(MLACore::MLA_ADMIN_NONCE_ACTION, MLACore::MLA_ADMIN_NONCE_NAME); $page_content = self::_reset_language_settings(); } else { $page_content = array('message' => '', 'body' => ''); } if (!empty($page_content['body'])) { return $page_content; } /* * Find WPML Media plugin status */ $installed = false; $active = false; $wpml_media = SitePress::get_installed_plugins(); if (isset($wpml_media['WPML Media'])) { $wpml_media = $wpml_media['WPML Media']; if (!empty($wpml_media['plugin'])) { $installed = true; $active = isset($wpml_media['file']) && is_plugin_active($wpml_media['file']); } } $wpml_media = ''; if (!$installed) { $wpml_media = '<p><strong>' . __('WARNING:', 'media-library-assistant') . __(' WPML Media is not installed.', 'media-library-assistant') . '</strong></p>'; } elseif (!$active) { $wpml_media = '<p><strong>' . __('WARNING:', 'media-library-assistant') . __(' WPML Media is not active.', 'media-library-assistant') . '</strong></p>'; } $page_values = array('Language Options' => __('Language Options', 'media-library-assistant'), 'In this tab' => sprintf(__('In this tab you can find a number of options for controlling WPML-specific operations. Scroll down to find options for %1$s and %2$s. Be sure to click "Save Changes" at the bottom of the tab to save any changes you make.', 'media-library-assistant'), '<strong>' . __('Media/Assistant submenu table', 'media-library-assistant') . '</strong>', '<strong>' . __('Term Management', 'media-library-assistant') . '</strong>'), 'You can find' => sprintf(__('You can find more information about multilingual features in the %1$s section of the Documentation.', 'media-library-assistant'), '<a href="[+settingsURL+]?page=mla-settings-menu-documentation&mla_tab=documentation#mla_language_tab" title="' . __('Language Options documentation', 'media-library-assistant') . '">' . __('WPML & Polylang Multilingual Support; the MLA Language Tab', 'media-library-assistant') . '</a>'), 'WPML Status' => $wpml_media, 'settingsURL' => admin_url('options-general.php'), 'Save Changes' => __('Save Changes', 'media-library-assistant'), 'Delete Language options' => __('Delete Language options and restore default settings', 'media-library-assistant'), '_wpnonce' => wp_nonce_field(MLACore::MLA_ADMIN_NONCE_ACTION, MLACore::MLA_ADMIN_NONCE_NAME, true, false), '_wp_http_referer' => wp_referer_field(false), 'Go to Top' => __('Go to Top', 'media-library-assistant'), 'form_url' => admin_url('options-general.php') . '?page=mla-settings-menu-language&mla_tab=language', 'options_list' => ''); $options_list = ''; foreach (MLA_WPML::$mla_language_option_definitions as $key => $value) { if ('language' == $value['tab']) { $options_list .= MLASettings::mla_compose_option_row($key, $value, MLA_WPML::$mla_language_option_definitions); } } $page_values['options_list'] = $options_list; $page_template = MLACore::mla_load_template('admin-display-language-tab.tpl'); $page_content['body'] = MLAData::mla_parse_template($page_template, $page_values); return $page_content; }
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 .= ' '; $message .= ' '; $message .= ' '; $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; }
<div class="wrap"> <div id="icon-wpml" class="icon32" style="clear:both" ><br /></div> <h2><?php _e('Support', 'sitepress'); ?> </h2> <p style="margin-top: 20px;"> <?php _e('Technical support for clients is available via <a target="_blank" href="https://wpml.org/forums/">WPML forums</a>.', 'sitepress'); ?> </p> <?php $wpml_plugins_list = SitePress::get_installed_plugins(); echo ' <table class="widefat" style="width: auto;"> <thead> <tr> <th>' . __('Plugin Name', 'sitepress') . '</th> <th style="text-align:right">' . __('Status', 'sitepress') . '</th> <th>' . __('Active', 'sitepress') . '</th> <th>' . __('Version', 'sitepress') . '</th> </tr> </thead> <tbody> '; foreach ($wpml_plugins_list as $name => $plugin_data) { $plugin_name = $name; $file = $plugin_data['file'];