| 1 |
<?php |
| 2 |
if ( ! class_exists( 'LoftLoader_Upgrade' ) ) { |
| 3 |
class LoftLoader_Upgrade { |
| 4 |
private $version ='2.4'; |
| 5 |
function __construct(){ |
| 6 |
$old_version = get_option('loftloader_lite_version', '1.0'); |
| 7 |
if(version_compare($old_version, $this->version, '<')){ |
| 8 |
if(version_compare($old_version, '2.0', '<')){ |
| 9 |
$this->upgrade20(); |
| 10 |
} |
| 11 |
$this->update_version(); |
| 12 |
} |
| 13 |
} |
| 14 |
private function upgrade20(){ |
| 15 |
$default_img = LOFTLOADER_URI . 'assets/img/loftloader-logo.png'; |
| 16 |
$defaults = array( |
| 17 |
'enable' => 'on', |
| 18 |
'homepage' => '', |
| 19 |
'settings' => array( |
| 20 |
'background' => array( |
| 21 |
'effect' => 'fade', |
| 22 |
'color' => '#000000', |
| 23 |
'opacity' => '95%' |
| 24 |
), |
| 25 |
'animation' => array( |
| 26 |
'type' => 'pl-sun', |
| 27 |
'color' => '#248acc', |
| 28 |
'image' => array( |
| 29 |
'url' => $default_img, |
| 30 |
'id' => '' |
| 31 |
), |
| 32 |
'width' => '76' |
| 33 |
) |
| 34 |
) |
| 35 |
); |
| 36 |
$saved = get_option('loftloader-custom-settings', array()); |
| 37 |
$options = array_merge($defaults, $saved); |
| 38 |
$effect = array('fade'=> 'fade', 'slide-up'=> 'up', 'slide-left-right'=> 'split-h', 'slide-up-down'=> 'split-v'); |
| 39 |
|
| 40 |
if($options['settings']['animation']['image']['url'] == LOFTLOADER_URI . 'img/loftloader-logo.png'){ |
| 41 |
$options['settings']['animation']['image']['url'] = $default_img; |
| 42 |
} |
| 43 |
|
| 44 |
update_option('loftloader_main_switch', ($options['enable'] == 'on' ? 'on' : 'off')); |
| 45 |
update_option('loftloader_show_range', ($options['homepage'] == 'on' ? 'homepage': 'sitewide')); |
| 46 |
|
| 47 |
update_option('loftloader_bg_color', $options['settings']['background']['color']); |
| 48 |
update_option('loftloader_bg_opacity', intval($options['settings']['background']['opacity'])); |
| 49 |
update_option('loftloader_bg_animation', $effect[$options['settings']['background']['effect']]); |
| 50 |
|
| 51 |
update_option('loftloader_loader_type', substr($options['settings']['animation']['type'], 3)); |
| 52 |
update_option('loftloader_loader_color', $options['settings']['animation']['color']); |
| 53 |
update_option('loftloader_custom_img', $options['settings']['animation']['image']['url']); |
| 54 |
update_option('loftloader_img_width', $options['settings']['animation']['width']); |
| 55 |
} |
| 56 |
private function update_version(){ |
| 57 |
update_option('loftloader_lite_version', $this->version); |
| 58 |
} |
| 59 |
} |
| 60 |
new LoftLoader_Upgrade(); |
| 61 |
} |
| 62 |
|