| Conditions | 11 |
| Paths | 49 |
| Total Lines | 631 |
| Code Lines | 433 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 22 | function perform_gallery_settings_upgrade( $foogallery ) { |
||
| 23 | |||
| 24 | $mappings = array( |
||
| 25 | array( |
||
| 26 | 'id' => 'border-style', |
||
| 27 | 'value' => 'border-style-square-white', |
||
| 28 | 'new' => array( |
||
| 29 | array ( 'id' => 'theme', 'value' => 'fg-light' ), |
||
| 30 | array ( 'id' => 'border_size', 'value' => 'fg-border-thin' ), |
||
| 31 | array ( 'id' => 'drop_shadow', 'value' => 'fg-shadow-small' ), |
||
| 32 | array ( 'id' => 'rounded_corners', 'value' => '' ), |
||
| 33 | array ( 'id' => 'inner_shadow', 'value' => '' ), |
||
| 34 | ) |
||
| 35 | ), |
||
| 36 | array( |
||
| 37 | 'id' => 'border-style', |
||
| 38 | 'value' => 'border-style-circle-white', |
||
| 39 | 'new' => array( |
||
| 40 | array ( 'id' => 'theme', 'value' => 'fg-light' ), |
||
| 41 | array ( 'id' => 'border_size', 'value' => 'fg-border-thin' ), |
||
| 42 | array ( 'id' => 'drop_shadow', 'value' => 'fg-shadow-small' ), |
||
| 43 | array ( 'id' => 'rounded_corners', 'value' => 'fg-round-full' ), |
||
| 44 | array ( 'id' => 'inner_shadow', 'value' => '' ), |
||
| 45 | ) |
||
| 46 | ), |
||
| 47 | array( |
||
| 48 | 'id' => 'border-style', |
||
| 49 | 'value' => 'border-style-square-black', |
||
| 50 | 'new' => array( |
||
| 51 | array ( 'id' => 'theme', 'value' => 'fg-dark' ), |
||
| 52 | array ( 'id' => 'border_size', 'value' => 'fg-border-thin' ), |
||
| 53 | array ( 'id' => 'drop_shadow', 'value' => 'fg-shadow-small' ), |
||
| 54 | array ( 'id' => 'rounded_corners', 'value' => '' ), |
||
| 55 | array ( 'id' => 'inner_shadow', 'value' => '' ), |
||
| 56 | ) |
||
| 57 | ), |
||
| 58 | array( |
||
| 59 | 'id' => 'border-style', |
||
| 60 | 'value' => 'border-style-circle-black', |
||
| 61 | 'new' => array( |
||
| 62 | array ( 'id' => 'theme', 'value' => 'fg-dark' ), |
||
| 63 | array ( 'id' => 'border_size', 'value' => 'fg-border-thin' ), |
||
| 64 | array ( 'id' => 'drop_shadow', 'value' => 'fg-shadow-small' ), |
||
| 65 | array ( 'id' => 'rounded_corners', 'value' => 'fg-round-full' ), |
||
| 66 | array ( 'id' => 'inner_shadow', 'value' => '' ), |
||
| 67 | ) |
||
| 68 | ), |
||
| 69 | array( |
||
| 70 | 'id' => 'border-style', |
||
| 71 | 'value' => 'border-style-inset', |
||
| 72 | 'new' => array( |
||
| 73 | array ( 'id' => 'theme', 'value' => 'fg-light' ), |
||
| 74 | array ( 'id' => 'border_size', 'value' => '' ), |
||
| 75 | array ( 'id' => 'drop_shadow', 'value' => 'fg-shadow-small' ), |
||
| 76 | array ( 'id' => 'rounded_corners', 'value' => '' ), |
||
| 77 | array ( 'id' => 'inner_shadow', 'value' => 'fg-shadow-inset-large' ), |
||
| 78 | ) |
||
| 79 | ), |
||
| 80 | array( |
||
| 81 | 'id' => 'border-style', |
||
| 82 | 'value' => 'border-style-rounded', |
||
| 83 | 'new' => array( |
||
| 84 | array ( 'id' => 'theme', 'value' => 'fg-light' ), |
||
| 85 | array ( 'id' => 'border_size', 'value' => '' ), |
||
| 86 | array ( 'id' => 'drop_shadow', 'value' => '' ), |
||
| 87 | array ( 'id' => 'rounded_corners', 'value' => 'fg-round-small' ), |
||
| 88 | array ( 'id' => 'inner_shadow', 'value' => '' ), |
||
| 89 | ) |
||
| 90 | ), |
||
| 91 | array( |
||
| 92 | 'id' => 'border-style', |
||
| 93 | 'value' => '', |
||
| 94 | 'new' => array( |
||
| 95 | array ( 'id' => 'theme', 'value' => 'fg-light' ), |
||
| 96 | array ( 'id' => 'border_size', 'value' => '' ), |
||
| 97 | array ( 'id' => 'drop_shadow', 'value' => '' ), |
||
| 98 | array ( 'id' => 'rounded_corners', 'value' => '' ), |
||
| 99 | array ( 'id' => 'inner_shadow', 'value' => '' ), |
||
| 100 | ) |
||
| 101 | ), |
||
| 102 | |||
| 103 | array( |
||
| 104 | 'id' => 'spacing', |
||
| 105 | 'value' => 'spacing-width-0', |
||
| 106 | 'new' => array( |
||
| 107 | array ( 'id' => 'spacing', 'value' => 'fg-gutter-0' ) |
||
| 108 | ) |
||
| 109 | ), |
||
| 110 | array( |
||
| 111 | 'id' => 'spacing', |
||
| 112 | 'value' => 'spacing-width-5', |
||
| 113 | 'new' => array( |
||
| 114 | array ( 'id' => 'spacing', 'value' => 'fg-gutter-5' ) |
||
| 115 | ) |
||
| 116 | ), |
||
| 117 | array( |
||
| 118 | 'id' => 'spacing', |
||
| 119 | 'value' => 'spacing-width-10', |
||
| 120 | 'new' => array( |
||
| 121 | array ( 'id' => 'spacing', 'value' => 'fg-gutter-10' ) |
||
| 122 | ) |
||
| 123 | ), |
||
| 124 | array( |
||
| 125 | 'id' => 'spacing', |
||
| 126 | 'value' => 'spacing-width-15', |
||
| 127 | 'new' => array( |
||
| 128 | array ( 'id' => 'spacing', 'value' => 'fg-gutter-15' ) |
||
| 129 | ) |
||
| 130 | ), |
||
| 131 | array( |
||
| 132 | 'id' => 'spacing', |
||
| 133 | 'value' => 'spacing-width-20', |
||
| 134 | 'new' => array( |
||
| 135 | array ( 'id' => 'spacing', 'value' => 'fg-gutter-20' ) |
||
| 136 | ) |
||
| 137 | ), |
||
| 138 | array( |
||
| 139 | 'id' => 'spacing', |
||
| 140 | 'value' => 'spacing-width-25', |
||
| 141 | 'new' => array( |
||
| 142 | array ( 'id' => 'spacing', 'value' => 'fg-gutter-25' ) |
||
| 143 | ) |
||
| 144 | ), |
||
| 145 | |||
| 146 | array( |
||
| 147 | 'id' => 'alignment', |
||
| 148 | 'value' => 'alignment-left', |
||
| 149 | 'new' => array( |
||
| 150 | array ( 'id' => 'alignment', 'value' => 'fg-left' ) |
||
| 151 | ) |
||
| 152 | ), |
||
| 153 | array( |
||
| 154 | 'id' => 'alignment', |
||
| 155 | 'value' => 'alignment-center', |
||
| 156 | 'new' => array( |
||
| 157 | array ( 'id' => 'alignment', 'value' => 'fg-center' ) |
||
| 158 | ) |
||
| 159 | ), |
||
| 160 | array( |
||
| 161 | 'id' => 'alignment', |
||
| 162 | 'value' => 'alignment-right', |
||
| 163 | 'new' => array( |
||
| 164 | array ( 'id' => 'alignment', 'value' => 'fg-right' ) |
||
| 165 | ) |
||
| 166 | ), |
||
| 167 | |||
| 168 | array( |
||
| 169 | 'id' => 'loading_animation', |
||
| 170 | 'value' => 'yes', |
||
| 171 | 'new' => array( |
||
| 172 | array ( 'id' => 'loading_icon', 'value' => 'fg-loading-default' ) |
||
| 173 | ) |
||
| 174 | ), |
||
| 175 | array( |
||
| 176 | 'id' => 'loading_animation', |
||
| 177 | 'value' => 'no', |
||
| 178 | 'new' => array( |
||
| 179 | array ( 'id' => 'loading_icon', 'value' => 'fg-loading-none' ) |
||
| 180 | ) |
||
| 181 | ), |
||
| 182 | |||
| 183 | |||
| 184 | array( |
||
| 185 | 'id' => 'hover-effect-type', |
||
| 186 | 'value' => '', //Icon |
||
| 187 | 'new' => array( |
||
| 188 | array ( 'id' => 'hover_effect_preset', 'value' => 'fg-custom' ), |
||
| 189 | array ( 'id' => 'hover_effect_caption_visibility', 'value' => 'fg-caption-hover' ), |
||
| 190 | array ( 'id' => 'hover_effect_transition', 'value' => 'fg-hover-fade' ), |
||
| 191 | array ( 'id' => 'hover_effect_icon', 'value' => 'fg-hover-zoom' ), |
||
| 192 | array ( 'id' => 'caption_title', 'value' => 'none' ), |
||
| 193 | array ( 'id' => 'caption_desc', 'value' => 'none' ) |
||
| 194 | ) |
||
| 195 | ), |
||
| 196 | |||
| 197 | array( |
||
| 198 | 'id' => 'hover-effect-type', |
||
| 199 | 'value' => 'hover-effect-tint', //Dark Tint |
||
| 200 | 'new' => array( |
||
| 201 | array ( 'id' => 'hover_effect_preset', 'value' => '' ), |
||
| 202 | array ( 'id' => 'hover_effect', 'value' => 'fg-hover-tint' ) |
||
| 203 | ) |
||
| 204 | ), |
||
| 205 | |||
| 206 | array( |
||
| 207 | 'id' => 'hover-effect-type', |
||
| 208 | 'value' => 'hover-effect-color', //Colorize |
||
| 209 | 'new' => array( |
||
| 210 | array ( 'id' => 'hover_effect_preset', 'value' => '' ), |
||
| 211 | array ( 'id' => 'hover_effect_color', 'value' => 'fg-hover-colorize' ) |
||
| 212 | ) |
||
| 213 | ), |
||
| 214 | |||
| 215 | array( |
||
| 216 | 'id' => 'hover-effect-type', |
||
| 217 | 'value' => 'hover-effect-none', //None |
||
| 218 | 'new' => array( |
||
| 219 | array ( 'id' => 'hover_effect_preset', 'value' => '' ) |
||
| 220 | ) |
||
| 221 | ), |
||
| 222 | |||
| 223 | array( |
||
| 224 | 'id' => 'hover-effect-type', |
||
| 225 | 'value' => 'hover-effect-caption', //Caption |
||
| 226 | 'new' => array( |
||
| 227 | array ( 'id' => 'hover_effect_preset', 'value' => 'fg-custom' ), |
||
| 228 | array ( 'id' => 'hover_effect_caption_visibility', 'value' => 'fg-caption-hover' ), |
||
| 229 | array ( 'id' => 'hover_effect_transition', 'value' => 'fg-hover-fade' ), |
||
| 230 | ) |
||
| 231 | ), |
||
| 232 | |||
| 233 | array( |
||
| 234 | 'id' => 'hover-effect', |
||
| 235 | 'value' => 'hover-effect-zoom', |
||
| 236 | 'new' => array( |
||
| 237 | array ( 'id' => 'hover_effect_preset', 'value' => 'fg-custom' ), |
||
| 238 | array ( 'id' => 'hover_effect_caption_visibility', 'value' => 'fg-caption-hover' ), |
||
| 239 | array ( 'id' => 'hover_effect_transition', 'value' => 'fg-hover-fade' ), |
||
| 240 | array ( 'id' => 'hover_effect_icon', 'value' => 'fg-hover-zoom' ) |
||
| 241 | ) |
||
| 242 | ), |
||
| 243 | |||
| 244 | array( |
||
| 245 | 'id' => 'hover-effect', |
||
| 246 | 'value' => 'hover-effect-zoom2', |
||
| 247 | 'new' => array( |
||
| 248 | array ( 'id' => 'hover_effect_preset', 'value' => 'fg-custom' ), |
||
| 249 | array ( 'id' => 'hover_effect_caption_visibility', 'value' => 'fg-caption-hover' ), |
||
| 250 | array ( 'id' => 'hover_effect_transition', 'value' => 'fg-hover-fade' ), |
||
| 251 | array ( 'id' => 'hover_effect_icon', 'value' => 'fg-hover-zoom2' ) |
||
| 252 | ) |
||
| 253 | ), |
||
| 254 | |||
| 255 | array( |
||
| 256 | 'id' => 'hover-effect', |
||
| 257 | 'value' => 'hover-effect-zoom3', |
||
| 258 | 'new' => array( |
||
| 259 | array ( 'id' => 'hover_effect_preset', 'value' => 'fg-custom' ), |
||
| 260 | array ( 'id' => 'hover_effect_caption_visibility', 'value' => 'fg-caption-hover' ), |
||
| 261 | array ( 'id' => 'hover_effect_transition', 'value' => 'fg-hover-fade' ), |
||
| 262 | array ( 'id' => 'hover_effect_icon', 'value' => 'fg-hover-zoom3' ) |
||
| 263 | ) |
||
| 264 | ), |
||
| 265 | |||
| 266 | array( |
||
| 267 | 'id' => 'hover-effect', |
||
| 268 | 'value' => 'hover-effect-plus', |
||
| 269 | 'new' => array( |
||
| 270 | array ( 'id' => 'hover_effect_preset', 'value' => 'fg-custom' ), |
||
| 271 | array ( 'id' => 'hover_effect_caption_visibility', 'value' => 'fg-caption-hover' ), |
||
| 272 | array ( 'id' => 'hover_effect_transition', 'value' => 'fg-hover-fade' ), |
||
| 273 | array ( 'id' => 'hover_effect_icon', 'value' => 'fg-hover-plus' ) |
||
| 274 | ) |
||
| 275 | ), |
||
| 276 | |||
| 277 | array( |
||
| 278 | 'id' => 'hover-effect', |
||
| 279 | 'value' => 'hover-effect-circle-plus', |
||
| 280 | 'new' => array( |
||
| 281 | array ( 'id' => 'hover_effect_preset', 'value' => 'fg-custom' ), |
||
| 282 | array ( 'id' => 'hover_effect_caption_visibility', 'value' => 'fg-caption-hover' ), |
||
| 283 | array ( 'id' => 'hover_effect_transition', 'value' => 'fg-hover-fade' ), |
||
| 284 | array ( 'id' => 'hover_effect_icon', 'value' => 'fg-hover-circle-plus' ) |
||
| 285 | ) |
||
| 286 | ), |
||
| 287 | |||
| 288 | array( |
||
| 289 | 'id' => 'hover-effect', |
||
| 290 | 'value' => 'hover-effect-eye', |
||
| 291 | 'new' => array( |
||
| 292 | array ( 'id' => 'hover_effect_preset', 'value' => 'fg-custom' ), |
||
| 293 | array ( 'id' => 'hover_effect_caption_visibility', 'value' => 'fg-caption-hover' ), |
||
| 294 | array ( 'id' => 'hover_effect_transition', 'value' => 'fg-hover-fade' ), |
||
| 295 | array ( 'id' => 'hover_effect_icon', 'value' => 'fg-hover-eye' ) |
||
| 296 | ) |
||
| 297 | ), |
||
| 298 | |||
| 299 | array( |
||
| 300 | 'id' => 'caption-hover-effect', |
||
| 301 | 'value' => 'hover-caption-simple', |
||
| 302 | 'new' => array( |
||
| 303 | array ( 'id' => 'hover_effect_preset', 'value' => 'fg-custom' ), |
||
| 304 | array ( 'id' => 'hover_effect_caption_visibility', 'value' => 'fg-caption-hover' ), |
||
| 305 | array ( 'id' => 'hover_effect_transition', 'value' => 'fg-hover-fade' ), |
||
| 306 | array ( 'id' => 'hover_effect_icon', 'value' => '' ) |
||
| 307 | ) |
||
| 308 | ), |
||
| 309 | array( |
||
| 310 | 'id' => 'caption-hover-effect', |
||
| 311 | 'value' => 'hover-caption-full-drop', |
||
| 312 | 'new' => array( |
||
| 313 | array ( 'id' => 'hover_effect_preset', 'value' => 'fg-custom' ), |
||
| 314 | array ( 'id' => 'hover_effect_caption_visibility', 'value' => 'fg-caption-hover' ), |
||
| 315 | array ( 'id' => 'hover_effect_transition', 'value' => 'fg-hover-slide-down' ), |
||
| 316 | array ( 'id' => 'hover_effect_icon', 'value' => '' ) |
||
| 317 | ) |
||
| 318 | ), |
||
| 319 | array( |
||
| 320 | 'id' => 'caption-hover-effect', |
||
| 321 | 'value' => 'hover-caption-full-fade', |
||
| 322 | 'new' => array( |
||
| 323 | array ( 'id' => 'hover_effect_preset', 'value' => 'fg-custom' ), |
||
| 324 | array ( 'id' => 'hover_effect_caption_visibility', 'value' => 'fg-caption-hover' ), |
||
| 325 | array ( 'id' => 'hover_effect_transition', 'value' => 'fg-hover-fade' ), |
||
| 326 | array ( 'id' => 'hover_effect_icon', 'value' => '' ) |
||
| 327 | ) |
||
| 328 | ), |
||
| 329 | array( |
||
| 330 | 'id' => 'caption-hover-effect', |
||
| 331 | 'value' => 'hover-caption-push', |
||
| 332 | 'new' => array( |
||
| 333 | array ( 'id' => 'hover_effect_preset', 'value' => 'fg-custom' ), |
||
| 334 | array ( 'id' => 'hover_effect_caption_visibility', 'value' => 'fg-caption-hover' ), |
||
| 335 | array ( 'id' => 'hover_effect_transition', 'value' => 'fg-hover-push' ), |
||
| 336 | array ( 'id' => 'hover_effect_icon', 'value' => '' ) |
||
| 337 | ) |
||
| 338 | ), |
||
| 339 | array( |
||
| 340 | 'id' => 'caption-hover-effect', |
||
| 341 | 'value' => 'hover-caption-simple-always', |
||
| 342 | 'new' => array( |
||
| 343 | array ( 'id' => 'hover_effect_preset', 'value' => 'fg-custom' ), |
||
| 344 | array ( 'id' => 'hover_effect_caption_visibility', 'value' => 'fg-caption-always' ), |
||
| 345 | array ( 'id' => 'hover_effect_icon', 'value' => '' ) |
||
| 346 | ) |
||
| 347 | ), |
||
| 348 | |||
| 349 | array( |
||
| 350 | 'id' => 'caption-content', |
||
| 351 | 'value' => 'title', |
||
| 352 | 'new' => array( |
||
| 353 | array ( 'id' => 'caption_title', 'value' => '' ), |
||
| 354 | array ( 'id' => 'caption_desc', 'value' => 'none' ) |
||
| 355 | ) |
||
| 356 | ), |
||
| 357 | array( |
||
| 358 | 'id' => 'caption-content', |
||
| 359 | 'value' => 'desc', |
||
| 360 | 'new' => array( |
||
| 361 | array ( 'id' => 'caption_title', 'value' => 'none' ), |
||
| 362 | array ( 'id' => 'caption_desc', 'value' => '' ) |
||
| 363 | ) |
||
| 364 | ), |
||
| 365 | array( |
||
| 366 | 'id' => 'caption-content', |
||
| 367 | 'value' => 'both', |
||
| 368 | 'new' => array( |
||
| 369 | array ( 'id' => 'caption_title', 'value' => '' ), |
||
| 370 | array ( 'id' => 'caption_desc', 'value' => '' ) |
||
| 371 | ) |
||
| 372 | ), |
||
| 373 | |||
| 374 | //masonry layout mappings |
||
| 375 | array( |
||
| 376 | 'id' => 'layout', |
||
| 377 | 'value' => '2col', |
||
| 378 | 'new' => array( |
||
| 379 | array ( 'id' => 'layout', 'value' => 'col2' ) |
||
| 380 | ) |
||
| 381 | ), |
||
| 382 | |||
| 383 | array( |
||
| 384 | 'id' => 'layout', |
||
| 385 | 'value' => '3col', |
||
| 386 | 'new' => array( |
||
| 387 | array ( 'id' => 'layout', 'value' => 'col3' ) |
||
| 388 | ) |
||
| 389 | ), |
||
| 390 | |||
| 391 | array( |
||
| 392 | 'id' => 'layout', |
||
| 393 | 'value' => '4col', |
||
| 394 | 'new' => array( |
||
| 395 | array ( 'id' => 'layout', 'value' => 'col4' ) |
||
| 396 | ) |
||
| 397 | ), |
||
| 398 | |||
| 399 | array( |
||
| 400 | 'id' => 'layout', |
||
| 401 | 'value' => '5col', |
||
| 402 | 'new' => array( |
||
| 403 | array ( 'id' => 'layout', 'value' => 'col5' ) |
||
| 404 | ) |
||
| 405 | ), |
||
| 406 | |||
| 407 | array( |
||
| 408 | 'id' => 'gutter_percent', |
||
| 409 | 'value' => 'no-gutter', |
||
| 410 | 'new' => array( |
||
| 411 | array ( 'id' => 'gutter_percent', 'value' => 'fg-gutter-none' ) |
||
| 412 | ) |
||
| 413 | ), |
||
| 414 | |||
| 415 | array( |
||
| 416 | 'id' => 'gutter_percent', |
||
| 417 | 'value' => 'large-gutter', |
||
| 418 | 'new' => array( |
||
| 419 | array ( 'id' => 'gutter_percent', 'value' => 'fg-gutter-large' ) |
||
| 420 | ) |
||
| 421 | ), |
||
| 422 | |||
| 423 | array( |
||
| 424 | 'id' => 'center_align', |
||
| 425 | 'value' => 'default', |
||
| 426 | 'new' => array( |
||
| 427 | array ( 'id' => 'alignment', 'value' => '' ) |
||
| 428 | ) |
||
| 429 | ), |
||
| 430 | |||
| 431 | array( |
||
| 432 | 'id' => 'center_align', |
||
| 433 | 'value' => 'center', |
||
| 434 | 'new' => array( |
||
| 435 | array ( 'id' => 'alignment', 'value' => 'fg-center' ) |
||
| 436 | ) |
||
| 437 | ), |
||
| 438 | |||
| 439 | array( |
||
| 440 | 'id' => 'hover_zoom', |
||
| 441 | 'value' => 'default', |
||
| 442 | 'new' => array( |
||
| 443 | array ( 'id' => 'hover_effect_scale', 'value' => 'fg-hover-scale' ) |
||
| 444 | ) |
||
| 445 | ), |
||
| 446 | |||
| 447 | array( |
||
| 448 | 'id' => 'hover_zoom', |
||
| 449 | 'value' => 'none', |
||
| 450 | 'new' => array( |
||
| 451 | array ( 'id' => 'hover_effect_scale', 'value' => '' ) |
||
| 452 | ) |
||
| 453 | ), |
||
| 454 | |||
| 455 | |||
| 456 | //image viewer upgrades |
||
| 457 | array( |
||
| 458 | 'id' => 'theme', |
||
| 459 | 'value' => 'fiv-dark', |
||
| 460 | 'new' => array( |
||
| 461 | array ( 'id' => 'theme', 'value' => 'fg-dark' ) |
||
| 462 | ) |
||
| 463 | ), |
||
| 464 | array( |
||
| 465 | 'id' => 'theme', |
||
| 466 | 'value' => '', |
||
| 467 | 'new' => array( |
||
| 468 | array ( 'id' => 'theme', 'value' => 'fg-light' ) |
||
| 469 | ) |
||
| 470 | ), |
||
| 471 | array( |
||
| 472 | 'id' => 'theme', |
||
| 473 | 'value' => 'fiv-custom', |
||
| 474 | 'new' => array( |
||
| 475 | array ( 'id' => 'theme', 'value' => 'fg-light' ) |
||
| 476 | ) |
||
| 477 | ), |
||
| 478 | |||
| 479 | array( |
||
| 480 | 'id' => 'alignment', |
||
| 481 | 'value' => 'alignment-left', |
||
| 482 | 'new' => array( |
||
| 483 | array ( 'id' => 'alignment', 'value' => 'fg-left' ) |
||
| 484 | ) |
||
| 485 | ), |
||
| 486 | array( |
||
| 487 | 'id' => 'alignment', |
||
| 488 | 'value' => 'alignment-center', |
||
| 489 | 'new' => array( |
||
| 490 | array ( 'id' => 'alignment', 'value' => 'fg-center' ) |
||
| 491 | ) |
||
| 492 | ), |
||
| 493 | array( |
||
| 494 | 'id' => 'alignment', |
||
| 495 | 'value' => 'alignment-right', |
||
| 496 | 'new' => array( |
||
| 497 | array ( 'id' => 'alignment', 'value' => 'fg-right' ) |
||
| 498 | ) |
||
| 499 | ), |
||
| 500 | |||
| 501 | //simple portfolio |
||
| 502 | array( |
||
| 503 | 'id' => 'caption_position', |
||
| 504 | 'value' => 'bf-captions-above', |
||
| 505 | 'new' => array( |
||
| 506 | array ( 'id' => 'caption_position', 'value' => 'fg-captions-top' ) |
||
| 507 | ) |
||
| 508 | ), |
||
| 509 | |||
| 510 | //single thumbnail |
||
| 511 | array( |
||
| 512 | 'id' => 'caption_style', |
||
| 513 | 'value' => 'caption-simple', |
||
| 514 | 'new' => array( |
||
| 515 | array ( 'id' => 'hover_effect_preset', 'value' => 'fg-custom' ), |
||
| 516 | array ( 'id' => 'hover_effect_caption_visibility', 'value' => 'fg-caption-always' ) |
||
| 517 | ) |
||
| 518 | ), |
||
| 519 | array( |
||
| 520 | 'id' => 'caption_style', |
||
| 521 | 'value' => 'caption-slideup', |
||
| 522 | 'new' => array( |
||
| 523 | array ( 'id' => 'hover_effect_preset', 'value' => 'fg-custom' ), |
||
| 524 | array ( 'id' => 'hover_effect_caption_visibility', 'value' => 'fg-caption-hover' ), |
||
| 525 | array ( 'id' => 'hover_effect_transition', 'value' => 'fg-hover-slide-up' ), |
||
| 526 | ) |
||
| 527 | ), |
||
| 528 | |||
| 529 | array( |
||
| 530 | 'id' => 'caption_style', |
||
| 531 | 'value' => 'caption-fall', |
||
| 532 | 'new' => array( |
||
| 533 | array ( 'id' => 'hover_effect_preset', 'value' => 'fg-custom' ), |
||
| 534 | array ( 'id' => 'hover_effect_caption_visibility', 'value' => 'fg-caption-hover' ), |
||
| 535 | array ( 'id' => 'hover_effect_transition', 'value' => 'fg-hover-slide-down' ), |
||
| 536 | ) |
||
| 537 | ), |
||
| 538 | array( |
||
| 539 | 'id' => 'caption_style', |
||
| 540 | 'value' => 'caption-fade', |
||
| 541 | 'new' => array( |
||
| 542 | array ( 'id' => 'hover_effect_preset', 'value' => 'fg-custom' ), |
||
| 543 | array ( 'id' => 'hover_effect_caption_visibility', 'value' => 'fg-caption-hover' ), |
||
| 544 | array ( 'id' => 'hover_effect_transition', 'value' => 'fg-hover-fade' ), |
||
| 545 | ) |
||
| 546 | ), |
||
| 547 | array( |
||
| 548 | 'id' => 'caption_style', |
||
| 549 | 'value' => 'caption-push', |
||
| 550 | 'new' => array( |
||
| 551 | array ( 'id' => 'hover_effect_preset', 'value' => 'fg-custom' ), |
||
| 552 | array ( 'id' => 'hover_effect_caption_visibility', 'value' => 'fg-caption-hover' ), |
||
| 553 | array ( 'id' => 'hover_effect_transition', 'value' => 'fg-hover-push' ), |
||
| 554 | ) |
||
| 555 | ), |
||
| 556 | array( |
||
| 557 | 'id' => 'caption_style', |
||
| 558 | 'value' => 'caption-scale', |
||
| 559 | 'new' => array( |
||
| 560 | array ( 'id' => 'hover_effect_preset', 'value' => 'fg-custom' ), |
||
| 561 | array ( 'id' => 'hover_effect_caption_visibility', 'value' => 'fg-caption-hover' ), |
||
| 562 | array ( 'id' => 'hover_effect_transition', 'value' => 'fg-hover-slide-left' ), |
||
| 563 | ) |
||
| 564 | ), |
||
| 565 | |||
| 566 | //single thumbnail gallery |
||
| 567 | array( |
||
| 568 | 'id' => 'position', |
||
| 569 | 'value' => 'position-block', |
||
| 570 | 'new' => array( |
||
| 571 | array ( 'id' => 'position', 'value' => 'fg-center' ), |
||
| 572 | ) |
||
| 573 | ), |
||
| 574 | array( |
||
| 575 | 'id' => 'position', |
||
| 576 | 'value' => 'position-float-left', |
||
| 577 | 'new' => array( |
||
| 578 | array ( 'id' => 'position', 'value' => 'fg-left' ), |
||
| 579 | ) |
||
| 580 | ), |
||
| 581 | array( |
||
| 582 | 'id' => 'position', |
||
| 583 | 'value' => 'position-float-right', |
||
| 584 | 'new' => array( |
||
| 585 | array ( 'id' => 'position', 'value' => 'fg-right' ), |
||
| 586 | ) |
||
| 587 | ), |
||
| 588 | |||
| 589 | ); |
||
| 590 | |||
| 591 | $new_settings = get_post_meta( $foogallery->ID, FOOGALLERY_META_SETTINGS, true ); |
||
| 592 | $old_settings = get_post_meta( $foogallery->ID, FOOGALLERY_META_SETTINGS_OLD, true ); |
||
| 593 | |||
| 594 | //only upgrade galleries that need to be |
||
| 595 | if ( !is_array($new_settings) && is_array($old_settings) ) { |
||
| 596 | |||
| 597 | //start with the old settings |
||
| 598 | $new_settings = $old_settings; |
||
| 599 | |||
| 600 | //upgrade all template settings |
||
| 601 | foreach ( foogallery_gallery_templates() as $template ) { |
||
| 602 | |||
| 603 | foreach ( $mappings as $mapping ) { |
||
| 604 | |||
| 605 | $settings_key = "{$template['slug']}_{$mapping['id']}"; |
||
| 606 | |||
| 607 | //check if the settings exists |
||
| 608 | if ( array_key_exists( $settings_key, $old_settings ) ) { |
||
| 609 | |||
| 610 | $old_settings_value = $old_settings[$settings_key]; |
||
| 611 | |||
| 612 | if ( $mapping['value'] === $old_settings_value ) { |
||
| 613 | //we have found a match! |
||
| 614 | |||
| 615 | foreach ( $mapping['new'] as $setting_to_create ) { |
||
| 616 | $new_setting_key = "{$template['slug']}_{$setting_to_create['id']}"; |
||
| 617 | $new_setting_value = $setting_to_create['value']; |
||
| 618 | $new_settings[$new_setting_key] = $new_setting_value; |
||
| 619 | } |
||
| 620 | } |
||
| 621 | } |
||
| 622 | } |
||
| 623 | } |
||
| 624 | |||
| 625 | //template specific settings overrides |
||
| 626 | if ( 'image-viewer' === $foogallery->gallery_template ) { |
||
| 627 | $new_settings['image-viewer_theme'] = 'fg-light'; |
||
| 628 | $new_settings['image-viewer_border_size'] = ''; |
||
| 629 | $new_settings['image-viewer_drop_shadow'] = ''; |
||
| 630 | $new_settings['image-viewer_rounded_corners'] = ''; |
||
| 631 | $new_settings['image-viewer_inner_shadow'] = ''; |
||
| 632 | } |
||
| 633 | |||
| 634 | if ( 'justified' === $foogallery->gallery_template ) { |
||
| 635 | $new_settings['image-viewer_theme'] = 'fg-light'; |
||
| 636 | $new_settings['image-viewer_border_size'] = ''; |
||
| 637 | $new_settings['image-viewer_drop_shadow'] = ''; |
||
| 638 | $new_settings['image-viewer_rounded_corners'] = ''; |
||
| 639 | $new_settings['image-viewer_inner_shadow'] = ''; |
||
| 640 | } |
||
| 641 | |||
| 642 | if ( 'masonry' === $foogallery->gallery_template ) { |
||
| 643 | $new_settings['image-viewer_theme'] = 'fg-light'; |
||
| 644 | $new_settings['image-viewer_border_size'] = ''; |
||
| 645 | $new_settings['image-viewer_drop_shadow'] = ''; |
||
| 646 | $new_settings['image-viewer_rounded_corners'] = ''; |
||
| 647 | $new_settings['image-viewer_inner_shadow'] = ''; |
||
| 648 | } |
||
| 649 | |||
| 650 | add_post_meta( $foogallery->ID, FOOGALLERY_META_SETTINGS, $new_settings, true ); |
||
| 651 | } |
||
| 652 | } |
||
| 653 | } |
||
| 654 | } |
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.