protected function upgrade_1_0()
 {
     // the option replaces PLL_MEDIA_SUPPORT in 1.0
     $this->options['media_support'] = defined('PLL_MEDIA_SUPPORT') && !PLL_MEDIA_SUPPORT ? 0 : 1;
     // split the synchronization options in 1.0
     $this->options['sync'] = empty($this->options['sync']) ? array() : array_keys(PLL_Settings::list_metas_to_sync());
     // set default values for post types and taxonomies to translate
     $this->options['post_types'] = array_values(get_post_types(array('_builtin' => false, 'show_ui => true')));
     $this->options['taxonomies'] = array_values(get_taxonomies(array('_builtin' => false, 'show_ui => true')));
     update_option('polylang', $this->options);
     flush_rewrite_rules();
     // rewrite rules have been modified in 1.0
 }
 /**
  * Saves the strings translations in DB
  * Optionaly clean the DB
  *
  * @since 1.9
  */
 public function save_translations()
 {
     check_admin_referer('string-translation', '_wpnonce_string-translation');
     if (!empty($_POST['submit'])) {
         foreach ($this->languages 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) {
                 /**
                  * Filter the string translation before it is saved in DB
                  * Allows to sanitize strings registered with pll_register_string
                  *
                  * @since 1.6
                  *
                  * @param string $translation the string translation
                  * @param string $name        the name as defined in pll_register_string
                  * @param string $context     the context as defined in pll_register_string
                  */
                 $translation = apply_filters('pll_sanitize_string_translation', $translation, $this->strings[$key]['name'], $this->strings[$key]['context']);
                 $mo->add_entry($mo->make_entry($this->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 ($this->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');
         /**
          * Fires after the strings translations are saved in DB
          *
          * @since 1.2
          */
         do_action('pll_save_strings_translations');
     }
     // Unregisters strings registered through WPML API
     if ($this->current_action() === 'delete' && !empty($_POST['strings']) && function_exists('icl_unregister_string')) {
         foreach ($_POST['strings'] as $key) {
             icl_unregister_string($this->strings[$key]['context'], $this->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($_GET['paged']) && !empty($_POST['submit'])) {
         $args['paged'] = (int) $_GET['paged'];
         // Don't rely on $_REQUEST['paged'] or $_POST['paged']. See #14
     }
     if (!empty($args['s'])) {
         $args['s'] = urlencode($args['s']);
         // Searched string needs to be encoded as it comes from $_POST
     }
     PLL_Settings::redirect($args);
 }