public static function update()
 {
     global $CRAYON_VERSION;
     CrayonSettingsWP::load_settings(TRUE);
     $settings = CrayonSettingsWP::get_settings();
     if ($settings === NULL || !isset($settings[CrayonSettings::VERSION])) {
         return;
     }
     $version = $settings[CrayonSettings::VERSION];
     // Only upgrade if the version differs
     if ($version != $CRAYON_VERSION) {
         $defaults = CrayonSettings::get_defaults_array();
         $touched = FALSE;
         // Upgrade database and settings
         if (CrayonUtil::version_compare($version, '1.7.21') < 0) {
             $settings[CrayonSettings::SCROLL] = $defaults[CrayonSettings::SCROLL];
             $touched = TRUE;
         }
         if (CrayonUtil::version_compare($version, '1.7.23') < 0 && $settings[CrayonSettings::FONT] == 'theme-font') {
             $settings[CrayonSettings::FONT] = $defaults[CrayonSettings::FONT];
             $touched = TRUE;
         }
         if (CrayonUtil::version_compare($version, '1.14') < 0) {
             CrayonLog::syslog("Updated to v1.14: Font size enabled");
             $settings[CrayonSettings::FONT_SIZE_ENABLE] = TRUE;
         }
         if (CrayonUtil::version_compare($version, '1.17') < 0) {
             $settings[CrayonSettings::HIDE_HELP] = FALSE;
         }
         // Save new version
         $settings[CrayonSettings::VERSION] = $CRAYON_VERSION;
         CrayonSettingsWP::save_settings($settings);
         CrayonLog::syslog("Updated from {$version} to {$CRAYON_VERSION}");
         // Refresh to show new settings
         header('Location: ' . CrayonUtil::current_url());
         exit;
     }
 }
 public static function load_settings($just_load_settings = FALSE)
 {
     if (self::$options === NULL) {
         // Load settings from db
         if (!(self::$options = get_option(self::OPTIONS))) {
             self::$options = CrayonSettings::get_defaults_array();
             update_option(self::OPTIONS, self::$options);
         }
         // Initialise default global settings and update them from db
         CrayonGlobalSettings::set(self::$options);
     }
     if (!self::$is_fully_loaded && !$just_load_settings) {
         // Load everything else as well
         // For local file loading
         // This is used to decouple WP functions from internal Crayon classes
         CrayonGlobalSettings::site_url(home_url());
         CrayonGlobalSettings::site_path(ABSPATH);
         CrayonGlobalSettings::plugin_path(plugins_url('', __FILE__));
         $upload = wp_upload_dir();
         CrayonLog::debug($upload, "WP UPLOAD FUNCTION");
         CrayonGlobalSettings::upload_path(CrayonUtil::path_slash($upload['basedir']) . CRAYON_DIR);
         CrayonGlobalSettings::upload_url($upload['baseurl'] . '/' . CRAYON_DIR);
         CrayonLog::debug(CrayonGlobalSettings::upload_path(), "UPLOAD PATH");
         CrayonGlobalSettings::set_mkdir('wp_mkdir_p');
         // Load all available languages and themes
         CrayonResources::langs()->load();
         CrayonResources::themes()->load();
         // Ensure all missing settings in db are replaced by default values
         $changed = FALSE;
         foreach (CrayonSettings::get_defaults_array() as $name => $value) {
             // Add missing settings
             if (!array_key_exists($name, self::$options)) {
                 self::$options[$name] = $value;
                 $changed = TRUE;
             }
         }
         // A setting was missing, update options
         if ($changed) {
             update_option(self::OPTIONS, self::$options);
         }
         self::$is_fully_loaded = TRUE;
     }
 }
 public static function update()
 {
     // Upgrade database and settings
     global $CRAYON_VERSION;
     $settings = CrayonSettingsWP::get_settings();
     if ($settings === NULL || !isset($settings[CrayonSettings::VERSION])) {
         return;
     }
     $version = $settings[CrayonSettings::VERSION];
     $defaults = CrayonSettings::get_defaults_array();
     $touched = FALSE;
     if ($version < '1.7.21') {
         $settings[CrayonSettings::SCROLL] = $defaults[CrayonSettings::SCROLL];
         $touched = TRUE;
     }
     if ($version < '1.7.23' && $settings[CrayonSettings::FONT] == 'theme-font') {
         $settings[CrayonSettings::FONT] = $defaults[CrayonSettings::FONT];
         $touched = TRUE;
     }
     if ($touched) {
         $settings[CrayonSettings::VERSION] = $CRAYON_VERSION;
         CrayonSettingsWP::save_settings($settings);
     }
 }