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; } }