Example #1
0
 public function languages_page()
 {
     // prepare the list of tabs
     $tabs = array('lang' => __('Languages', 'polylang'));
     // only if at least one language has been created
     if ($listlanguages = $this->model->get_languages_list()) {
         $tabs['strings'] = __('Strings translation', 'polylang');
         $tabs['settings'] = __('Settings', 'polylang');
     }
     // allows plugins to add tabs
     $tabs = apply_filters('pll_settings_tabs', $tabs);
     switch ($this->active_tab) {
         case 'lang':
             // prepare the list table of languages
             $list_table = new PLL_Table_Languages();
             $list_table->prepare_items($listlanguages);
             break;
         case 'strings':
             // get the strings to translate
             $data = PLL_Admin_Strings::get_strings();
             // get the groups
             foreach ($data as $key => $row) {
                 $groups[] = $row['context'];
             }
             $groups = array_unique($groups);
             $selected = empty($_GET['group']) || !in_array($_GET['group'], $groups) ? -1 : $_GET['group'];
             $s = empty($_GET['s']) ? '' : wp_unslash($_GET['s']);
             // filter for search string
             foreach ($data as $key => $row) {
                 if (-1 != $selected && $row['context'] != $selected || !empty($s) && stripos($row['name'], $s) === false && stripos($row['string'], $s) === false) {
                     unset($data[$key]);
                 }
             }
             // load translations
             foreach ($listlanguages as $language) {
                 // filters by language if requested
                 if (($lg = get_user_meta(get_current_user_id(), 'pll_filter_content', true)) && $language->slug != $lg) {
                     continue;
                 }
                 $mo = new PLL_MO();
                 $mo->import_from_db($language);
                 foreach ($data as $key => $row) {
                     $data[$key]['translations'][$language->slug] = $mo->translate($row['string']);
                     $data[$key]['row'] = $key;
                     // store the row number for convenience
                 }
             }
             // get an array with language slugs as keys, names as values
             $languages = array_combine(wp_list_pluck($listlanguages, 'slug'), wp_list_pluck($listlanguages, 'name'));
             $string_table = new PLL_Table_String(compact('languages', 'groups', 'selected'));
             $string_table->prepare_items($data);
             break;
         case 'settings':
             $post_types = get_post_types(array('public' => true, '_builtin' => false));
             $post_types = array_diff($post_types, get_post_types(array('_pll' => true)));
             $post_types = array_unique(apply_filters('pll_get_post_types', $post_types, true));
             $taxonomies = get_taxonomies(array('public' => true, '_builtin' => false));
             $taxonomies = array_diff($taxonomies, get_taxonomies(array('_pll' => true)));
             $taxonomies = array_unique(apply_filters('pll_get_taxonomies', $taxonomies, true));
             break;
     }
     $action = isset($_REQUEST['pll_action']) ? $_REQUEST['pll_action'] : '';
     switch ($action) {
         case 'add':
             check_admin_referer('add-lang', '_wpnonce_add-lang');
             if ($this->model->add_language($_POST) && 'en_US' != $_POST['locale']) {
                 // attempts to install the language pack
                 require_once ABSPATH . 'wp-admin/includes/translation-install.php';
                 if (!wp_download_language_pack($_POST['locale'])) {
                     add_settings_error('general', 'pll_download_mo', __('The language was created, but the WordPress language file was not downloaded. Please install it manually.', 'polylang'));
                 }
                 // force checking for themes and plugins translations updates
                 wp_clean_themes_cache();
                 wp_clean_plugins_cache();
             }
             self::redirect();
             // to refresh the page ( possible thanks to the $_GET['noheader']=true )
             break;
         case 'delete':
             check_admin_referer('delete-lang');
             if (!empty($_GET['lang'])) {
                 $this->model->delete_language((int) $_GET['lang']);
             }
             self::redirect();
             // to refresh the page ( possible thanks to the $_GET['noheader']=true )
             break;
         case 'edit':
             if (!empty($_GET['lang'])) {
                 $edit_lang = $this->model->get_language((int) $_GET['lang']);
             }
             break;
         case 'update':
             check_admin_referer('add-lang', '_wpnonce_add-lang');
             $error = $this->model->update_language($_POST);
             self::redirect();
             // to refresh the page ( possible thanks to the $_GET['noheader']=true )
             break;
         case 'default-lang':
             check_admin_referer('default-lang');
             if ($lang = $this->model->get_language((int) $_GET['lang'])) {
                 $this->model->update_default_lang($lang->slug);
             }
             self::redirect();
             // to refresh the page ( possible thanks to the $_GET['noheader']=true )
             break;
         case 'content-default-lang':
             check_admin_referer('content-default-lang');
             if ($nolang = $this->model->get_objects_with_no_lang()) {
                 if (!empty($nolang['posts'])) {
                     $this->model->set_language_in_mass('post', $nolang['posts'], $this->options['default_lang']);
                 }
                 if (!empty($nolang['terms'])) {
                     $this->model->set_language_in_mass('term', $nolang['terms'], $this->options['default_lang']);
                 }
             }
             self::redirect();
             // to refresh the page ( possible thanks to the $_GET['noheader']=true )
             break;
         case 'string-translation':
             if (!empty($_POST['submit'])) {
                 check_admin_referer('string-translation', '_wpnonce_string-translation');
                 $strings = PLL_Admin_Strings::get_strings();
                 foreach ($this->model->get_languages_list() as $language) {
                     if (empty($_POST['translation'][$language->slug])) {
                         // in case the language filter is active ( thanks to John P. Bloch )
                         continue;
                     }
                     $mo = new PLL_MO();
                     $mo->import_from_db($language);
                     foreach ($_POST['translation'][$language->slug] as $key => $translation) {
                         $translation = apply_filters('pll_sanitize_string_translation', $translation, $strings[$key]['name'], $strings[$key]['context']);
                         $mo->add_entry($mo->make_entry($strings[$key]['string'], $translation));
                     }
                     // clean database ( removes all strings which were registered some day but are no more )
                     if (!empty($_POST['clean'])) {
                         $new_mo = new PLL_MO();
                         foreach ($strings as $string) {
                             $new_mo->add_entry($mo->make_entry($string['string'], $mo->translate($string['string'])));
                         }
                     }
                     isset($new_mo) ? $new_mo->export_to_db($language) : $mo->export_to_db($language);
                 }
                 add_settings_error('general', 'pll_strings_translations_updated', __('Translations updated.', 'polylang'), 'updated');
                 do_action('pll_save_strings_translations');
             }
             // unregisters strings registered through WPML API
             if ($string_table->current_action() == 'delete' && !empty($_POST['strings']) && function_exists('icl_unregister_string')) {
                 check_admin_referer('string-translation', '_wpnonce_string-translation');
                 $strings = PLL_Admin_Strings::get_strings();
                 foreach ($_POST['strings'] as $key) {
                     icl_unregister_string($strings[$key]['context'], $strings[$key]['name']);
                 }
             }
             // to refresh the page ( possible thanks to the $_GET['noheader']=true )
             $args = array_intersect_key($_REQUEST, array_flip(array('s', 'paged', 'group')));
             if (!empty($args['s'])) {
                 $args['s'] = urlencode($args['s']);
                 // searched string needs to be encoded as it comes from $_POST
             }
             self::redirect($args);
             break;
         case 'activate':
             check_admin_referer('pll_activate');
             $this->modules[$_GET['module']]->activate();
             self::redirect();
             break;
         case 'deactivate':
             check_admin_referer('pll_deactivate');
             $this->modules[$_GET['module']]->deactivate();
             self::redirect();
             break;
         default:
             do_action("mlang_action_{$action}");
             break;
     }
     // displays the page
     include PLL_SETTINGS_INC . '/view-languages.php';
 }
Example #2
0
 public function languages_page()
 {
     // prepare the list of tabs
     $tabs = array('lang' => __('Languages', 'polylang'));
     // only if at least one language has been created
     if ($listlanguages = $this->model->get_languages_list()) {
         $tabs['strings'] = __('Strings translation', 'polylang');
         $tabs['settings'] = __('Settings', 'polylang');
     }
     $tabs = apply_filters('pll_settings_tabs', $tabs);
     switch ($this->active_tab) {
         case 'lang':
             // prepare the list table of languages
             $list_table = new PLL_Table_Languages();
             $list_table->prepare_items($listlanguages);
             break;
         case 'strings':
             // get the strings to translate
             $data = PLL_Admin_Strings::get_strings();
             // get the groups
             foreach ($data as $key => $row) {
                 $groups[] = $row['context'];
             }
             $groups = array_unique($groups);
             $selected = empty($_REQUEST['group']) || !in_array($_REQUEST['group'], $groups) ? -1 : $_REQUEST['group'];
             $s = empty($_REQUEST['s']) ? '' : wp_unslash($_REQUEST['s']);
             // filter for search string
             foreach ($data as $key => $row) {
                 if ($selected != -1 && $row['context'] != $selected || !empty($s) && stripos($row['name'], $s) === false && stripos($row['string'], $s) === false) {
                     unset($data[$key]);
                 }
             }
             // load translations
             foreach ($listlanguages as $language) {
                 // filters by language if requested
                 if (($lg = get_user_meta(get_current_user_id(), 'pll_filter_content', true)) && $language->slug != $lg) {
                     continue;
                 }
                 $mo = new PLL_MO();
                 // print_r($language);
                 $mo->import_from_db($language);
                 foreach ($data as $key => $row) {
                     $data[$key]['translations'][$language->slug] = $mo->translate($row['string']);
                     $data[$key]['row'] = $key;
                     // store the row number for convenience
                 }
             }
             // get an array with language slugs as keys, names as values
             $languages = array_combine(wp_list_pluck($listlanguages, 'slug'), wp_list_pluck($listlanguages, 'name'));
             $string_table = new PLL_Table_String(compact('languages', 'groups', 'selected'));
             $string_table->prepare_items($data);
             break;
         case 'settings':
             $post_types = get_post_types(array('public' => true, '_builtin' => false));
             $post_types = array_diff($post_types, get_post_types(array('_pll' => true)));
             $post_types = array_unique(apply_filters('pll_get_post_types', $post_types, true));
             $taxonomies = get_taxonomies(array('public' => true, '_builtin' => false));
             $taxonomies = array_diff($taxonomies, get_taxonomies(array('_pll' => true)));
             $taxonomies = array_unique(apply_filters('pll_get_taxonomies', $taxonomies, true));
             break;
         default:
             break;
     }
     $action = isset($_REQUEST['pll_action']) ? $_REQUEST['pll_action'] : '';
     switch ($action) {
         case 'add':
             check_admin_referer('add-lang', '_wpnonce_add-lang');
             if ($this->model->add_language($_POST)) {
                 // backward compatibility WP < 4.0
                 if (version_compare($GLOBALS['wp_version'], '4.0', '<')) {
                     PLL_Admin::download_mo($_POST['locale']);
                 } elseif ('en_US' != $_POST['locale']) {
                     // attempts to install the language pack
                     require_once ABSPATH . 'wp-admin/includes/translation-install.php';
                     if (!wp_download_language_pack($_POST['locale'])) {
                         add_settings_error('general', 'pll_download_mo', __('The language was created, but the WordPress language file was not downloaded. Please install it manually.', 'polylang'));
                     }
                     // force checking for themes and plugins translations updates
                     wp_update_themes();
                     wp_update_plugins();
                 }
             }
             $this->redirect();
             // to refresh the page (possible thanks to the $_GET['noheader']=true)
             break;
         case 'delete':
             check_admin_referer('delete-lang');
             if (!empty($_GET['lang'])) {
                 $this->model->delete_language((int) $_GET['lang']);
             }
             $this->redirect();
             // to refresh the page (possible thanks to the $_GET['noheader']=true)
             break;
         case 'edit':
             if (!empty($_GET['lang'])) {
                 $edit_lang = $this->model->get_language((int) $_GET['lang']);
             }
             break;
         case 'update':
             check_admin_referer('add-lang', '_wpnonce_add-lang');
             $error = $this->model->update_language($_POST);
             $this->redirect();
             // to refresh the page (possible thanks to the $_GET['noheader']=true)
             break;
         case 'string-translation':
             if (!empty($_REQUEST['submit'])) {
                 check_admin_referer('string-translation', '_wpnonce_string-translation');
                 $strings = PLL_Admin_Strings::get_strings();
                 foreach ($this->model->get_languages_list() as $language) {
                     if (empty($_POST['translation'][$language->slug])) {
                         // in case the language filter is active (thanks to John P. Bloch)
                         continue;
                     }
                     $mo = new PLL_MO();
                     $mo->import_from_db($language);
                     foreach ($_POST['translation'][$language->slug] as $key => $translation) {
                         $translation = apply_filters('pll_sanitize_string_translation', $translation, $strings[$key]['name'], $strings[$key]['context']);
                         $mo->add_entry($mo->make_entry($strings[$key]['string'], $translation));
                     }
                     // clean database (removes all strings which were registered some day but are no more)
                     if (!empty($_POST['clean'])) {
                         $new_mo = new PLL_MO();
                         foreach ($strings as $string) {
                             $new_mo->add_entry($mo->make_entry($string['string'], $mo->translate($string['string'])));
                         }
                     }
                     isset($new_mo) ? $new_mo->export_to_db($language) : $mo->export_to_db($language);
                 }
                 add_settings_error('general', 'pll_strings_translations_updated', __('Translations updated.', 'polylang'), 'updated');
             }
             do_action('pll_save_strings_translations');
             // unregisters strings registered through WPML API
             if ($string_table->current_action() == 'delete' && !empty($_REQUEST['strings']) && function_exists('icl_unregister_string')) {
                 check_admin_referer('string-translation', '_wpnonce_string-translation');
                 $strings = PLL_Admin_Strings::get_strings();
                 foreach ($_REQUEST['strings'] as $key) {
                     icl_unregister_string($strings[$key]['context'], $strings[$key]['name']);
                 }
             }
             // to refresh the page (possible thanks to the $_GET['noheader']=true)
             $this->redirect(array_intersect_key($_REQUEST, array_flip(array('s', 'paged', 'group'))));
             break;
         case 'options':
             check_admin_referer('options-lang', '_wpnonce_options-lang');
             $this->options['default_lang'] = sanitize_title($_POST['default_lang']);
             // we have slug as value
             foreach (array('force_lang', 'rewrite') as $key) {
                 $this->options[$key] = isset($_POST[$key]) ? (int) $_POST[$key] : 0;
             }
             if (3 == $this->options['force_lang'] && isset($_POST['domains']) && is_array($_POST['domains'])) {
                 foreach ($_POST['domains'] as $key => $domain) {
                     $this->options['domains'][$key] = esc_url_raw(trim($domain));
                 }
             }
             foreach (array('browser', 'hide_default', 'redirect_lang', 'media_support') as $key) {
                 $this->options[$key] = isset($_POST[$key]) ? 1 : 0;
             }
             if (3 == $this->options['force_lang']) {
                 $this->options['browser'] = $this->options['hide_default'] = 0;
             }
             foreach (array('sync', 'post_types', 'taxonomies') as $key) {
                 $this->options[$key] = empty($_POST[$key]) ? array() : array_keys($_POST[$key], 1);
             }
             update_option('polylang', $this->options);
             // refresh rewrite rules in case rewrite,  hide_default, post types or taxonomies options have been modified
             // it seems useless to refresh permastruct here
             flush_rewrite_rules();
             // refresh language cache in case home urls have been modified
             $this->model->clean_languages_cache();
             // fills existing posts & terms with default language
             if (isset($_POST['fill_languages']) && ($nolang = $this->model->get_objects_with_no_lang())) {
                 if (!empty($nolang['posts'])) {
                     $this->model->set_language_in_mass('post', $nolang['posts'], $this->options['default_lang']);
                 }
                 if (!empty($nolang['terms'])) {
                     $this->model->set_language_in_mass('term', $nolang['terms'], $this->options['default_lang']);
                 }
             }
             add_settings_error('general', 'settings_updated', __('Settings saved.'), 'updated');
             $this->redirect();
             break;
         default:
             break;
     }
     // displays the page
     include PLL_ADMIN_INC . '/view-languages.php';
 }
Example #3
0
 /**
  * Displays the 3 tabs pages: languages, strings translations, settings
  * also manages user input for these pages
  *
  * @since 0.1
  */
 public function languages_page()
 {
     switch ($this->active_tab) {
         case 'lang':
             // prepare the list table of languages
             $list_table = new PLL_Table_Languages();
             $list_table->prepare_items($this->model->get_languages_list());
             break;
         case 'strings':
             $string_table = new PLL_Table_String($this->model->get_languages_list());
             $string_table->prepare_items();
             break;
     }
     // handle user input
     $action = isset($_REQUEST['pll_action']) ? $_REQUEST['pll_action'] : '';
     if ('edit' === $action && !empty($_GET['lang'])) {
         $edit_lang = $this->model->get_language((int) $_GET['lang']);
     } else {
         $this->handle_actions($action);
     }
     // displays the page
     include PLL_SETTINGS_INC . '/view-languages.php';
 }
Example #4
0
 /**
  * Displays the 3 tabs pages: languages, strings translations, settings
  * also manages user input for these pages
  *
  * @since 0.1
  */
 public function languages_page()
 {
     // prepare the list of tabs
     $tabs = array('lang' => __('Languages', 'polylang'));
     // only if at least one language has been created
     if ($listlanguages = $this->model->get_languages_list()) {
         $tabs['strings'] = __('Strings translations', 'polylang');
     }
     $tabs['settings'] = __('Settings', 'polylang');
     /**
      * Filter the list of tabs in Polylang settings
      *
      * @since 1.5.1
      *
      * @param array $tabs list of tab names
      */
     $tabs = apply_filters('pll_settings_tabs', $tabs);
     switch ($this->active_tab) {
         case 'lang':
             // prepare the list table of languages
             $list_table = new PLL_Table_Languages();
             $list_table->prepare_items($listlanguages);
             break;
         case 'strings':
             $string_table = new PLL_Table_String($listlanguages);
             $string_table->prepare_items();
             break;
     }
     // handle user input
     $action = isset($_REQUEST['pll_action']) ? $_REQUEST['pll_action'] : '';
     if ('edit' === $action && !empty($_GET['lang'])) {
         $edit_lang = $this->model->get_language((int) $_GET['lang']);
     } else {
         $this->handle_actions($action);
     }
     // displays the page
     include PLL_SETTINGS_INC . '/view-languages.php';
 }
Example #5
0
 public function languages_page()
 {
     // prepare the list of tabs
     $tabs = array('lang' => __('Languages', 'polylang'));
     // only if at least one language has been created
     if ($listlanguages = $this->model->get_languages_list()) {
         $tabs['strings'] = __('Strings translation', 'polylang');
         $tabs['settings'] = __('Settings', 'polylang');
     }
     $active_tab = !empty($_GET['tab']) ? $_GET['tab'] : 'lang';
     switch ($active_tab) {
         case 'lang':
             // prepare the list table of languages
             $list_table = new PLL_Table_Languages();
             $list_table->prepare_items($listlanguages);
             // error messages for data validation
             $errors[1] = __('Enter a valid WordPress locale', 'polylang');
             $errors[2] = __('The language code contains invalid characters', 'polylang');
             $errors[3] = __('The language code must be unique', 'polylang');
             $errors[4] = __('The language must have a name', 'polylang');
             $errors[5] = __('The language was created, but the WordPress language file was not downloaded. Please install it manually.', 'polylang');
             break;
         case 'strings':
             // get the strings to translate
             $data = $this->get_strings();
             $selected = empty($_REQUEST['group']) ? -1 : $_REQUEST['group'];
             foreach ($data as $key => $row) {
                 $groups[] = $row['context'];
                 // get the groups
                 // filter for search string
                 if ($selected != -1 && $row['context'] != $selected || !empty($_REQUEST['s']) && stripos($row['name'], $_REQUEST['s']) === false && stripos($row['string'], $_REQUEST['s']) === false) {
                     unset($data[$key]);
                 }
             }
             $groups = array_unique($groups);
             // load translations
             foreach ($listlanguages as $language) {
                 // filters by language if requested
                 if (($lg = get_user_meta(get_current_user_id(), 'pll_filter_content', true)) && $language->slug != $lg) {
                     continue;
                 }
                 $mo = new PLL_MO();
                 $mo->import_from_db($language);
                 foreach ($data as $key => $row) {
                     $data[$key]['translations'][$language->name] = $mo->translate($row['string']);
                     $data[$key]['row'] = $key;
                     // store the row number for convenience
                 }
             }
             $string_table = new PLL_Table_String($groups, $selected);
             $string_table->prepare_items($data);
             break;
         case 'settings':
             $post_types = get_post_types(array('public' => true, '_builtin' => false));
             $post_types = array_diff($post_types, get_post_types(array('_pll' => true)));
             $post_types = array_unique(apply_filters('pll_get_post_types', $post_types, true));
             $taxonomies = get_taxonomies(array('public' => true, '_builtin' => false));
             $taxonomies = array_diff($taxonomies, get_taxonomies(array('_pll' => true)));
             $taxonomies = array_unique(apply_filters('pll_get_taxonomies', $taxonomies, true));
             break;
         default:
             break;
     }
     $using_permalinks = $GLOBALS['wp_rewrite']->using_permalinks();
     $action = isset($_REQUEST['pll_action']) ? $_REQUEST['pll_action'] : '';
     switch ($action) {
         case 'add':
             check_admin_referer('add-lang', '_wpnonce_add-lang');
             $error = $this->model->add_language($_POST);
             if (0 == $error && !PLL_Admin::download_mo($_POST['locale'])) {
                 $error = 5;
             }
             wp_redirect('admin.php?page=mlang' . ($error ? '&error=' . $error : ''));
             // to refresh the page (possible thanks to the $_GET['noheader']=true)
             exit;
             break;
         case 'delete':
             check_admin_referer('delete-lang');
             if (!empty($_GET['lang'])) {
                 $this->model->delete_language((int) $_GET['lang']);
             }
             wp_redirect('admin.php?page=mlang');
             // to refresh the page (possible thanks to the $_GET['noheader']=true)
             exit;
             break;
         case 'edit':
             if (!empty($_GET['lang'])) {
                 $edit_lang = $this->model->get_language((int) $_GET['lang']);
             }
             break;
         case 'update':
             check_admin_referer('add-lang', '_wpnonce_add-lang');
             $error = $this->model->update_language($_POST);
             wp_redirect('admin.php?page=mlang' . ($error ? '&error=' . $error : ''));
             // to refresh the page (possible thanks to the $_GET['noheader']=true)
             exit;
             break;
         case 'string-translation':
             if (!empty($_REQUEST['submit'])) {
                 check_admin_referer('string-translation', '_wpnonce_string-translation');
                 $strings = $this->get_strings();
                 foreach ($this->model->get_languages_list() as $language) {
                     if (empty($_POST['translation'][$language->name])) {
                         // in case the language filter is active (thanks to John P. Bloch)
                         continue;
                     }
                     $mo = new PLL_MO();
                     $mo->import_from_db($language);
                     foreach ($_POST['translation'][$language->name] as $key => $translation) {
                         $mo->add_entry($mo->make_entry($strings[$key]['string'], stripslashes($translation)));
                     }
                     // clean database (removes all strings which were registered some day but are no more)
                     if (!empty($_POST['clean'])) {
                         $new_mo = new PLL_MO();
                         foreach ($strings as $string) {
                             $new_mo->add_entry($mo->make_entry($string['string'], $mo->translate($string['string'])));
                         }
                     }
                     isset($new_mo) ? $new_mo->export_to_db($language) : $mo->export_to_db($language);
                 }
             }
             do_action('pll_save_strings_translations');
             // unregisters strings registered through WPML API
             if ($string_table->current_action() == 'delete' && !empty($_REQUEST['strings']) && function_exists('icl_unregister_string')) {
                 check_admin_referer('string-translation', '_wpnonce_string-translation');
                 $strings = $this->get_strings();
                 foreach ($_REQUEST['strings'] as $key) {
                     icl_unregister_string($strings[$key]['context'], $strings[$key]['name']);
                 }
             }
             // to refresh the page (possible thanks to the $_GET['noheader']=true)
             $url = 'admin.php?page=mlang&tab=strings';
             foreach (array('s', 'paged', 'group') as $qv) {
                 $url = empty($_REQUEST[$qv]) ? $url : $url . '&' . $qv . '=' . $_REQUEST[$qv];
             }
             wp_redirect($url);
             exit;
             break;
         case 'options':
             check_admin_referer('options-lang', '_wpnonce_options-lang');
             $this->options['default_lang'] = sanitize_title($_POST['default_lang']);
             // we have slug as value
             foreach (array('force_lang', 'rewrite') as $key) {
                 $this->options[$key] = isset($_POST[$key]) ? (int) $_POST[$key] : 0;
             }
             // FIXME : TODO error message if not a valid url
             if (3 == $this->options['force_lang'] && isset($_POST['domains']) && is_array($_POST['domains'])) {
                 foreach ($_POST['domains'] as $key => $domain) {
                     $this->options['domains'][$key] = esc_url_raw(trim($domain));
                 }
                 $this->options['domains'][$this->options['default_lang']] = get_option('home');
             }
             foreach (array('browser', 'hide_default', 'redirect_lang', 'media_support') as $key) {
                 $this->options[$key] = isset($_POST[$key]) ? 1 : 0;
             }
             if (3 == $this->options['force_lang']) {
                 $this->options['browser'] = $this->options['hide_default'] = 0;
             }
             foreach (array('sync', 'post_types', 'taxonomies') as $key) {
                 $this->options[$key] = empty($_POST[$key]) ? array() : array_keys($_POST[$key], 1);
             }
             update_option('polylang', $this->options);
             // refresh rewrite rules in case rewrite,  hide_default, post types or taxonomies options have been modified
             // it seems useless to refresh permastruct here
             flush_rewrite_rules();
             // refresh language cache in case home urls have been modified
             $this->model->clean_languages_cache();
             // fills existing posts & terms with default language
             if (isset($_POST['fill_languages']) && ($nolang = $this->model->get_objects_with_no_lang())) {
                 if (!empty($nolang['posts'])) {
                     $this->model->set_language_in_mass('post', $nolang['posts'], $this->options['default_lang']);
                 }
                 if (!empty($nolang['terms'])) {
                     $this->model->set_language_in_mass('term', $nolang['terms'], $this->options['default_lang']);
                 }
             }
             wp_redirect('admin.php?page=mlang&tab=settings&updated=true');
             // updated=true interpreted by WP
             exit;
             break;
         default:
             break;
     }
     // displays the page
     include PLL_ADMIN_INC . '/view-languages.php';
 }