1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
<?php
namespace hji\ResponsiveIDX\controllers;
use \hji\ResponsiveIDX\ResponsiveIDX;
use \hji\ResponsiveIDX\controllers\Settings;
class Upgrader
{
protected $plugin;
private $versionSetting = 'hji_ridx_version';
private $ver;
function __construct()
{
if (!$this->ver = get_option($this->versionSetting))
{
$this->ver = 0;
}
add_action('admin_init', array($this, 'init'));
}
function init()
{
$this->plugin = get_plugin_data(ResponsiveIDX::$dir . '/responsive-idx.php');
if (version_compare($this->ver, $this->plugin['Version'], '<'))
{
$this->doUpgrade($this->plugin['Version']);
}
}
function doUpgrade($ver)
{
$callback = 'update_' . str_replace('.', '_', $ver);
if (method_exists($this, $callback))
{
$this->$callback();
}
update_option($this->versionSetting, $ver);
}
function update_2_5_4()
{
$colors = Settings::get_colors();
$colors['colors-on'] = 1;
update_option(Settings::$color_settings_key, $colors);
}
}