public function verify($options)
 {
     global $mymail;
     if (isset($_POST['mymail_generate_dkim_keys'])) {
         try {
             $res = openssl_pkey_new(array('private_key_bits' => isset($options['dkim_bitsize']) ? (int) $options['dkim_bitsize'] : 512));
             openssl_pkey_export($res, $dkim_private_key);
             $dkim_public_key = openssl_pkey_get_details($res);
             $dkim_public_key = $dkim_public_key["key"];
             $options['dkim_public_key'] = $dkim_public_key;
             $options['dkim_private_key'] = $dkim_private_key;
             add_settings_error('mymail_options', 'mymail_options', __('New DKIM keys have been created!', 'mymail'), 'updated');
         } catch (Exception $e) {
             add_settings_error('mymail_options', 'mymail_options', __('Not able to create new DKIM keys!', 'mymail'));
         }
     }
     if (!empty($_FILES['country_db_file']['name'])) {
         $file = $_FILES['country_db_file'];
         $dest = MYMAIL_UPLOAD_DIR . '/' . $file['name'];
         if (move_uploaded_file($file['tmp_name'], $dest)) {
             if (is_file($dest)) {
                 $options['countries_db'] = $dest;
                 add_settings_error('mymail_options', 'mymail_options', sprintf(__('File uploaded to %s', 'mymail'), '"' . $dest . '"'), 'updated');
             } else {
                 $options['countries_db'] = '';
             }
         } else {
             add_settings_error('mymail_options', 'mymail_options', __('unable to upload file', 'mymail'));
             $options['countries_db'] = '';
         }
     }
     if (!empty($_FILES['city_db_file']['name'])) {
         $file = $_FILES['city_db_file'];
         $dest = MYMAIL_UPLOAD_DIR . '/' . $file['name'];
         if (move_uploaded_file($file['tmp_name'], $dest)) {
             if (is_file($dest)) {
                 $options['cities_db'] = $dest;
                 add_settings_error('mymail_options', 'mymail_options', sprintf(__('File uploaded to %s', 'mymail'), '"' . $dest . '"'), 'updated');
             } else {
                 $options['cities_db'] = '';
             }
         } else {
             add_settings_error('mymail_options', 'mymail_options', __('unable to upload file', 'mymail'));
             $options['cities_db'] = '';
         }
     }
     $verify = array('from', 'reply_to', 'homepage', 'trackcountries', 'trackcities', 'vcard_content', 'custom_field', 'forms', 'form_css', 'send_period', 'bounce', 'cron_service', 'cron_secret', 'interval', 'roles', 'tweet_cache_time', 'deliverymethod', 'dkim_domain', 'dkim_selector', 'dkim_identity', 'dkim_passphrase', 'dkim_private_key', 'purchasecode');
     if (isset($_POST['mymail_import_settings']) && $_POST['mymail_import_settings']) {
         $settings = unserialize(base64_decode($_POST['mymail_import_settings']));
         $options = wp_parse_args($settings, $options);
     }
     foreach ($verify as $id) {
         if (!isset($options[$id])) {
             continue;
         }
         $value = $options[$id];
         $old = mymail_option($id);
         switch ($id) {
             case 'from':
             case 'reply_to':
             case 'bounce':
                 if ($value && !mymail_is_email($value)) {
                     add_settings_error('mymail_options', 'mymail_options', sprintf(__('%s is not a valid email address', 'mymail'), '"' . $value . '"'));
                     $value = $old;
                 }
                 break;
             case 'trackcountries':
                 if (!$options['countries_db'] || !is_file($options['countries_db'])) {
                     add_settings_error('mymail_options', 'mymail_options', __('No country database found! Please load it!', 'mymail'));
                     $value = false;
                 }
                 break;
             case 'trackcities':
                 if (!$options['cities_db'] || !is_file($options['cities_db'])) {
                     add_settings_error('mymail_options', 'mymail_options', __('No city database found! Please load it!', 'mymail'));
                     $value = false;
                 }
                 break;
             case 'homepage':
                 if ($old != $value) {
                     mymail_remove_notice('no-homepage');
                 }
                 break;
             case 'interval':
                 if ($old != $value) {
                 }
                 break;
             case 'cron_service':
                 if ($old != $value) {
                     if ($value == 'wp_cron') {
                         if (!wp_next_scheduled('mymail_cron_worker')) {
                             wp_schedule_event(floor(time() / 300) * 300, 'mymail_cron_interval', 'mymail_cron_worker');
                         }
                     } else {
                         wp_clear_scheduled_hook('mymail_cron_worker');
                     }
                 }
                 break;
             case 'cron_secret':
                 if ($old != $value) {
                     if ($value == '') {
                         $value = md5(uniqid());
                     }
                 }
                 break;
             case 'vcard_content':
                 $folder = MYMAIL_UPLOAD_DIR;
                 if (empty($options['vcard_content'])) {
                     $options['vcard'] = false;
                 }
                 if (!is_dir($folder)) {
                     wp_mkdir_p($folder);
                 }
                 $options['vcard_filename'] = sanitize_file_name($options['vcard_filename']);
                 $filename = $folder . '/' . $options['vcard_filename'];
                 if (!empty($options['vcard'])) {
                     file_put_contents($filename, $options['vcard_content']);
                 } else {
                     if (file_exists($filename)) {
                         @unlink($filename);
                     }
                 }
                 break;
             case 'custom_field':
                 if (serialize($old) != serialize($value)) {
                 }
                 break;
             case 'forms':
                 if (function_exists('add_settings_error')) {
                     foreach ($value as $form) {
                         if (!isset($form['lists']) || empty($form['lists'])) {
                             add_settings_error('mymail_options', 'mymail_options', sprintf(__('Form %s has no assigned lists', 'mymail'), '"' . $form['name'] . '"'));
                         }
                     }
                 }
                 if (serialize($old) != serialize($value)) {
                 }
                 break;
             case 'form_css':
                 if (isset($_POST['mymail_reset_form_css'])) {
                     require_once MYMAIL_DIR . '/includes/static.php';
                     $value = $mymail_form_css;
                     add_settings_error('mymail_options', 'mymail_options', __('Form CSS reseted!', 'mymail'), 'updated');
                 }
                 if ($old != $value) {
                     delete_transient('mymail_form_css');
                     $value = str_replace(array('MYMAIL_URI'), array(MYMAIL_URI), $value);
                     $options['form_css_hash'] = md5(MYMAIL_VERSION . $value);
                 }
                 break;
             case 'send_period':
                 if ($old != $value) {
                     if ($timestamp = get_option('_transient_timeout__mymail_send_period_timeout')) {
                         $new = time() + $value * 3600;
                         update_option('_transient_timeout__mymail_send_period_timeout', $new);
                     } else {
                         update_option('_transient__mymail_send_period_timeout', false);
                     }
                     mymail_remove_notice('dailylimit');
                 }
                 break;
             case 'roles':
                 if (serialize($old) != serialize($value)) {
                     require_once MYMAIL_DIR . '/includes/capability.php';
                     global $wp_roles;
                     if (!$wp_roles) {
                         break;
                     }
                     $newvalue = array();
                     //give admin all rights
                     $value['administrator'] = array();
                     //foreach role
                     foreach ($value as $role => $capabilities) {
                         if (!isset($newvalue[$role])) {
                             $newvalue[$role] = array();
                         }
                         foreach ($mymail_capabilities as $capability => $data) {
                             if (in_array($capability, $capabilities) || 'administrator' == $role) {
                                 $wp_roles->add_cap($role, $capability);
                                 $newvalue[$role][] = $capability;
                             } else {
                                 $wp_roles->remove_cap($role, $capability);
                             }
                         }
                     }
                     $value = $newvalue;
                 }
                 break;
             case 'tweet_cache_time':
                 $value = (int) $value;
                 if ($value < 10) {
                     $value = 10;
                     add_settings_error('mymail_options', 'mymail_options', sprintf(__('The caching time for tweets must be at least %d minutes', 'mymail'), '10'));
                 }
                 break;
             case 'deliverymethod':
                 if ($old != $value) {
                     if ($value == 'gmail') {
                         if ($options['send_limit'] != 500) {
                             $options['send_limit'] = 500;
                             $options['send_period'] = 24;
                             update_option('_transient__mymail_send_period_timeout', false);
                             add_settings_error('mymail_options', 'mymail_options', sprintf(__('Send limit has been adjusted to %d for Gmail', 'mymail'), 500));
                         }
                     }
                 }
                 break;
             case 'dkim_domain':
             case 'dkim_selector':
             case 'dkim_identity':
                 if ($old != $value) {
                     $value = trim($value);
                 }
                 break;
             case 'dkim_private_key':
                 if ($old != $value) {
                     global $wp_filesystem;
                     if (!mymail_require_filesystem('', '', false)) {
                         break;
                     }
                     $folder = MYMAIL_UPLOAD_DIR . '/dkim';
                     //create folder
                     if (!is_dir($folder)) {
                         wp_mkdir_p($folder);
                         $wp_filesystem->put_contents($folder . '/index.php', '<?php //silence is golden ?>', FS_CHMOD_FILE);
                     }
                     //remove old
                     if (isset($options['dkim_private_hash']) && is_file($folder . '/' . $options['dkim_private_hash'] . '.pem')) {
                         $wp_filesystem->delete($folder . '/' . $options['dkim_private_hash'] . '.pem');
                     }
                     $hash = md5($value);
                     if ($wp_filesystem->put_contents($folder . '/' . $hash . '.pem', $value, FS_CHMOD_FILE)) {
                         $options['dkim_private_hash'] = $hash;
                     }
                 }
                 break;
             case 'purchasecode':
                 if ($old != $value && $value) {
                     if (preg_match('#^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$#', $value)) {
                         $envato_plugins = get_option('envato_plugins');
                         if (isset($envato_plugins[MYMAIL_SLUG])) {
                             $envato_plugins[MYMAIL_SLUG]->last_update = 0;
                             update_option('envato_plugins', $envato_plugins);
                         }
                     } else {
                         add_settings_error('mymail_options', 'mymail_options', sprintf(__('The provided purchasecode %s is invalid', 'mymail'), '"' . $value . '"'));
                         $value = '';
                     }
                 }
                 break;
         }
         $options[$id] = $value;
     }
     $options = apply_filters('mymail_verify_options', $options);
     //clear everything thats cached
     mymail_clear_cache();
     return $options;
 }
            $form['required'] = $required;
            $options['forms'][] = $form;
        }
    case '1.3.4.4':
    case '1.3.4.5':
    case '1.3.5':
    case '1.3.6':
    case '1.3.6.1':
        add_action('shutdown', array($mymail_templates, 'renew_default_template'));
    case '1.4.0':
    case '1.4.0.1':
        $lists = isset($options['newusers']) ? $options['newusers'] : array();
        $options['register_other_lists'] = $options['register_comment_form_lists'] = $options['register_signup_lists'] = $lists;
        $options['register_comment_form_status'] = array('1', '0');
        if (!empty($lists)) {
            $options['register_other'] = true;
        }
        $texts['newsletter_signup'] = __('Sign up to our newsletter', 'mymail');
        mymail_notice('[1.4.1] New option for WordPress Users! Please <a href="options-general.php?page=newsletter-settings#subscribers">update your settings</a>!');
        mymail_notice('[1.4.1] New text for newsletter sign up Please <a href="options-general.php?page=newsletter-settings#texts">update your settings</a>!');
    default:
}
//do stuff every update
$options['text'] = $texts;
//update options
update_option('mymail_options', $options);
//update caps
$mymail_settings->update_capabilities();
//clear cache
mymail_clear_cache('', true);
flush_rewrite_rules();
 public function edited_newsletter_lists($term_id, $tt_id)
 {
     mymail_clear_cache('form');
 }