static function import_forced($force = '') { // conditionally imports old settings only if they exist // see if upgrading from an older version $old_global_options = get_option('si_contact_form_gb'); if ($old_global_options) { // import now require_once FSCF_PATH . 'includes/class-fscf-import.php'; FSCF_Import::import_old_version($force); } else { // old options did not exist self::$global_options = FSCF_Util::get_global_options(); // Is this is a really old version, prior to 2.6.5 (earlier versions did not have global options) $temp = get_option('si_contact_form'); if (!empty($temp)) { FSCF_Util::add_admin_notice(__('<b>Warning</b>: Fast Secure Contact Form cannot import settings because the previous version is too old. Installed as new.', 'si-contact-form'), 'error'); self::$global_options['import_success'] = false; self::$global_options['import_msg'] = true; update_option('fs_contact_global', self::$global_options); } } return; }
static function import_old_version($force = '') { // global $fscf_special_slugs; // List of reserve slug names // ***** Import global options ***** // upgrade import only back to version 2.5.6, because before that, there was no 'si_contact_form_gb' setting self::$old_global_options = get_option('si_contact_form_gb'); if (empty(self::$old_global_options)) { return; } //print_r(self::$old_global_options)."<br>\n"; self::$global_options = FSCF_Util::get_global_options(); // import a few global options $copy_fields = array('donated', 'vcita_dismiss'); foreach ($copy_fields as $field) { if (!empty(self::$old_global_options[$field])) { self::$global_options[$field] = self::$old_global_options[$field]; } } // import this global option // Highest form ID (used to assign ID to new form) // When forms are deleted, the remaining forms are NOT renumberd, so max_form_num might be greater than // the number of existing forms if (!empty(self::$old_global_options['max_forms'])) { self::$global_options['max_form_num'] = self::$old_global_options['max_forms']; } //print 'max_form_num:'.self::$global_options['max_form_num']."<br>\n"; // ***** Import form options ***** $max_fields_shim = 8; if ($force == 'force') { // force is when they pressed the button import from 3.xx, they are warned this replaces the 4.xx forms self::$global_options['form_list'] = array(); // delete current form list // delete current 4.xx forms delete_option('fs_contact_global'); // delete up to 100 forms (a unique configuration for each contact form) for ($i = 1; $i <= 100; $i++) { delete_option("fs_contact_form{$i}"); } } for ($frm = 1; $frm <= self::$global_options['max_form_num']; $frm++) { //print 'importing form:'.$frm."<br>\n"; $old_opt_name = 'si_contact_form'; $old_opt_name .= $frm == 1 ? '' : $frm; self::$old_form_options = get_option($old_opt_name); if (!self::$old_form_options) { continue; } if ($force == 'force') { } else { // Make sure that the options for this form doesn't already exist self::$form_options = FSCF_Util::get_form_options($frm, $use_defaults = false); if (self::$form_options) { continue; } } // if max fields is missing it will be 8, or the value of the last one in the loop. if (isset(self::$old_form_options['max_fields']) && self::$old_form_options['max_fields'] > 0) { $max_fields_shim = self::$old_form_options['max_fields']; } else { self::$old_form_options['max_fields'] = $max_fields_shim; } $new_form_options = self::convert_form_options(self::$old_form_options, self::$old_form_options['max_fields']); //print_r($new_form_options)."<br>\n"; // Save the imported form $form_option_name = 'fs_contact_form' . $frm; // Add form name to the form list... if ($new_form_options['form_name'] == '') { $new_form_options['form_name'] = __('imported', 'si-contact-form'); } self::$global_options['form_list'][$frm] = $new_form_options['form_name']; update_option($form_option_name, $new_form_options); } // end for loop (forms) self::$global_options['import_success'] = true; self::$global_options['import_msg'] = true; // recalibrate max_form_num to the highest form number (not count) ksort(self::$global_options['form_list']); self::$global_options['max_form_num'] = max(array_keys(self::$global_options['form_list'])); //print_r(self::$global_options)."<br>\n"; update_option('fs_contact_global', self::$global_options); // Display a notice on the admin page FSCF_Util::add_admin_notice(__('Fast Secure Contact Form has imported settings from the old version.', 'si-contact-form'), 'updated'); // Force reload of global and form options FSCF_Options::unload_options(); }