/** * Tarski preferences sometimes change between versions, and need to * be updated. This function does not determine whether an update is * needed, it merely perfoms it. It's also self-contained, so it * won't update the global $tarski_options object either. * * @since 2.1 * * @uses tarski_upgrade_special */ function tarski_upgrade() { // Get options and set defaults $options = get_option('tarski_options'); // Update the options version so we don't run this code more than once $options->installed = wp_get_theme()->Version; // Handle special cases first tarski_upgrade_special($options, null); // Save our upgraded options update_option('tarski_options', flush_tarski_options()); }
/** * function tarski_upgrade() - Upgrades Tarski's options where appropriate. * * Tarski preferences sometimes change between versions, and need to * be updated. This function does not determine whether an update is * needed, it merely perfoms it. It's also self-contained, so it * won't update the global $tarski_options object either. * @since 2.1 * @uses tarski_upgrade_special() * @uses tarski_upgrade_widgets() */ function tarski_upgrade() { // Get existing options $options = new Options(); $options->tarski_options_get(); // Get our defaults, so we can merge them in $defaults = new Options(); $defaults->tarski_options_defaults(); // Update the options version so we don't run this code more than once $options->installed = theme_version('current'); // Handle special cases first tarski_upgrade_special($options, $defaults); // Upgrade old display options to use widgets instead tarski_upgrade_widgets($options, $defaults); // Conform our options to the expected values, types, and defaults foreach ($options as $name => $value) { if (!isset($defaults->{$name})) { // Get rid of options which no longer exist unset($options->{$name}); } elseif (!isset($options->{$name})) { // Use the default if we don't have this option $options->{$name} = $defaults->{$name}; } elseif (is_array($options->{$name}) && !is_array($defaults->{$name})) { // If our option is an array and the default is not, implode using " " as a separator $options->{$name} = implode(" ", $options->{$name}); } elseif (!is_array($options->{$name}) && is_array($defaults->{$name})) { // If our option is a scalar and the default is an array, wrap our option in an array $options->{$name} = array($options->{$name}); } } // Save our upgraded options update_option('tarski_options', $options); }