/**
  * @static
  * @return EasyRecipePlusSettings
  */
 static function getInstance()
 {
     $freeSettings = null;
     $updateOptions = false;
     /**
      * If we haven't already instantiated settings, try to do it from the options
      */
     if (!self::$instance) {
         self::$instance = get_option('EasyRecipePlus', false);
         if (!self::$instance) {
             self::$instance = new EasyRecipePlusSettings();
             /**
              * There were no Plus settings saved
              * See if we have any free version settings and copy those if there are
              */
             $freeSettings = get_option('EasyRecipe');
             if (!empty($freeSettings)) {
                 foreach (self::$defaultSettings as $setting => $default) {
                     if (isset($freeSettings->{$setting})) {
                         self::$instance->{$setting} = $freeSettings->{$setting};
                     }
                 }
                 $updateOptions = true;
             }
             /**
              * If we're updating from a very early version, copy the old settings which are still relevant
              * Any not set in the defaults are deprecated and we can drop them
              */
             if (empty($freeSettings)) {
                 $v31Settings = get_option('ERPlusSettings');
                 if (!$v31Settings) {
                     $v31Settings = get_option('ERSettings');
                 }
                 if (!empty($v31Settings)) {
                     foreach ($v31Settings as $setting => $value) {
                         if (isset(self::$defaultSettings[$setting])) {
                             self::$instance->{$setting} = $value;
                         }
                     }
                     $updateOptions = true;
                 }
             }
         }
         /**
          * Fixup possible legacy problems where the options weren't stored as the correct class
          */
         if (!self::$instance instanceof EasyRecipePlusSettings) {
             self::$instance = new EasyRecipePlusSettings(self::$instance);
             $updateOptions = true;
         }
         /**
          * If this is the first run of the plugin after an update, see if we need to do any processing specific to this update.
          * Also do the update check if the taxonomies haven't been created yet
          *
          * TODO - determine if this is a new install -  won't need to check if so?
          */
         $updateCheck = version_compare(self::$instance->settingsVersion, EasyRecipePlus::$pluginVersion) == -1 || !self::$instance->taxonomiesCreated;
         if ($updateCheck) {
             EasyRecipePlusUpdate::check(self::$instance);
             /**
              * Save the new settings version (will be the same as the installed pluginVersion)
              */
             self::$instance->settingsVersion = EasyRecipePlus::$pluginVersion;
             $updateOptions = true;
         }
         /**
          * Do we need to fix the .tmp stuff up that happened on some installs of ER 3.2.2802?
          * Only need to check if the current version is > 2802
          * Should be able to remove this once the few sites that it affects get updated
          */
         if (version_compare(EasyRecipePlus::$pluginVersion, '3.2.2802') == 1) {
             EasyRecipePlusUpdate::check2802();
         }
         /**
          * Set any defaults which haven't been set in the current version (i.e. new settings just introduced)
          * TODO - remove any options no longer needed?
          */
         foreach (self::$defaultSettings as $setting => $default) {
             if (!isset(self::$instance->{$setting})) {
                 self::$instance->{$setting} = $default;
                 $updateOptions = true;
             }
         }
         /**
          * Update the settings if we changed them during construction
          */
         if ($updateOptions) {
             update_option('EasyRecipePlus', self::$instance);
         }
     }
     return self::$instance;
 }