Plugin Directory

source: featured-video-plus/trunk/php/inc-upgrade.php @ 1179150

Last change on this file since 1179150 was 1179150, checked in by a.hoereth, 9 years ago

Version 2.1.0

File size: 5.7 KB
Line 
1<?php
2if ( empty( $version ) || empty( $options ) || empty( $options_org ) ) {
3        exit('Featured Video Plus Error:
4                Upgrade can not be executed directly!
5                Must be called through FVP_Backend->upgrade().');
6}
7
8switch ( $version ) {
9        case '1.0':
10        case '1.1':
11                $users = array_merge(
12                        get_users( array( 'role' => 'Administrator' ) ),
13                        get_users( array( 'role' => 'Super Admin'   ) )
14                );
15
16                foreach ( $users AS $user ) {
17                        delete_user_meta( $user->ID, 'fvp_activation_notification_ignore' );
18                }
19
20
21        case '1.2':
22                $options['videojs'] = array(
23                        'skin' => 'videojs', //videojs,moonfy,tubejs
24                );
25                $options['youtube'] = array(
26                        'theme' => 'dark',
27                        'color' => 'red',
28                        'info'  => 1,
29                        'rel'   => 1,
30                        'fs'    => 1,
31                );
32                $options['dailymotion'] = array(
33                        'foreground'  => 'F7FFFD',
34                        'highlight'   => 'FFC300',
35                        'background'  => '171D1B',
36                        'logo'        => 1,
37                        'info'        => 1,
38                );
39                $options['sizing'] = array(
40                        'wmode'  => $options['width'],
41                        'hmode'  => $options['height'],
42                        'width'  => 560,
43                        'height' => 315,
44                        'align'  => 'left',
45                );
46                unset( $options['width'], $options['height'] );
47
48
49        case '1.3':
50                $options['out']                        = 0;
51                $options['autoplay']                   = 0;
52                $options['youtube']['logo']            = 1;
53                $options['dailymotion']['syndication'] = '';
54                $options['align'] = $options['sizing']['wmode'] == 'auto' ? 'center' : $options['sizing']['align'];
55                unset( $options['sizing']['align'] );
56
57
58        case '1.4':
59                $options['youtube']['wmode']        = 'auto';
60                $options['local']['videojs']['js']  = true;
61                $options['local']['videojs']['css'] = true;
62                $options['local']['videojs']['cdn'] = false;
63                unset( $options['videojs'] );
64
65
66        case '1.5':
67        case '1.5.1':
68                $options['youtube']['jsapi']           = 0;
69                $options['local']['videojs']['poster'] = false;
70                unset( $options['reged'], $options['out'] );
71
72
73        case '1.6':
74        case '1.6.1':
75                $options['usage'] = $options['overwrite'] ? 'replace' : 'manual'; // replace;manual;overlay
76                unset( $options['overwrite'] );
77
78
79        case '1.7':
80        case '1.7.1':
81                $options['local']['cdn']     = $options['local']['videojs']['cdn'];
82                $options['local']['enabled'] = $options['local']['videojs']['js'];
83                $options['local']['poster']  = $options['local']['videojs']['poster'];
84                unset( $options['local']['videojs'] );
85
86                $options['local']['foreground'] = 'cccccc';
87                $options['local']['highlight']  = '66a8cc';
88                $options['local']['background'] = '000000';
89                $options['local']['controls']   = true;
90                $options['local']['loop']       = false;
91                $options['autoplay'] = $options['autoplay'] ? 'yes' : 'no'; //yes/auto/no
92
93
94        case '1.8':
95                unset(
96                        $options['local']['cdn'],
97                        $options['local']['enabled'],
98                        $options['local']['foreground'],
99                        $options['local']['background'],
100                        $options['local']['controls']
101                );
102
103
104        case '1.9':
105        case '1.9.1':
106                $sizing = array(
107                        'responsive' => ! empty( $options['sizing']['wmode'] ) ?
108                                (bool)  $options['sizing']['wmode']   : true,
109                        'width'      => ! empty( $options['sizing']['width'] ) ?
110                                intval( $options['sizing']['width'] ) : 640,
111                );
112                unset( $options['sizing'] );
113                $options['sizing'] = $sizing;
114
115                $options['conditions'] = array(
116                        'home'   => ! empty( $options['ishome'] )  && $options['ishome'],
117                        'single' => ! empty( $options['issingle'] ) && $options['issingle'],
118                );
119                $options['mode'] = $options['usage'];
120                $options['alignment'] = $options['align'];
121                $options['youtube']['showinfo']    = $options['youtube']['info'];
122                $options['youtube']['enablejsapi'] = $options['youtube']['jsapi'];
123                $options['youtube']['modestbranding'] =
124                        ( $options['youtube']['logo'] + 1 ) % 2;
125
126                unset(
127                        $options['ishome'],
128                        $options['issingle'],
129                        $options['usage'],
130                        $options['align'],
131                        $options['youtube']['info'],
132                        $options['youtube']['jsapi'],
133                        $options['youtube']['logo'],
134                        $options['version'] // now saved in its own field
135                );
136
137                // remove all previous defaults
138                $options['default_args'] = array(
139                        'general' => array_diff_assoc(
140                                array(
141                                        'autoplay' => $options['autoplay'] == 'true' ? true : false,
142                                        'loop'     => $options['local']['loop'],
143                                ),
144                                array(
145                                        'autoplay' => false,
146                                        'loop'     => false,
147                                )
148                        ),
149                        'vimeo' => array_diff_assoc(
150                                ! empty( $options['vimeo'] ) ? $options['vimeo'] : array(),
151                                array(
152                                        'portrait' => 0,
153                                        'title'    => 1,
154                                        'byline'   => 1,
155                                        'color'    => '00adef',
156                                )
157                        ),
158                        'youtube' => array_diff_assoc(
159                                ! empty( $options['youtube'] ) ? $options['youtube'] : array(),
160                                array(
161                                        'theme' => 'dark',
162                                        'color' => 'red',
163                                        'info'  => 1,
164                                        'rel'   => 1,
165                                        'fs'    => 1,
166                                        'logo'  => 1,
167                                        'jsapi' => 0,
168                                        'showinfo' => 1,
169                                        'enablejsapi' => 0,
170                                        'modestbranding'  => 0,
171                                )
172                        ),
173                        'dailymotion' => array_diff_assoc(
174                                ! empty( $options['dailymotion'] ) ? $options['dailymotion'] : array(),
175                                array(
176                                        'foreground'  => 'F7FFFD',
177                                        'highlight'   => 'FFC300',
178                                        'background'  => '171D1B',
179                                        'logo'        => 1,
180                                        'info'        => 1,
181                                        'syndication' => '',
182                                )
183                        ),
184                );
185                unset(
186                        $options['autoplay'],
187                        $options['vimeo'],
188                        $options['youtube'],
189                        $options['dailymotion'],
190                        $options['local']
191                );
192
193                // check all featured video post metas
194                $ids = self::get_post_by_custom_meta( '_fvp_video' );
195                foreach ( $ids as $id ) {
196                        $meta = maybe_unserialize( get_post_meta( $id, '_fvp_video', true ) );
197
198                        // Remove and re-add video.
199                        $this->save( array( 'id' => $id, 'fvp_video' => '' ) );
200                        $this->save( array( 'id' => $id, 'fvp_video' => $meta['full'] ) );
201                }
202
203
204        case '2.0.3':
205                $options['single_replace'] = false;
206                foreach( $options['conditions'] AS $key => $value ) {
207                        $options['conditions'][ $key ] = (bool) $value;
208                }
209
210
211        default:
212                update_option( 'fvp-settings', $options );
213                update_option( 'fvp-version', FVP_VERSION );
214                break;
215}
Note: See TracBrowser for help on using the repository browser.