This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | /** |
||
3 | * Class used to upgrade internal gallery settings when needed |
||
4 | * Date: 19/07/2017 |
||
5 | */ |
||
6 | if ( ! class_exists( 'FooGallery_Upgrade' ) ) { |
||
7 | |||
8 | class FooGallery_Upgrade { |
||
0 ignored issues
–
show
|
|||
9 | |||
10 | function __construct() { |
||
0 ignored issues
–
show
|
|||
11 | //add_action( 'foogallery_admin_new_version_detected', array( $this, 'upgrade_all_galleries' ) ); |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
62% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. ![]() |
|||
12 | add_filter( 'foogallery_settings_upgrade', array( $this, 'upgrade_gallery_settings' ), 10, 2 ); |
||
13 | |||
14 | add_filter( 'foogallery_admin_settings_override', array( $this, 'add_force_upgrade_setting' ) ); |
||
15 | add_action( 'foogallery_admin_settings_custom_type_render_setting', array( $this, 'render_force_upgrades_settings' ) ); |
||
16 | add_action( 'wp_ajax_foogallery_force_upgrade', array( $this, 'ajax_force_upgrade' ) ); |
||
17 | |||
18 | add_action( 'add_meta_boxes_' . FOOGALLERY_CPT_GALLERY, array( $this, 'add_meta_boxes_to_gallery' ) ); |
||
19 | } |
||
20 | |||
21 | public function upgrade_gallery_settings( $settings, $foogallery ) { |
||
22 | $old_settings = get_post_meta( $foogallery->ID, FOOGALLERY_META_SETTINGS_OLD, true ); |
||
23 | |||
24 | //we have old settings - so upgrade them!!! |
||
25 | if ( !empty( $old_settings ) ) { |
||
26 | $upgrade_helper = new FooGallery_Upgrade_Helper(); |
||
27 | $settings = $upgrade_helper->perform_gallery_settings_upgrade( $foogallery ); |
||
28 | } |
||
29 | |||
30 | return $settings; |
||
31 | } |
||
32 | |||
33 | public function add_meta_boxes_to_gallery( $post ) { |
||
0 ignored issues
–
show
|
|||
34 | |||
35 | if ( foogallery_get_setting( 'enable_debugging' ) ) { |
||
36 | add_meta_box( |
||
37 | 'foogallery_upgrade_debug', |
||
38 | __( 'Settings Upgrade Debugging', 'foogallery' ), |
||
39 | array( $this, 'render_upgrade_debug_metabox' ), |
||
40 | FOOGALLERY_CPT_GALLERY, |
||
41 | 'normal', |
||
42 | 'low' |
||
43 | ); |
||
44 | } |
||
45 | } |
||
46 | |||
47 | public function render_upgrade_debug_metabox( $post ) { |
||
48 | $gallery = FooGallery::get( $post ); |
||
49 | |||
50 | if ( $gallery->is_new() ) { |
||
51 | return; |
||
52 | } |
||
53 | |||
54 | $old_settings = get_post_meta( $gallery->ID, FOOGALLERY_META_SETTINGS_OLD, true ); |
||
55 | $new_settings = $gallery->settings; // get_post_meta( $gallery->ID, FOOGALLERY_META_SETTINGS, true ); |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
50% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. ![]() |
|||
56 | $upgrade_helper = new FooGallery_Upgrade_Helper(); |
||
57 | $upgrade_settings = $upgrade_helper->build_new_settings( $gallery ); |
||
58 | |||
59 | if ( is_array( $old_settings ) ) { ksort( $old_settings ); } |
||
60 | if ( is_array( $new_settings ) ) { ksort( $new_settings ); } |
||
61 | if ( is_array( $upgrade_settings ) ) { ksort( $upgrade_settings ); } |
||
62 | ?> |
||
63 | <style> |
||
64 | #foogallery_upgrade_debug .inside { overflow: scroll; } |
||
65 | #foogallery_upgrade_debug table { font-size: 0.8em; } |
||
66 | #foogallery_upgrade_debug td { vertical-align: top; } |
||
67 | </style> |
||
68 | <table> |
||
69 | <tr> |
||
70 | <td><h3>Old Settings</h3></td> |
||
71 | <td><h3>New Settings</h3></td> |
||
72 | <td><h3>Upgrade Settings</h3></td> |
||
73 | </tr> |
||
74 | <tr> |
||
75 | <td><?php var_dump( $old_settings ); ?></td> |
||
76 | <td><?php var_dump( $new_settings ); ?></td> |
||
77 | <td><?php var_dump( $upgrade_settings ); ?></td> |
||
78 | </tr> |
||
79 | </table> |
||
80 | <?php |
||
81 | } |
||
82 | |||
83 | function ajax_force_upgrade() { |
||
0 ignored issues
–
show
|
|||
84 | if ( check_admin_referer( 'foogallery_force_upgrade' ) && current_user_can( 'install_plugins' ) ) { |
||
85 | |||
86 | //clear any and all previous upgrades! |
||
87 | delete_post_meta_by_key( '_foogallery_settings' ); |
||
88 | $this->upgrade_all_galleries(); |
||
89 | |||
90 | _e('The BETA upgrade process has been run!', 'foogallery' ); |
||
91 | die(); |
||
92 | } |
||
93 | } |
||
94 | |||
95 | function add_force_upgrade_setting( $settings ) { |
||
0 ignored issues
–
show
|
|||
96 | $settings['settings'][] = array( |
||
97 | 'id' => 'force_upgrade', |
||
98 | 'title' => __( 'Force Upgrade', 'foogallery' ), |
||
99 | 'desc' => sprintf( __( 'Force the BETA upgrade process to run. This may sometimes be needed if the upgrade did not run automatically. Any changes you have made to galleries after updating will be lost. THERE IS NO UNDO.', 'foogallery' ), foogallery_plugin_name() ), |
||
100 | 'type' => 'force_upgrade', |
||
101 | 'tab' => 'advanced' |
||
102 | ); |
||
103 | |||
104 | return $settings; |
||
105 | } |
||
106 | |||
107 | function render_force_upgrades_settings( $args ) { |
||
0 ignored issues
–
show
|
|||
108 | if ( 'force_upgrade' === $args['type'] ) { ?> |
||
109 | <div class="foogallery_settings_ajax_container"> |
||
110 | <input type="button" data-action="foogallery_force_upgrade" data-confirm="<?php _e('Are you sure? Any changes you have made since updating will be lost. There is no undo!', 'foogallery'); ?>" data-response="replace_container" data-nonce="<?php echo esc_attr( wp_create_nonce( 'foogallery_force_upgrade' ) ); ?>" class="button-primary foogallery_settings_ajax foogallery_force_upgrade" value="<?php _e( 'Run Upgrade Process', 'foogallery' ); ?>"> |
||
111 | <span style="position: absolute" class="spinner"></span> |
||
112 | </div> |
||
113 | <?php } |
||
114 | } |
||
115 | |||
116 | function upgrade_all_galleries() { |
||
0 ignored issues
–
show
|
|||
117 | $galleries = foogallery_get_all_galleries(); |
||
118 | |||
119 | foreach ( $galleries as $gallery ) { |
||
120 | $new_settings = get_post_meta( $gallery->ID, FOOGALLERY_META_SETTINGS, true ); |
||
121 | $old_settings = get_post_meta( $gallery->ID, FOOGALLERY_META_SETTINGS_OLD, true ); |
||
122 | |||
123 | //only upgrade galleries that need to be |
||
124 | if ( !is_array($new_settings) && is_array($old_settings) ) { |
||
125 | $upgrade_helper = new FooGallery_Upgrade_Helper(); |
||
126 | $upgrade_helper->perform_gallery_settings_upgrade( $gallery ); |
||
127 | } |
||
128 | } |
||
129 | } |
||
130 | } |
||
131 | } |
||
132 | |||
133 | if ( ! class_exists( 'FooGallery_Upgrade_Helper' ) ) { |
||
134 | |||
135 | class FooGallery_Upgrade_Helper { |
||
0 ignored issues
–
show
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.
You can fix this by adding a namespace to your class: namespace YourVendor;
class YourClass { }
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries. ![]() |
|||
136 | |||
137 | function perform_gallery_settings_upgrade( $foogallery ) { |
||
0 ignored issues
–
show
|
|||
138 | //build up the new settings |
||
139 | $new_settings = $this->build_new_settings( $foogallery ); |
||
140 | |||
141 | if ( !empty( $new_settings ) ) { |
||
142 | |||
143 | //save the new settings |
||
144 | add_post_meta($foogallery->ID, FOOGALLERY_META_SETTINGS, $new_settings, true); |
||
145 | |||
146 | //clear any cache that may be saved for the gallery |
||
147 | delete_post_meta($foogallery->ID, FOOGALLERY_META_CACHE); |
||
148 | |||
149 | //clear any previously calculated thumb dimensions |
||
150 | delete_post_meta($foogallery->ID, FOOGALLERY_META_THUMB_DIMENSIONS); |
||
151 | } |
||
152 | |||
153 | return $new_settings; |
||
154 | } |
||
155 | |||
156 | function build_new_settings( $foogallery ) { |
||
0 ignored issues
–
show
|
|||
157 | $mappings = array( |
||
158 | array( |
||
159 | 'id' => 'border-style', |
||
160 | 'value' => 'border-style-square-white', |
||
161 | 'new' => array( |
||
162 | array ( 'id' => 'theme', 'value' => 'fg-light' ), |
||
163 | array ( 'id' => 'border_size', 'value' => 'fg-border-thin' ), |
||
164 | array ( 'id' => 'drop_shadow', 'value' => 'fg-shadow-small' ), |
||
165 | array ( 'id' => 'rounded_corners', 'value' => '' ), |
||
166 | array ( 'id' => 'inner_shadow', 'value' => '' ), |
||
167 | ) |
||
168 | ), |
||
169 | array( |
||
170 | 'id' => 'border-style', |
||
171 | 'value' => 'border-style-circle-white', |
||
172 | 'new' => array( |
||
173 | array ( 'id' => 'theme', 'value' => 'fg-light' ), |
||
174 | array ( 'id' => 'border_size', 'value' => 'fg-border-thin' ), |
||
175 | array ( 'id' => 'drop_shadow', 'value' => 'fg-shadow-small' ), |
||
176 | array ( 'id' => 'rounded_corners', 'value' => 'fg-round-full' ), |
||
177 | array ( 'id' => 'inner_shadow', 'value' => '' ), |
||
178 | ) |
||
179 | ), |
||
180 | array( |
||
181 | 'id' => 'border-style', |
||
182 | 'value' => 'border-style-square-black', |
||
183 | 'new' => array( |
||
184 | array ( 'id' => 'theme', 'value' => 'fg-dark' ), |
||
185 | array ( 'id' => 'border_size', 'value' => 'fg-border-thin' ), |
||
186 | array ( 'id' => 'drop_shadow', 'value' => 'fg-shadow-small' ), |
||
187 | array ( 'id' => 'rounded_corners', 'value' => '' ), |
||
188 | array ( 'id' => 'inner_shadow', 'value' => '' ), |
||
189 | ) |
||
190 | ), |
||
191 | array( |
||
192 | 'id' => 'border-style', |
||
193 | 'value' => 'border-style-circle-black', |
||
194 | 'new' => array( |
||
195 | array ( 'id' => 'theme', 'value' => 'fg-dark' ), |
||
196 | array ( 'id' => 'border_size', 'value' => 'fg-border-thin' ), |
||
197 | array ( 'id' => 'drop_shadow', 'value' => 'fg-shadow-small' ), |
||
198 | array ( 'id' => 'rounded_corners', 'value' => 'fg-round-full' ), |
||
199 | array ( 'id' => 'inner_shadow', 'value' => '' ), |
||
200 | ) |
||
201 | ), |
||
202 | array( |
||
203 | 'id' => 'border-style', |
||
204 | 'value' => 'border-style-inset', |
||
205 | 'new' => array( |
||
206 | array ( 'id' => 'theme', 'value' => 'fg-light' ), |
||
207 | array ( 'id' => 'border_size', 'value' => '' ), |
||
208 | array ( 'id' => 'drop_shadow', 'value' => 'fg-shadow-small' ), |
||
209 | array ( 'id' => 'rounded_corners', 'value' => '' ), |
||
210 | array ( 'id' => 'inner_shadow', 'value' => 'fg-shadow-inset-large' ), |
||
211 | ) |
||
212 | ), |
||
213 | array( |
||
214 | 'id' => 'border-style', |
||
215 | 'value' => 'border-style-rounded', |
||
216 | 'new' => array( |
||
217 | array ( 'id' => 'theme', 'value' => 'fg-light' ), |
||
218 | array ( 'id' => 'border_size', 'value' => '' ), |
||
219 | array ( 'id' => 'drop_shadow', 'value' => '' ), |
||
220 | array ( 'id' => 'rounded_corners', 'value' => 'fg-round-small' ), |
||
221 | array ( 'id' => 'inner_shadow', 'value' => '' ), |
||
222 | ) |
||
223 | ), |
||
224 | array( |
||
225 | 'id' => 'border-style', |
||
226 | 'value' => '', |
||
227 | 'new' => array( |
||
228 | array ( 'id' => 'theme', 'value' => 'fg-light' ), |
||
229 | array ( 'id' => 'border_size', 'value' => '' ), |
||
230 | array ( 'id' => 'drop_shadow', 'value' => '' ), |
||
231 | array ( 'id' => 'rounded_corners', 'value' => '' ), |
||
232 | array ( 'id' => 'inner_shadow', 'value' => '' ), |
||
233 | ) |
||
234 | ), |
||
235 | |||
236 | array( |
||
237 | 'id' => 'spacing', |
||
238 | 'value' => 'spacing-width-0', |
||
239 | 'new' => array( |
||
240 | array ( 'id' => 'spacing', 'value' => 'fg-gutter-0' ) |
||
241 | ) |
||
242 | ), |
||
243 | array( |
||
244 | 'id' => 'spacing', |
||
245 | 'value' => 'spacing-width-5', |
||
246 | 'new' => array( |
||
247 | array ( 'id' => 'spacing', 'value' => 'fg-gutter-5' ) |
||
248 | ) |
||
249 | ), |
||
250 | array( |
||
251 | 'id' => 'spacing', |
||
252 | 'value' => 'spacing-width-10', |
||
253 | 'new' => array( |
||
254 | array ( 'id' => 'spacing', 'value' => 'fg-gutter-10' ) |
||
255 | ) |
||
256 | ), |
||
257 | array( |
||
258 | 'id' => 'spacing', |
||
259 | 'value' => 'spacing-width-15', |
||
260 | 'new' => array( |
||
261 | array ( 'id' => 'spacing', 'value' => 'fg-gutter-15' ) |
||
262 | ) |
||
263 | ), |
||
264 | array( |
||
265 | 'id' => 'spacing', |
||
266 | 'value' => 'spacing-width-20', |
||
267 | 'new' => array( |
||
268 | array ( 'id' => 'spacing', 'value' => 'fg-gutter-20' ) |
||
269 | ) |
||
270 | ), |
||
271 | array( |
||
272 | 'id' => 'spacing', |
||
273 | 'value' => 'spacing-width-25', |
||
274 | 'new' => array( |
||
275 | array ( 'id' => 'spacing', 'value' => 'fg-gutter-25' ) |
||
276 | ) |
||
277 | ), |
||
278 | |||
279 | array( |
||
280 | 'id' => 'alignment', |
||
281 | 'value' => 'alignment-left', |
||
282 | 'new' => array( |
||
283 | array ( 'id' => 'alignment', 'value' => 'fg-left' ) |
||
284 | ) |
||
285 | ), |
||
286 | array( |
||
287 | 'id' => 'alignment', |
||
288 | 'value' => 'alignment-center', |
||
289 | 'new' => array( |
||
290 | array ( 'id' => 'alignment', 'value' => 'fg-center' ) |
||
291 | ) |
||
292 | ), |
||
293 | array( |
||
294 | 'id' => 'alignment', |
||
295 | 'value' => 'alignment-right', |
||
296 | 'new' => array( |
||
297 | array ( 'id' => 'alignment', 'value' => 'fg-right' ) |
||
298 | ) |
||
299 | ), |
||
300 | |||
301 | array( |
||
302 | 'id' => 'loading_animation', |
||
303 | 'value' => 'yes', |
||
304 | 'new' => array( |
||
305 | array ( 'id' => 'loading_icon', 'value' => 'fg-loading-default' ) |
||
306 | ) |
||
307 | ), |
||
308 | array( |
||
309 | 'id' => 'loading_animation', |
||
310 | 'value' => 'no', |
||
311 | 'new' => array( |
||
312 | array ( 'id' => 'loading_icon', 'value' => 'fg-loading-none' ) |
||
313 | ) |
||
314 | ), |
||
315 | |||
316 | //Icon hover effects |
||
317 | array( |
||
318 | 'id' => 'hover-effect-type', |
||
319 | 'value' => '', //Icon |
||
320 | 'new' => array( |
||
321 | array ( 'id' => 'hover_effect_preset', 'value' => 'fg-custom' ), |
||
322 | array ( 'id' => 'hover_effect_caption_visibility', 'value' => '' ), |
||
323 | array ( 'id' => 'hover_effect_transition', 'value' => 'fg-hover-fade' ), |
||
324 | array ( 'id' => 'hover_effect_icon', 'value' => 'fg-hover-zoom' ), |
||
325 | array ( 'id' => 'caption_title_source', 'value' => 'none' ), |
||
326 | array ( 'id' => 'caption_desc_source', 'value' => 'none' ) |
||
327 | ) |
||
328 | ), |
||
329 | |||
330 | array( |
||
331 | 'id' => 'hover-effect', |
||
332 | 'value' => 'hover-effect-zoom', |
||
333 | 'preconditions' => array ( |
||
334 | array ( 'id' => 'hover-effect-type', 'value' => '' ), |
||
335 | ), |
||
336 | 'new' => array( |
||
337 | array ( 'id' => 'hover_effect_icon', 'value' => 'fg-hover-zoom' ) |
||
338 | ) |
||
339 | ), |
||
340 | |||
341 | array( |
||
342 | 'id' => 'hover-effect', |
||
343 | 'value' => 'hover-effect-zoom2', |
||
344 | 'preconditions' => array ( |
||
345 | array ( 'id' => 'hover-effect-type', 'value' => '' ), |
||
346 | ), |
||
347 | 'new' => array( |
||
348 | array ( 'id' => 'hover_effect_icon', 'value' => 'fg-hover-zoom2' ) |
||
349 | ) |
||
350 | ), |
||
351 | |||
352 | array( |
||
353 | 'id' => 'hover-effect', |
||
354 | 'value' => 'hover-effect-zoom3', |
||
355 | 'preconditions' => array ( |
||
356 | array ( 'id' => 'hover-effect-type', 'value' => '' ), |
||
357 | ), |
||
358 | 'new' => array( |
||
359 | array ( 'id' => 'hover_effect_icon', 'value' => 'fg-hover-zoom3' ) |
||
360 | ) |
||
361 | ), |
||
362 | |||
363 | array( |
||
364 | 'id' => 'hover-effect', |
||
365 | 'value' => 'hover-effect-plus', |
||
366 | 'preconditions' => array ( |
||
367 | array ( 'id' => 'hover-effect-type', 'value' => '' ), |
||
368 | ), |
||
369 | 'new' => array( |
||
370 | array ( 'id' => 'hover_effect_icon', 'value' => 'fg-hover-plus' ) |
||
371 | ) |
||
372 | ), |
||
373 | |||
374 | array( |
||
375 | 'id' => 'hover-effect', |
||
376 | 'value' => 'hover-effect-circle-plus', |
||
377 | 'preconditions' => array ( |
||
378 | array ( 'id' => 'hover-effect-type', 'value' => '' ), |
||
379 | ), |
||
380 | 'new' => array( |
||
381 | array ( 'id' => 'hover_effect_icon', 'value' => 'fg-hover-circle-plus' ) |
||
382 | ) |
||
383 | ), |
||
384 | |||
385 | array( |
||
386 | 'id' => 'hover-effect', |
||
387 | 'value' => 'hover-effect-eye', |
||
388 | 'preconditions' => array ( |
||
389 | array ( 'id' => 'hover-effect-type', 'value' => '' ), |
||
390 | ), |
||
391 | 'new' => array( |
||
392 | array ( 'id' => 'hover_effect_icon', 'value' => 'fg-hover-eye' ) |
||
393 | ) |
||
394 | ), |
||
395 | |||
396 | array( |
||
397 | 'id' => 'hover-effect-type', |
||
398 | 'value' => 'hover-effect-tint', //Dark Tint |
||
399 | 'new' => array( |
||
400 | array ( 'id' => 'hover_effect_preset', 'value' => '' ), |
||
401 | array ( 'id' => 'hover_effect', 'value' => 'fg-hover-tint' ), |
||
402 | array ( 'id' => 'hover_effect_caption_visibility', 'value' => '' ), |
||
403 | ) |
||
404 | ), |
||
405 | |||
406 | array( |
||
407 | 'id' => 'hover-effect-type', |
||
408 | 'value' => 'hover-effect-color', //Colorize |
||
409 | 'new' => array( |
||
410 | array ( 'id' => 'hover_effect_preset', 'value' => '' ), |
||
411 | array ( 'id' => 'hover_effect_color', 'value' => 'fg-hover-colorize' ), |
||
412 | array ( 'id' => 'hover_effect_icon', 'value' => '' ), |
||
413 | array ( 'id' => 'hover_effect_caption_visibility', 'value' => '' ), |
||
414 | ) |
||
415 | ), |
||
416 | |||
417 | array( |
||
418 | 'id' => 'hover-effect-type', |
||
419 | 'value' => 'hover-effect-none', //None |
||
420 | 'new' => array( |
||
421 | array ( 'id' => 'hover_effect_preset', 'value' => '' ), |
||
422 | array ( 'id' => 'hover_effect_icon', 'value' => '' ), |
||
423 | array ( 'id' => 'hover_effect_caption_visibility', 'value' => '' ), |
||
424 | ) |
||
425 | ), |
||
426 | |||
427 | array( |
||
428 | 'id' => 'hover-effect-type', |
||
429 | 'value' => 'hover-effect-caption', //Caption |
||
430 | 'new' => array( |
||
431 | array ( 'id' => 'hover_effect_preset', 'value' => 'fg-custom' ), |
||
432 | array ( 'id' => 'hover_effect_caption_visibility', 'value' => 'fg-caption-hover' ), |
||
433 | array ( 'id' => 'hover_effect_transition', 'value' => 'fg-hover-fade' ), |
||
434 | array ( 'id' => 'hover_effect_icon', 'value' => '' ) |
||
435 | ) |
||
436 | ), |
||
437 | |||
438 | array( |
||
439 | 'id' => 'caption-hover-effect', |
||
440 | 'value' => 'hover-caption-simple', |
||
441 | 'preconditions' => array ( |
||
442 | array ( 'id' => 'hover-effect-type', 'value' => 'hover-effect-caption' ), |
||
443 | ), |
||
444 | 'new' => array( |
||
445 | array ( 'id' => 'hover_effect_transition', 'value' => 'fg-hover-fade' ), |
||
446 | ) |
||
447 | ), |
||
448 | array( |
||
449 | 'id' => 'caption-hover-effect', |
||
450 | 'value' => 'hover-caption-full-drop', |
||
451 | 'preconditions' => array ( |
||
452 | array ( 'id' => 'hover-effect-type', 'value' => 'hover-effect-caption' ), |
||
453 | ), |
||
454 | 'new' => array( |
||
455 | array ( 'id' => 'hover_effect_transition', 'value' => 'fg-hover-slide-down' ), |
||
456 | ) |
||
457 | ), |
||
458 | array( |
||
459 | 'id' => 'caption-hover-effect', |
||
460 | 'value' => 'hover-caption-full-fade', |
||
461 | 'preconditions' => array ( |
||
462 | array ( 'id' => 'hover-effect-type', 'value' => 'hover-effect-caption' ), |
||
463 | ), |
||
464 | 'new' => array( |
||
465 | array ( 'id' => 'hover_effect_transition', 'value' => 'fg-hover-fade' ), |
||
466 | ) |
||
467 | ), |
||
468 | array( |
||
469 | 'id' => 'caption-hover-effect', |
||
470 | 'value' => 'hover-caption-push', |
||
471 | 'preconditions' => array ( |
||
472 | array ( 'id' => 'hover-effect-type', 'value' => 'hover-effect-caption' ), |
||
473 | ), |
||
474 | 'new' => array( |
||
475 | array ( 'id' => 'hover_effect_transition', 'value' => 'fg-hover-push' ), |
||
476 | ) |
||
477 | ), |
||
478 | array( |
||
479 | 'id' => 'caption-hover-effect', |
||
480 | 'value' => 'hover-caption-simple-always', |
||
481 | 'preconditions' => array ( |
||
482 | array ( 'id' => 'hover-effect-type', 'value' => 'hover-effect-caption' ), |
||
483 | ), |
||
484 | 'new' => array( |
||
485 | array ( 'id' => 'hover_effect_caption_visibility', 'value' => 'fg-caption-always' ), |
||
486 | ) |
||
487 | ), |
||
488 | |||
489 | array( |
||
490 | 'id' => 'caption-content', |
||
491 | 'value' => 'title', |
||
492 | 'new' => array( |
||
493 | array ( 'id' => 'caption_title_source', 'value' => '' ), |
||
494 | array ( 'id' => 'caption_desc_source', 'value' => 'none' ) |
||
495 | ) |
||
496 | ), |
||
497 | array( |
||
498 | 'id' => 'caption-content', |
||
499 | 'value' => 'desc', |
||
500 | 'new' => array( |
||
501 | array ( 'id' => 'caption_title_source', 'value' => 'none' ), |
||
502 | array ( 'id' => 'caption_desc_source', 'value' => '' ) |
||
503 | ) |
||
504 | ), |
||
505 | array( |
||
506 | 'id' => 'caption-content', |
||
507 | 'value' => 'both', |
||
508 | 'new' => array( |
||
509 | array ( 'id' => 'caption_title_source', 'value' => '' ), |
||
510 | array ( 'id' => 'caption_desc_source', 'value' => '' ) |
||
511 | ) |
||
512 | ), |
||
513 | |||
514 | //masonry layout mappings |
||
515 | array( |
||
516 | 'id' => 'layout', |
||
517 | 'value' => '2col', |
||
518 | 'new' => array( |
||
519 | array ( 'id' => 'layout', 'value' => 'col2' ) |
||
520 | ) |
||
521 | ), |
||
522 | |||
523 | array( |
||
524 | 'id' => 'layout', |
||
525 | 'value' => '3col', |
||
526 | 'new' => array( |
||
527 | array ( 'id' => 'layout', 'value' => 'col3' ) |
||
528 | ) |
||
529 | ), |
||
530 | |||
531 | array( |
||
532 | 'id' => 'layout', |
||
533 | 'value' => '4col', |
||
534 | 'new' => array( |
||
535 | array ( 'id' => 'layout', 'value' => 'col4' ) |
||
536 | ) |
||
537 | ), |
||
538 | |||
539 | array( |
||
540 | 'id' => 'layout', |
||
541 | 'value' => '5col', |
||
542 | 'new' => array( |
||
543 | array ( 'id' => 'layout', 'value' => 'col5' ) |
||
544 | ) |
||
545 | ), |
||
546 | |||
547 | array( |
||
548 | 'id' => 'gutter_percent', |
||
549 | 'value' => 'no-gutter', |
||
550 | 'new' => array( |
||
551 | array ( 'id' => 'gutter_percent', 'value' => 'fg-gutter-none' ) |
||
552 | ) |
||
553 | ), |
||
554 | |||
555 | array( |
||
556 | 'id' => 'gutter_percent', |
||
557 | 'value' => 'large-gutter', |
||
558 | 'new' => array( |
||
559 | array ( 'id' => 'gutter_percent', 'value' => 'fg-gutter-large' ) |
||
560 | ) |
||
561 | ), |
||
562 | |||
563 | array( |
||
564 | 'id' => 'center_align', |
||
565 | 'value' => 'default', |
||
566 | 'new' => array( |
||
567 | array ( 'id' => 'alignment', 'value' => '' ) |
||
568 | ) |
||
569 | ), |
||
570 | |||
571 | array( |
||
572 | 'id' => 'center_align', |
||
573 | 'value' => 'center', |
||
574 | 'new' => array( |
||
575 | array ( 'id' => 'alignment', 'value' => 'fg-center' ) |
||
576 | ) |
||
577 | ), |
||
578 | |||
579 | array( |
||
580 | 'id' => 'hover_zoom', |
||
581 | 'value' => 'default', |
||
582 | 'new' => array( |
||
583 | array ( 'id' => 'hover_effect_scale', 'value' => 'fg-hover-scale' ) |
||
584 | ) |
||
585 | ), |
||
586 | |||
587 | array( |
||
588 | 'id' => 'hover_zoom', |
||
589 | 'value' => 'none', |
||
590 | 'new' => array( |
||
591 | array ( 'id' => 'hover_effect_scale', 'value' => '' ) |
||
592 | ) |
||
593 | ), |
||
594 | |||
595 | |||
596 | //image viewer upgrades |
||
597 | array( |
||
598 | 'id' => 'theme', |
||
599 | 'value' => 'fiv-dark', |
||
600 | 'new' => array( |
||
601 | array ( 'id' => 'theme', 'value' => 'fg-dark' ) |
||
602 | ) |
||
603 | ), |
||
604 | array( |
||
605 | 'id' => 'theme', |
||
606 | 'value' => '', |
||
607 | 'new' => array( |
||
608 | array ( 'id' => 'theme', 'value' => 'fg-light' ) |
||
609 | ) |
||
610 | ), |
||
611 | array( |
||
612 | 'id' => 'theme', |
||
613 | 'value' => 'fiv-custom', |
||
614 | 'new' => array( |
||
615 | array ( 'id' => 'theme', 'value' => 'fg-light' ) |
||
616 | ) |
||
617 | ), |
||
618 | |||
619 | array( |
||
620 | 'id' => 'alignment', |
||
621 | 'value' => 'alignment-left', |
||
622 | 'new' => array( |
||
623 | array ( 'id' => 'alignment', 'value' => 'fg-left' ) |
||
624 | ) |
||
625 | ), |
||
626 | array( |
||
627 | 'id' => 'alignment', |
||
628 | 'value' => 'alignment-center', |
||
629 | 'new' => array( |
||
630 | array ( 'id' => 'alignment', 'value' => 'fg-center' ) |
||
631 | ) |
||
632 | ), |
||
633 | array( |
||
634 | 'id' => 'alignment', |
||
635 | 'value' => 'alignment-right', |
||
636 | 'new' => array( |
||
637 | array ( 'id' => 'alignment', 'value' => 'fg-right' ) |
||
638 | ) |
||
639 | ), |
||
640 | |||
641 | //simple portfolio |
||
642 | array( |
||
643 | 'id' => 'caption_position', |
||
644 | 'value' => 'bf-captions-above', |
||
645 | 'new' => array( |
||
646 | array ( 'id' => 'caption_position', 'value' => 'fg-captions-top' ) |
||
647 | ) |
||
648 | ), |
||
649 | |||
650 | //single thumbnail |
||
651 | array( |
||
652 | 'id' => 'caption_style', |
||
653 | 'value' => 'caption-simple', |
||
654 | 'new' => array( |
||
655 | array ( 'id' => 'hover_effect_preset', 'value' => 'fg-custom' ), |
||
656 | array ( 'id' => 'hover_effect_caption_visibility', 'value' => 'fg-caption-always' ) |
||
657 | ) |
||
658 | ), |
||
659 | array( |
||
660 | 'id' => 'caption_style', |
||
661 | 'value' => 'caption-slideup', |
||
662 | 'new' => array( |
||
663 | array ( 'id' => 'hover_effect_preset', 'value' => 'fg-custom' ), |
||
664 | array ( 'id' => 'hover_effect_caption_visibility', 'value' => 'fg-caption-hover' ), |
||
665 | array ( 'id' => 'hover_effect_transition', 'value' => 'fg-hover-slide-up' ), |
||
666 | ) |
||
667 | ), |
||
668 | |||
669 | array( |
||
670 | 'id' => 'caption_style', |
||
671 | 'value' => 'caption-fall', |
||
672 | 'new' => array( |
||
673 | array ( 'id' => 'hover_effect_preset', 'value' => 'fg-custom' ), |
||
674 | array ( 'id' => 'hover_effect_caption_visibility', 'value' => 'fg-caption-hover' ), |
||
675 | array ( 'id' => 'hover_effect_transition', 'value' => 'fg-hover-slide-down' ), |
||
676 | ) |
||
677 | ), |
||
678 | array( |
||
679 | 'id' => 'caption_style', |
||
680 | 'value' => 'caption-fade', |
||
681 | 'new' => array( |
||
682 | array ( 'id' => 'hover_effect_preset', 'value' => 'fg-custom' ), |
||
683 | array ( 'id' => 'hover_effect_caption_visibility', 'value' => 'fg-caption-hover' ), |
||
684 | array ( 'id' => 'hover_effect_transition', 'value' => 'fg-hover-fade' ), |
||
685 | ) |
||
686 | ), |
||
687 | array( |
||
688 | 'id' => 'caption_style', |
||
689 | 'value' => 'caption-push', |
||
690 | 'new' => array( |
||
691 | array ( 'id' => 'hover_effect_preset', 'value' => 'fg-custom' ), |
||
692 | array ( 'id' => 'hover_effect_caption_visibility', 'value' => 'fg-caption-hover' ), |
||
693 | array ( 'id' => 'hover_effect_transition', 'value' => 'fg-hover-push' ), |
||
694 | ) |
||
695 | ), |
||
696 | array( |
||
697 | 'id' => 'caption_style', |
||
698 | 'value' => 'caption-scale', |
||
699 | 'new' => array( |
||
700 | array ( 'id' => 'hover_effect_preset', 'value' => 'fg-custom' ), |
||
701 | array ( 'id' => 'hover_effect_caption_visibility', 'value' => 'fg-caption-hover' ), |
||
702 | array ( 'id' => 'hover_effect_transition', 'value' => 'fg-hover-slide-left' ), |
||
703 | ) |
||
704 | ), |
||
705 | |||
706 | //single thumbnail gallery |
||
707 | array( |
||
708 | 'id' => 'position', |
||
709 | 'value' => 'position-block', |
||
710 | 'new' => array( |
||
711 | array ( 'id' => 'position', 'value' => 'fg-center' ), |
||
712 | ) |
||
713 | ), |
||
714 | array( |
||
715 | 'id' => 'position', |
||
716 | 'value' => 'position-float-left', |
||
717 | 'new' => array( |
||
718 | array ( 'id' => 'position', 'value' => 'fg-left' ), |
||
719 | ) |
||
720 | ), |
||
721 | array( |
||
722 | 'id' => 'position', |
||
723 | 'value' => 'position-float-right', |
||
724 | 'new' => array( |
||
725 | array ( 'id' => 'position', 'value' => 'fg-right' ), |
||
726 | ) |
||
727 | ), |
||
728 | |||
729 | ); |
||
730 | |||
731 | $old_settings = get_post_meta( $foogallery->ID, FOOGALLERY_META_SETTINGS_OLD, true ); |
||
732 | |||
733 | if ( empty( $old_settings ) ) { |
||
734 | return $old_settings; |
||
735 | } |
||
736 | |||
737 | //start with the old settings |
||
738 | $new_settings = $old_settings; |
||
739 | |||
740 | //upgrade all template settings |
||
741 | foreach ( foogallery_gallery_templates() as $template ) { |
||
742 | |||
743 | foreach ( $mappings as $mapping ) { |
||
744 | |||
745 | $settings_key = "{$template['slug']}_{$mapping['id']}"; |
||
746 | |||
747 | //check if the settings exists |
||
748 | if ( array_key_exists( $settings_key, $old_settings ) ) { |
||
749 | |||
750 | $old_settings_value = $old_settings[$settings_key]; |
||
751 | |||
752 | if ( $mapping['value'] === $old_settings_value ) { |
||
753 | //we have found a match! |
||
754 | |||
755 | $add_settings = true; |
||
756 | |||
757 | //check if we have any preconditions |
||
758 | if ( isset( $mapping['preconditions'] ) ) { |
||
759 | $add_settings = false; |
||
760 | foreach ($mapping['preconditions'] as $precondition) { |
||
761 | $precondition_setting_key = "{$template['slug']}_{$precondition['id']}"; |
||
762 | $precondition_setting_value = $precondition['value']; |
||
763 | |||
764 | if ( array_key_exists( $precondition_setting_key, $old_settings ) && |
||
765 | $precondition_setting_value === $old_settings[$precondition_setting_key] ) { |
||
766 | //we have found a precondition match |
||
767 | $add_settings = true; |
||
768 | } |
||
769 | } |
||
770 | } |
||
771 | |||
772 | if ( $add_settings ) { |
||
773 | foreach ($mapping['new'] as $setting_to_create) { |
||
774 | $new_setting_key = "{$template['slug']}_{$setting_to_create['id']}"; |
||
775 | $new_setting_value = $setting_to_create['value']; |
||
776 | $new_settings[$new_setting_key] = $new_setting_value; |
||
777 | } |
||
778 | } |
||
779 | } |
||
780 | } |
||
781 | } |
||
782 | } |
||
783 | |||
784 | //template specific settings overrides |
||
785 | if ( 'image-viewer' === $foogallery->gallery_template ) { |
||
786 | $new_settings['image-viewer_border_size'] = 'fg-border-thin'; |
||
787 | $new_settings['image-viewer_drop_shadow'] = 'fg-shadow-outline'; |
||
788 | $new_settings['image-viewer_rounded_corners'] = ''; |
||
789 | $new_settings['image-viewer_inner_shadow'] = ''; |
||
790 | $new_settings['image-viewer_hover_effect_caption_visibility'] = 'fg-caption-always'; |
||
791 | } |
||
792 | |||
793 | if ( 'justified' === $foogallery->gallery_template ) { |
||
794 | $new_settings['justified_theme'] = 'fg-light'; |
||
795 | $new_settings['justified_border_size'] = ''; |
||
796 | $new_settings['justified_drop_shadow'] = ''; |
||
797 | $new_settings['justified_rounded_corners'] = ''; |
||
798 | $new_settings['justified_inner_shadow'] = ''; |
||
799 | $new_settings['justified_hover_effect_preset'] = 'fg-custom'; |
||
800 | $new_settings['justified_hover_effect_icon'] = ''; |
||
801 | $new_settings['justified_hover_effect_caption_visibility'] = ''; |
||
802 | } |
||
803 | |||
804 | if ( 'masonry' === $foogallery->gallery_template ) { |
||
805 | $new_settings['masonry_theme'] = 'fg-light'; |
||
806 | $new_settings['masonry_border_size'] = ''; |
||
807 | $new_settings['masonry_drop_shadow'] = ''; |
||
808 | $new_settings['masonry_rounded_corners'] = ''; |
||
809 | $new_settings['masonry_inner_shadow'] = ''; |
||
810 | $new_settings['masonry_hover_effect_preset'] = 'fg-custom'; |
||
811 | $new_settings['masonry_hover_effect_icon'] = ''; |
||
812 | $new_settings['masonry_hover_effect_caption_visibility'] = ''; |
||
813 | } |
||
814 | |||
815 | if ( 'simple_portfolio' === $foogallery->gallery_template ) { |
||
816 | $new_settings['simple_portfolio_theme'] = 'fg-light'; |
||
817 | $new_settings['simple_portfolio_border_size'] = ''; |
||
818 | $new_settings['simple_portfolio_drop_shadow'] = ''; |
||
819 | $new_settings['simple_portfolio_rounded_corners'] = ''; |
||
820 | $new_settings['simple_portfolio_inner_shadow'] = ''; |
||
821 | $new_settings['simple_portfolio_hover_effect_preset'] = ''; |
||
822 | } |
||
823 | |||
824 | return $new_settings; |
||
825 | } |
||
826 | } |
||
827 | } |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.