/**
  * migrate typography fields
  */
 public function migrate_typography_fields($typography_options)
 {
     global $wpdb;
     $options = get_option(Avada::get_option_name(), array());
     $is_custom_font = false;
     if (isset($options['custom_fonts'])) {
         if (isset($options['custom_fonts']['woff']) && !empty($options['custom_fonts']['woff'])) {
             if (isset($options['custom_fonts']['woff'][0]) && isset($options['custom_fonts']['woff'][0]['id'])) {
                 $is_custom_font = true;
                 $woff_path = get_attached_file($options['custom_fonts']['woff'][0]['id']);
                 $custom_font_name = str_replace('.woff', '', basename($woff_path));
                 $custom_font_name = str_replace(' ', '-', $custom_font_name);
             }
         }
     }
     // Get subsets from gfont_settings
     $subset = false;
     if (isset($options['gfont_settings']) && !empty($options['gfont_settings'])) {
         if (false !== strpos($options['gfont_settings'], 'subset')) {
             $gfont_settings = wp_parse_args($options['gfont_settings'], array());
         } else {
             $all_subsets = Avada_Data::font_subsets();
             $gfont_settings = array();
             foreach ($all_subsets as $available_subset) {
                 if (false !== strpos($options['gfont_settings'], $available_subset)) {
                     $gfont_settings['subset'][] = $available_subset;
                 }
             }
         }
         if (isset($gfont_settings['subset']) && !empty($gfont_settings['subset'])) {
             if (is_array($gfont_settings['subset'])) {
                 $subsets = $gfont_settings['subset'];
             } else {
                 if (false !== strpos($gfont_settings['subset'], ',')) {
                     $subsets = explode(',', $gfont_settings['subset']);
                 } else {
                     $all_subsets = Avada_Data::font_subsets();
                     $subsets = array();
                     foreach ($all_subsets as $available_subset) {
                         if (false !== strpos($options['gfont_settings'], $available_subset)) {
                             $subsets[] = $available_subset;
                         }
                     }
                 }
             }
             if (1 < count($subsets)) {
                 $subset = 'latin' == $subsets[0] ? $subsets[1] : $subsets[0];
             } else {
                 $subset = $subsets[0];
             }
         } else {
             $subset = isset($gfont_settings['subset']) ? $gfont_settings['subset'] : false;
         }
     }
     $subset = 'latin' == $subset ? false : $subset;
     $this->fields = Avada_Options::get_option_fields();
     foreach ($this->fields as $field) {
         if (isset($field['type'])) {
             /**
              * Convert typography fields
              */
             if (isset($field['id']) && array_key_exists($field['id'], $typography_options)) {
                 $options[$field['id']] = array();
                 /**
                  * font-family
                  */
                 if (isset($typography_options[$field['id']]['font-family'])) {
                     if (is_array($typography_options[$field['id']]['font-family'])) {
                         // standard fonts
                         if (isset($typography_options[$field['id']]['font-family']['standard']) && isset($options[$typography_options[$field['id']]['font-family']['standard']])) {
                             if (!in_array($options[$typography_options[$field['id']]['font-family']['standard']], array('', 'None', 'none', 'Select Font'))) {
                                 $options[$field['id']]['font-family'] = $options[$typography_options[$field['id']]['font-family']['standard']];
                             } elseif ('body_typography' != $field['id'] && isset($options['body_typography']['font-backup'])) {
                                 $options[$field['id']]['font-backup'] = $options['body_typography']['font-backup'];
                             }
                         }
                         // google fonts
                         if (isset($typography_options[$field['id']]['font-family']['google']) && isset($options[$typography_options[$field['id']]['font-family']['google']]) && !in_array($options[$typography_options[$field['id']]['font-family']['google']], array('', 'None', 'none'))) {
                             $options[$field['id']]['font-family'] = $options[$typography_options[$field['id']]['font-family']['google']];
                             $options[$field['id']]['google'] = 'true';
                             // use standard font as backup font
                             if (isset($typography_options[$field['id']]['font-family']['standard']) && isset($options[$typography_options[$field['id']]['font-family']['standard']])) {
                                 if (!in_array($options[$typography_options[$field['id']]['font-family']['standard']], array('', 'None', 'none', 'Select Font'))) {
                                     $options[$field['id']]['font-backup'] = $options[$typography_options[$field['id']]['font-family']['standard']];
                                 } else {
                                     $options[$field['id']]['font-backup'] = 'Arial, Helvetica, sans-serif';
                                 }
                             }
                         }
                         // Handle custom-fonts
                         if (isset($custom_font_name) && isset($typography_options[$field['id']]['font-family']['custom']) && true === $typography_options[$field['id']]['font-family']['custom'] && $is_custom_font) {
                             $options[$field['id']]['font-family'] = $custom_font_name;
                         }
                     } else {
                         $options[$field['id']]['font-family'] = $options[$typography_options[$field['id']]['font-family']];
                     }
                 }
                 /**
                  * font-size
                  */
                 if (isset($typography_options[$field['id']]['font-size'])) {
                     if (isset($options[$typography_options[$field['id']]['font-size']]) && !isset($options[$field['id']]['font-size'])) {
                         $options[$field['id']]['font-size'] = $options[$typography_options[$field['id']]['font-size']] . 'px';
                     }
                 }
                 /**
                  * line-height
                  */
                 if (isset($typography_options[$field['id']]['line-height']) && isset($options[$typography_options[$field['id']]['line-height']])) {
                     $font_size = intval($options[$field['id']]['font-size']);
                     $line_height = intval($options[$typography_options[$field['id']]['line-height']]);
                     if (4 < $line_height) {
                         $options[$field['id']]['line-height'] = round($line_height / $font_size, 2);
                     }
                 }
                 /**
                  * font-weight
                  */
                 if (isset($typography_options[$field['id']]['font-weight'])) {
                     if (isset($options[$typography_options[$field['id']]['font-weight']])) {
                         $options[$field['id']]['font-weight'] = (int) $options[$typography_options[$field['id']]['font-weight']];
                     }
                 }
                 /**
                  * letter-spacing
                  */
                 if (isset($typography_options[$field['id']]['letter-spacing'])) {
                     if (isset($options[$typography_options[$field['id']]['letter-spacing']])) {
                         $options[$field['id']]['letter-spacing'] = intval($options[$typography_options[$field['id']]['letter-spacing']]) . 'px';
                     }
                 }
                 /**
                  * color
                  */
                 if (isset($typography_options[$field['id']]['color'])) {
                     if (isset($options[$typography_options[$field['id']]['color']])) {
                         $options[$field['id']]['color'] = $options[$typography_options[$field['id']]['color']];
                     }
                 }
                 /**
                  * margin-top
                  */
                 if (isset($typography_options[$field['id']]['margin-top'])) {
                     if (isset($options[$typography_options[$field['id']]['margin-top']])) {
                         // get the previous value
                         $options[$field['id']]['margin-top'] = $options[$typography_options[$field['id']]['margin-top']];
                         // figure out the units we'll be using
                         $units = isset($typography_options[$field['id']]['margin-units']) ? $typography_options[$field['id']]['margin-units'] : 'em';
                         // If numeric value is the same as the whole value, then we don't have units and we'll need to add them.
                         if ($options[$field['id']]['margin-top'] == Avada_Sanitize::number($options[$field['id']]['margin-top'])) {
                             // format the value: numeric + units
                             $options[$field['id']]['margin-top'] = $options[$field['id']]['margin-top'] . $units;
                         }
                     }
                 }
                 /**
                  * margin-bottom
                  */
                 if (isset($typography_options[$field['id']]['margin-bottom'])) {
                     if (isset($options[$typography_options[$field['id']]['margin-bottom']])) {
                         // get the previous value
                         $options[$field['id']]['margin-bottom'] = $options[$typography_options[$field['id']]['margin-bottom']];
                         // figure out the units we'll be using
                         $units = isset($typography_options[$field['id']]['margin-units']) ? $typography_options[$field['id']]['margin-units'] : 'em';
                         // If numeric value is the same as the whole value, then we don't have units and we'll need to add them.
                         if ($options[$field['id']]['margin-bottom'] == Avada_Sanitize::number($options[$field['id']]['margin-bottom'])) {
                             // format the value: numeric + units
                             $options[$field['id']]['margin-bottom'] = $options[$field['id']]['margin-bottom'] . $units;
                         }
                     }
                 }
                 /**
                  * Add fallbacks to default values
                  */
                 if (isset($all_new_fields[$field['id']]['default']['font-family']) && !isset($options[$field['id']]['font-family'])) {
                     $options[$field['id']]['font-family'] = $all_new_fields[$field['id']]['default']['font-family'];
                 }
                 if (isset($all_new_fields[$field['id']]['default']['font-size']) && !isset($options[$field['id']]['font-size'])) {
                     $options[$field['id']]['font-size'] = $all_new_fields[$field['id']]['default']['font-size'];
                 }
                 if (isset($all_new_fields[$field['id']]['default']['line-height']) && !isset($options[$field['id']]['line-height'])) {
                     $options[$field['id']]['line-height'] = $all_new_fields[$field['id']]['default']['line-height'];
                 }
                 if (isset($all_new_fields[$field['id']]['default']['font-weight']) && !isset($options[$field['id']]['font-weight'])) {
                     $options[$field['id']]['font-weight'] = $all_new_fields[$field['id']]['default']['font-weight'];
                 }
                 if (isset($all_new_fields[$field['id']]['default']['letter-spacing']) && !isset($options[$field['id']]['letter-spacing'])) {
                     $options[$field['id']]['letter-spacing'] = $all_new_fields[$field['id']]['default']['letter-spacing'];
                 }
                 if (isset($all_new_fields[$field['id']]['default']['color']) && !isset($options[$field['id']]['color'])) {
                     $options[$field['id']]['color'] = $all_new_fields[$field['id']]['default']['color'];
                 }
                 // add subsets
                 if ($subset) {
                     $options[$field['id']]['subsets'] = $subset;
                 }
             }
         }
     }
     // Update the options with our modifications.
     update_option(Avada::get_option_name(), $options);
 }