PluginProbe
LoftLoader / trunk
LoftLoader vtrunk
trunk 1.0.0 1.0.1 1.0.2 2.0.0 2.1.0 2.1.1 2.1.10 2.1.11 2.1.12 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 2.2.0 2.2.1 2.2.2 2.3 2.3.1 2.3.2 2.3.3 All 34 releases
loftloader / inc / class-loftloader-upgrade.php

class-loftloader-upgrade.php in LoftLoader trunk, at inc/class-loftloader-upgrade.php

62 lines 2.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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