static function convert_form_options($old_options, $max_fields)
 {
     // Converts form options from version 3.x to 4.x
     // Returns converted options array
     global $fscf_special_slugs;
     // List of reserve slug names
     //print_r($old_options); exit;
     // Start with the current version form defaults
     $new_options = FSCF_Util::get_form_defaults();
     foreach ($new_options as $key => $val) {
         //if ( ! empty($old_options[$key]) ) // caused empty  Welcome introduction to appear filled in
         if (isset($old_options[$key])) {
             $new_options[$key] = stripslashes($old_options[$key]);
         }
     }
     // ***** Import fields *****
     // Keep a list of slugs so we can be sure they are unique
     $slug_list = $fscf_special_slugs;
     // Standard fields should already have been added by defaults
     // Import standard field settings
     $std_fields = array('name', 'email', 'subject', 'message');
     // This assumes that the standard fields in the form defaults are in the same order as
     //   the names in the above array
     foreach ($std_fields as $key => $val) {
         if ('subject' == $val) {
             // was there an optional subject select list?
             if (!empty($old_options['email_subject_list'])) {
                 $new_options['fields'][$key]['options'] = $old_options['email_subject_list'];
                 $new_options['fields'][$key]['type'] = 'select';
             }
         }
         // Make sure this goes to the correct field!
         $test = 'name' == $val ? 'full_name' : $val;
         $slug_list[] = $test;
         if ($new_options['fields'][$key]['slug'] == $test) {
             // name_type, etc. could be 'required', 'not_required', or 'not_available'
             if ('not_required' == $old_options[$val . '_type']) {
                 // Standard fields are required by default, so change this
                 $new_options['fields'][$key]['req'] = 'false';
             } else {
                 if ('not_available' == $old_options[$val . '_type']) {
                     $new_options['fields'][$key]['disable'] = 'true';
                 }
             }
         } else {
             // Error: this is the wrong field!
             // This could happen if the standard fields in the default form are in a different
             // order than in $std_fields
         }
     }
     // end foreach $std_fields
     //print_r($new_options);
     // Import the old "extra fields"
     // This will ignore any field properties no longer used
     for ($fld = 1; $fld <= $max_fields; $fld++) {
         $old_type = $old_options['ex_field' . $fld . '_type'];
         if (!empty($old_options['ex_field' . $fld . '_label']) || 'fieldset' == $old_type || 'fieldset-close' == $old_type) {
             // Add a new field with the default properties
             $new_field = FSCF_Util::get_field_defaults();
             foreach ($new_field as $key => $val) {
                 $old_prop = 'ex_field' . $fld . '_' . $key;
                 // Need special treatment for: default option / default_text
                 // Need to parse and reformat select options lists, checkboxres, etc.
                 switch ($key) {
                     case "default":
                         // The old version has both default_text and default_option
                         if (in_array($old_type, self::$select_type_fields) && $old_options['ex_field' . $fld . '_default'] > 0) {
                             $new_field['default'] = $old_options['ex_field' . $fld . '_default'];
                         } else {
                             if (!empty($old_options['ex_field' . $fld . '_default_text'])) {
                                 $new_field['default'] = stripslashes($old_options['ex_field' . $fld . '_default_text']);
                             }
                         }
                         break;
                     case "label":
                         if (empty($old_options['ex_field' . $fld . '_label']) && ('fieldset' == $old_type || 'fieldset-close' == $old_type)) {
                             $old_options['ex_field' . $fld . '_label'] = sprintf(__('Field %s', 'si-contact-form'), $fld);
                         }
                         // Check for options added to the label (e.g. Color:,Red;Green;Blue ), etc.
                         $new_field[$key] = $old_options[$old_prop];
                         if (in_array($old_type, self::$select_type_fields) && 'checkbox' != $old_type) {
                             $new_field = self::parse_label($new_field);
                         }
                         if ('checkbox' == $old_type) {
                             // label might have \, (not needed in 4.x version, remove it)
                             $new_field['label'] = str_replace('\\,', ',', $new_field['label']);
                             // "\," changes to ","
                             $new_field['label'] = stripslashes($new_field['label']);
                         }
                         break;
                     default:
                         if (!empty($old_options[$old_prop])) {
                             $new_field[$key] = stripslashes($old_options[$old_prop]);
                         }
                 }
                 // End switch
             }
             // end foreach $new_field
             // Create the slug for the field from the field label
             // the sanitize title function encodes UTF-8 characters, so we need to undo that
             // this line croaked on some chinese characters
             //$new_field['slug'] = substr( urldecode(sanitize_title_with_dashes(remove_accents($new_field['label']))), 0, FSCF_MAX_SLUG_LEN );
             //echo 'slug before:'.$new_field['label']."<br>\n";
             $new_field['slug'] = remove_accents($new_field['label']);
             $new_field['slug'] = preg_replace('~([^a-zA-Z\\d_ .-])~', '', $new_field['slug']);
             $new_field['slug'] = substr(urldecode(sanitize_title_with_dashes($new_field['slug'])), 0, FSCF_MAX_SLUG_LEN);
             if ($new_field['slug'] == '') {
                 $new_field['slug'] = 'na';
             }
             if ('-' == substr($new_field['slug'], strlen($new_field['slug']) - 1, 1)) {
                 $new_field['slug'] = substr($new_field['slug'], 0, strlen($new_field['slug']) - 1);
             }
             // Make sure the slug is unique
             $new_field['slug'] = FSCF_Options::check_slug($new_field['slug'], $slug_list);
             //echo 'slug jafter:'.$new_field['slug']."<br>\n";
             $slug_list[] = $new_field['slug'];
             $new_options['fields'][] = $new_field;
         }
         // end if old field label not empty
     }
     // for loop through fields
     return $new_options;
 }