/var/www/hkosl.com/aga/wp-content/plugins/foogallery/includes/class-foogallery-common-fields.php


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
<?php
/**
 * Adds all functionality related to the common gallery fields that are used in the default gallery templates
 * Date: 12/09/2017
 */
if ( ! class_exists'FooGallery_Common_Fields' ) ) {

    class 
FooGallery_Common_Fields {

        function 
__construct() {
            
//handle some default field types that all templates can reuse
            
add_filter'foogallery_alter_gallery_template_field', array( $this'alter_gallery_template_field' ), 10);

            
//build up class attributes
            
add_filter'foogallery_build_class_attribute', array( $this'add_common_fields_class_attributes' ), 10);

            
//add our common field data attribute
            
add_filter'foogallery_build_container_attributes', array( $this'add_common_fields_data_attribute' ), 10);

            
//add common data options
            
add_filter'foogallery_build_container_data_options', array( $this'add_caption_data_options' ), 10);

            
//build up any preview arguments
            
add_filter'foogallery_preview_arguments', array( $this'preview_arguments' ), 10);

            
//add common fields to the templates that support it
            
add_filter'foogallery_override_gallery_template_fields', array( $this'add_common_fields' ), 10);

            
//check that we are no longer on pro and have previously used a preset or a loaded effect
            
add_filter'foogallery_render_gallery_template_field_value', array( $this'check_downgrade_values' ), 10);
        }

        function 
alter_gallery_template_field$field$gallery ) {
            if ( 
$field ) {

                if ( isset( 
$field['type'] ) ) {
                    switch ( 
$field['type'] ) {
                        case 
'thumb_link':
                            
$field['type']    = 'radio';
                            
$field['choices'] = foogallery_gallery_template_field_thumb_link_choices();
                            break;
                        case 
'lightbox':
                            
$field['lightbox'] = true;
                            
$field['type']     = 'select';
                            
$field['choices']  = foogallery_gallery_template_field_lightbox_choices();
                            break;
                    }
                }

                if ( isset(
$field['help']) && $field['help'] ) {
                    
$field['type'] = 'help';
                }
            }
            return 
$field;
        }

        
/**
         * Add common fields to the gallery template if supported
         *
         * @param $fields
         * @param $template
         *
         * @return array
         */
        
function add_common_fields$fields$template ) {
            
//check if the template supports the common fields
            
if ( $template && array_key_exists'common_fields_support'$template ) && true === $template['common_fields_support'] ) {

                
//region Appearance Fields
                
$fields[] = array(
                    
'id'      => 'theme_custom_help',
                    
'title'   => __'Theme Help''foogallery' ),
                    
'desc'    => __'If you choose to use the Custom theme, then you will need to provide your own Custom CSS in order to style the gallery to suit your needs.''foogallery' ),
                    
'section' => __'Appearance''foogallery' ),
                    
'type'    => 'help',
                    
'row_data' => array(
                        
'data-foogallery-hidden'                    => true,
                        
'data-foogallery-show-when-field'          => 'theme',
                        
'data-foogallery-show-when-field-value'    => 'fg-custom',
                    )
                );

                
$fields[] = array(
                    
'id'       => 'theme',
                    
'title'    => __'Theme''foogallery' ),
                    
'desc'     => __'The overall appearance of the items in the gallery, affecting the border, background, font and shadow colors.''foogallery' ),
                    
'section'  => __'Appearance''foogallery' ),
                    
'type'     => 'radio',
                    
'default'  => 'fg-light',
                    
'spacer'   => '<span class="spacer"></span>',
                    
'choices'  => array(
                        
'fg-light'  => __'Light''foogallery' ),
                        
'fg-dark'   => __'Dark''foogallery' ),
                        
'fg-custom' => __'Custom''foogallery' )
                    ),
                    
'row_data' => array(
                        
'data-foogallery-change-selector' => 'input:radio',
                        
'data-foogallery-value-selector'  => 'input:checked',
                        
'data-foogallery-preview'         => 'class'
                    
)
                );

                
$fields[] = array(
                    
'id'       => 'border_size',
                    
'title'    => __'Border Size''foogallery' ),
                    
'desc'     => __'The border size applied to each thumbnail''foogallery' ),
                    
'section'  => __'Appearance''foogallery' ),
                    
'type'     => 'radio',
                    
'spacer'   => '<span class="spacer"></span>',
                    
'default'  => 'fg-border-thin',
                    
'choices'  => array(
                        
''                 => __'None''foogallery' ),
                        
'fg-border-thin'   => __'Thin''foogallery' ),
                        
'fg-border-medium' => __'Medium''foogallery' ),
                        
'fg-border-thick'  => __'Thick''foogallery' ),
                    ),
                    
'row_data' => array(
                        
'data-foogallery-change-selector' => 'input:radio',
                        
'data-foogallery-preview'         => 'class'
                    
)
                );

                
$fields[] = array(
                    
'id'       => 'rounded_corners',
                    
'title'    => __'Rounded Corners''foogallery' ),
                    
'desc'     => __'The border radius, or rounded corners applied to each thumbnail''foogallery' ),
                    
'section'  => __'Appearance''foogallery' ),
                    
'type'     => 'radio',
                    
'spacer'   => '<span class="spacer"></span>',
                    
'default'  => '',
                    
'choices'  => array(
                        
''                => __'None''foogallery' ),
                        
'fg-round-small'  => __'Small''foogallery' ),
                        
'fg-round-medium' => __'Medium''foogallery' ),
                        
'fg-round-large'  => __'Large''foogallery' ),
                        
'fg-round-full'   => __'Full''foogallery' ),
                    ),
                    
'row_data' => array(
                        
'data-foogallery-change-selector' => 'input:radio',
                        
'data-foogallery-preview'         => 'class'
                    
)
                );

                
$fields[] = array(
                    
'id'       => 'drop_shadow',
                    
'title'    => __'Drop Shadow''foogallery' ),
                    
'desc'     => __'The outer or drop shadow applied to each thumbnail''foogallery' ),
                    
'section'  => __'Appearance''foogallery' ),
                    
'type'     => 'radio',
                    
'spacer'   => '<span class="spacer"></span>',
                    
'default'  => 'fg-shadow-outline',
                    
'choices'  => array(
                        
''                  => __'None''foogallery' ),
                        
'fg-shadow-outline' => __'Outline''foogallery' ),
                        
'fg-shadow-small'   => __'Small''foogallery' ),
                        
'fg-shadow-medium'  => __'Medium''foogallery' ),
                        
'fg-shadow-large'   => __'Large''foogallery' ),
                    ),
                    
'row_data' => array(
                        
'data-foogallery-change-selector' => 'input:radio',
                        
'data-foogallery-preview'         => 'class'
                    
)
                );

                
$fields[] = array(
                    
'id'       => 'inner_shadow',
                    
'title'    => __'Inner Shadow''foogallery' ),
                    
'desc'     => __'The inner shadow applied to each thumbnail''foogallery' ),
                    
'section'  => __'Appearance''foogallery' ),
                    
'type'     => 'radio',
                    
'spacer'   => '<span class="spacer"></span>',
                    
'default'  => '',
                    
'choices'  => array(
                        
''                       => __'None''foogallery' ),
                        
'fg-shadow-inset-small'  => __'Small''foogallery' ),
                        
'fg-shadow-inset-medium' => __'Medium''foogallery' ),
                        
'fg-shadow-inset-large'  => __'Large''foogallery' ),
                    ),
                    
'row_data' => array(
                        
'data-foogallery-change-selector' => 'input:radio',
                        
'data-foogallery-preview'         => 'class'
                    
)
                );

                
$fields[] = array(
                    
'id'       => 'loading_icon',
                    
'title'    => __'Loading Icon''foogallery' ),
                    
'desc'     => __'An animated loading icon can be shown while the thumbnails are busy loading.''foogallery' ),
                    
'section'  => __'Appearance''foogallery' ),
                    
'default'  => 'fg-loading-default',
                    
'type'     => 'htmlicon',
                    
'choices'  => apply_filters(
                        
'foogallery_gallery_template_common_thumbnail_fields_loading_icon_choices', array(
                        
''                   => array( 'label' => __'None''foogallery' ), 'html' => '<div class="foogallery-setting-loading_icon"></div>' ),
                        
'fg-loading-default' => array( 'label' => __'Default''foogallery' ), 'html' => '<div class="foogallery-setting-loading_icon fg-loading-default"><div class="fg-loader"></div></div>' ),
                        
'fg-loading-bars'    => array( 'label' => __'Bars''foogallery' ), 'html' => '<div class="foogallery-setting-loading_icon fg-loading-bars"><div class="fg-loader"></div></div>' ),
                        
'fg-loading-dots'    => array( 'label' => __'Dots''foogallery' ), 'html' => '<div class="foogallery-setting-loading_icon fg-loading-dots"><div class="fg-loader"></div></div>' ),
                        
'fg-loading-partial' => array( 'label' => __'Partial''foogallery' ), 'html' => '<div class="foogallery-setting-loading_icon fg-loading-partial"><div class="fg-loader"></div></div>' ),
                        
'fg-loading-pulse'   => array( 'label' => __'Pulse''foogallery' ), 'html' => '<div class="foogallery-setting-loading_icon fg-loading-pulse"><div class="fg-loader"></div></div>' ),
                        
'fg-loading-trail'   => array( 'label' => __'Trail''foogallery' ), 'html' => '<div class="foogallery-setting-loading_icon fg-loading-trail"><div class="fg-loader"></div></div>' ),
                    )
                    ),
                    
'row_data' => array(
                        
'data-foogallery-change-selector' => 'input:radio',
                        
'data-foogallery-value-selector'  => 'input:checked',
                        
'data-foogallery-preview'         => 'class'
                    
)
                );

                
$fields[] = array(
                    
'id'       => 'loaded_effect',
                    
'title'    => __'Loaded Effect''foogallery' ),
                    
'desc'     => __'The animation effect used to display the thumbnail, once it has loaded.''foogallery' ),
                    
'section'  => __'Appearance''foogallery' ),
                    
'default'  => 'fg-loaded-fade-in',
                    
'type'     => 'select',
                    
'choices'  => apply_filters(
                        
'foogallery_gallery_template_common_thumbnail_fields_loaded_effect_choices', array(
                        
''                      => __'None''foogallery' ),
                        
'fg-loaded-fade-in'     => __'Fade In''foogallery' ),
                    )
                    ),
                    
'row_data' => array(
                        
'data-foogallery-change-selector' => 'select',
                        
'data-foogallery-value-selector'  => 'select option:selected',
                        
'data-foogallery-preview'         => 'class'
                    
)
                );
                
//endregion

                //region Hover Effects Fields
                
$fields[] = array(
                    
'id'      => 'hover_effect_help',
                    
'title'   => __'Hover Effect Help''foogallery' ),
                    
'desc'    => __'A preset provides a stylish and pre-defined look &amp; feel for when you hover over the thumbnails.''foogallery' ),
                    
'section' => __'Hover Effects''foogallery' ),
                    
'type'    => 'help',
                    
'row_data' => array(
                        
'data-foogallery-hidden' => true,
                    )
                );

                
$fields[] = array(
                    
'id'       => 'hover_effect_preset',
                    
'title'    => __'Preset''foogallery' ),
                    
'section'  => __'Hover Effects''foogallery' ),
                    
'default'  => 'fg-custom',
                    
'type'     => 'radio',
                    
'choices'  => apply_filters(
                        
'foogallery_gallery_template_common_thumbnail_fields_hover_effect_preset_choices', array(
                        
''          => __'None''foogallery' ),
                        
'fg-custom' => __'Custom''foogallery' ),
                    )
                    ),
                    
'spacer'   => '<span class="spacer"></span>',
                    
'desc'     => __'A preset styling that is used for the captions. If you want to define your own custom captions, then choose Custom.''foogallery' ),
                    
'row_data' => array(
                        
'data-foogallery-hidden'          => true,
                        
'data-foogallery-change-selector' => 'input:radio',
                        
'data-foogallery-value-selector'  => 'input:checked',
                        
'data-foogallery-preview'         => 'class'
                    
)
                );

                
$fields[] = array(
                    
'id'       => 'hover_effect_preset_size',
                    
'title'    => __'Preset Size''foogallery' ),
                    
'section'  => __'Hover Effects''foogallery' ),
                    
'default'  => 'fg-preset-small',
                    
'spacer'   => '<span class="spacer"></span>',
                    
'type'     => 'radio',
                    
'choices'  => apply_filters(
                        
'foogallery_gallery_template_common_thumbnail_fields_hover_effect_preset_size_choices', array(
                        
'fg-preset-small'  => __'Small''foogallery' ),
                        
'fg-preset-medium' => __'Medium''foogallery' ),
                        
'fg-preset-large'  => __'Large''foogallery' ),
                    )
                    ),
                    
'desc'     => __'Choose an appropriate size for the preset caption effects, based on the size of your thumbs. Choose small for thumbs 150-200 wide, medium for thumbs 200-400 wide, and large for thumbs over 400 wide.''foogallery' ),
                    
'row_data' => array(
                        
'data-foogallery-change-selector'          => 'input:radio',
                        
'data-foogallery-hidden'                   => true,
                        
'data-foogallery-show-when-field'          => 'hover_effect_preset',
                        
'data-foogallery-show-when-field-operator' => 'indexOf',
                        
'data-foogallery-show-when-field-value'    => 'fg-preset',
                        
'data-foogallery-preview'                  => 'class'
                    
)
                );

                
$fields[] = array(
                    
'id'       => 'hover_effect_color',
                    
'title'    => __'Color Effect''foogallery' ),
                    
'section'  => __'Hover Effects''foogallery' ),
                    
'default'  => '',
                    
'spacer'   => '<span class="spacer"></span>',
                    
'type'     => 'radio',
                    
'choices'  => apply_filters(
                        
'foogallery_gallery_template_common_thumbnail_fields_hover_effect_color_choices', array(
                        
''                   => __'None''foogallery' ),
                        
'fg-hover-colorize'  => __'Colorize''foogallery' ),
                        
'fg-hover-grayscale' => __'Greyscale''foogallery' ),
                    )
                    ),
                    
'desc'     => __'Choose an color effect that is applied when you hover over a thumbnail.''foogallery' ),
                    
'row_data' => array(
                        
'data-foogallery-change-selector'       => 'input:radio',
                        
'data-foogallery-hidden'                => true,
                        
'data-foogallery-show-when-field'       => 'hover_effect_preset',
                        
'data-foogallery-show-when-field-value' => 'fg-custom',
                        
'data-foogallery-preview'               => 'class'
                    
)
                );

                
$fields[] = array(
                    
'id'       => 'hover_effect_scale',
                    
'title'    => __'Scaling Effect''foogallery' ),
                    
'section'  => __'Hover Effects''foogallery' ),
                    
'default'  => '',
                    
'spacer'   => '<span class="spacer"></span>',
                    
'type'     => 'radio',
                    
'choices'  => apply_filters(
                        
'foogallery_gallery_template_common_thumbnail_fields_hover_effect_scale_choices', array(
                        
''               => __'None''foogallery' ),
                        
'fg-hover-scale' => __'Scaled''foogallery' ),
                    )
                    ),
                    
'desc'     => __'Apply a slight scaling effect when hovering over a thumbnail.''foogallery' ),
                    
'row_data' => array(
                        
'data-foogallery-change-selector'       => 'input:radio',
                        
'data-foogallery-hidden'                => true,
                        
'data-foogallery-show-when-field'       => 'hover_effect_preset',
                        
'data-foogallery-show-when-field-value' => 'fg-custom',
                        
'data-foogallery-preview'               => 'class'
                    
)
                );

                
$fields[] = array(
                    
'id'       => 'hover_effect_caption_visibility',
                    
'title'    => __'Caption Visibility''foogallery' ),
                    
'section'  => __'Hover Effects''foogallery' ),
                    
'default'  => 'fg-caption-hover',
                    
'spacer'   => '<span class="spacer"></span>',
                    
'type'     => 'radio',
                    
'choices'  => apply_filters(
                        
'foogallery_gallery_template_common_thumbnail_fields_hover_effect_caption_visibility_choices', array(
                        
''                  => __'None''foogallery' ),
                        
'fg-caption-hover'  => __'On Hover''foogallery' ),
                        
'fg-caption-always' => __'Always Visible''foogallery' ),
                    )
                    ),
                    
'desc'     => __'Choose how the captions will be displayed.''foogallery' ),
                    
'row_data' => array(
                        
'data-foogallery-change-selector'       => 'input:radio',
                        
'data-foogallery-hidden'                => true,
                        
'data-foogallery-show-when-field'       => 'hover_effect_preset',
                        
'data-foogallery-show-when-field-value' => 'fg-custom',
                        
'data-foogallery-preview'               => 'class'
                    
)
                );

                
$fields[] = array(
                    
'id'       => 'hover_effect_transition',
                    
'title'    => __'Transition''foogallery' ),
                    
'section'  => __'Hover Effects''foogallery' ),
                    
'default'  => 'fg-hover-fade',
                    
'type'     => 'select',
                    
'choices'  => apply_filters'foogallery_gallery_template_common_thumbnail_fields_hover_effect_transition_choices', array(
                        
'fg-hover-instant'     => __'Instant''foogallery' ),
                        
'fg-hover-fade'        => __'Fade''foogallery' ),
                        
'fg-hover-slide-up'    => __'Slide Up''foogallery' ),
                        
'fg-hover-slide-down'  => __'Slide Down''foogallery' ),
                        
'fg-hover-slide-left'  => __'Slide Left''foogallery' ),
                        
'fg-hover-slide-right' => __'Slide Right''foogallery' ),
                        
'fg-hover-push'        => __'Push''foogallery' ) )
                    ),
                    
'desc'     => __'Choose what effect is used to show the caption when you hover over a thumbnail''foogallery' ),
                    
'row_data' => array(
                        
'data-foogallery-change-selector'       => 'select',
                        
'data-foogallery-hidden'                => true,
                        
'data-foogallery-show-when-field'       => 'hover_effect_preset',
                        
'data-foogallery-show-when-field-value' => 'fg-custom',
                        
'data-foogallery-preview'               => 'class'
                    
)
                );

                
$fields[] = array(
                    
'id'       => 'hover_effect_icon',
                    
'title'    => __'Icon''foogallery' ),
                    
'desc'     => __'Choose which icon is shown with the caption when you hover over a thumbnail''foogallery' ),
                    
'section'  => __'Hover Effects''foogallery' ),
                    
'type'     => 'htmlicon',
                    
'default'  => 'fg-hover-zoom',
                    
'choices'  => apply_filters'foogallery_gallery_template_common_thumbnail_fields_hover_effect_icon_choices', array(
                        
''                     => array( 'label' => __'None''foogallery' ), 'html' => '<div class="foogallery-setting-caption_icon"></div>' ),
                        
'fg-hover-zoom'        => array( 'label' => __'Zoom''foogallery' ), 'html' => '<div class="foogallery-setting-caption_icon fg-hover-zoom"></div>' ),
                        
'fg-hover-zoom2'       => array( 'label' => __'Zoom 2''foogallery' ), 'html' => '<div class="foogallery-setting-caption_icon fg-hover-zoom2"></div>' ),
                        
'fg-hover-zoom3'       => array( 'label' => __'Zoom 3''foogallery' ), 'html' => '<div class="foogallery-setting-caption_icon fg-hover-zoom3"></div>' ),
                        
'fg-hover-plus'        => array( 'label' => __'Plus''foogallery' ), 'html' => '<div class="foogallery-setting-caption_icon fg-hover-plus"></div>' ),
                        
'fg-hover-circle-plus' => array( 'label' => __'Circle Plus''foogallery' ), 'html' => '<div class="foogallery-setting-caption_icon fg-hover-circle-plus"></div>' ),
                        
'fg-hover-eye'         => array( 'label' => __'Eye''foogallery' ), 'html' => '<div class="foogallery-setting-caption_icon fg-hover-eye"></div>' ),
                        
'fg-hover-external'    => array( 'label' => __'External''foogallery' ), 'html' => '<div class="foogallery-setting-caption_icon fg-hover-external"></div>' ), )
                    ),
                    
'row_data' => array(
                        
'data-foogallery-change-selector'       => 'input:radio',
                        
'data-foogallery-hidden'                => true,
                        
'data-foogallery-show-when-field'       => 'hover_effect_preset',
                        
'data-foogallery-show-when-field-value' => 'fg-custom',
                        
'data-foogallery-preview'               => 'class'
                    
)
                );
                
//endregion Hover Effects Fields

                //region Caption Fields
                
$fields[] = array(
                    
'id'      => 'captions_help',
                    
'title'   => __'Captions Help''foogallery' ),
                    
'desc'    => __'You can change when captions are shown using the "Hover Effects -> Caption Visibility" setting .''foogallery' ),
                    
'section' => __'Captions''foogallery' ),
                    
'type'    => 'help'
                
);

                
$settings_link sprintf'<a target="blank" href="%s">%s</a>'foogallery_admin_settings_url(), __'settings''foogallery' ) );

                
$fields[] = array(
                    
'id'       => 'caption_title_source',
                    
'title'    => __'Title''foogallery' ),
                    
'desc'     => __'Decide where caption titles are pulled from. By default, what is saved under general settings will be used, but it can be overridden per gallery''foogallery' ),
                    
'section'  => __'Captions''foogallery' ),
                    
'type'     => 'radio',
                    
'default'  => '',
                    
'choices'  => array(
                        
'none'    => __'None''foogallery' ),
                        
''        => sprintf__'Default (as per %s)''foogallery' ), $settings_link ),
                        
'title'   => foogallery_get_attachment_field_friendly_name'title' ),
                        
'caption' => foogallery_get_attachment_field_friendly_name'caption' ),
                        
'alt'     => foogallery_get_attachment_field_friendly_name'alt' ),
                        
'desc'    => foogallery_get_attachment_field_friendly_name'desc' ),
                    ),
                    
'row_data' => array(
                        
'data-foogallery-change-selector'       => 'input:radio',
                        
'data-foogallery-preview'               => 'shortcode'
                    
)
                );

                
$fields[] = array(
                    
'id'       => 'caption_desc_source',
                    
'title'    => __'Description''foogallery' ),
                    
'desc'     => __'Decide where captions descriptions are pulled from. By default, the general settings are used, but it can be overridden per gallery''foogallery' ),
                    
'section'  => __'Captions''foogallery' ),
                    
'type'     => 'radio',
                    
'default'  => '',
                    
'choices'  => array(
                        
'none'    => __'None''foogallery' ),
                        
''        => sprintf__'Default (as per %s)''foogallery' ), $settings_link ),
                        
'title'   => foogallery_get_attachment_field_friendly_name'title' ),
                        
'caption' => foogallery_get_attachment_field_friendly_name'caption' ),
                        
'alt'     => foogallery_get_attachment_field_friendly_name'alt' ),
                        
'desc'    => foogallery_get_attachment_field_friendly_name'desc' ),
                    ),
                    
'row_data' => array(
                        
'data-foogallery-change-selector'       => 'input:radio',
                        
'data-foogallery-preview'               => 'shortcode'
                    
)
                );

                
$fields[] = array(
                    
'id'      => 'captions_limit_length',
                    
'title'   => __'Limit Caption Length''foogallery' ),
                    
'desc'    => __'You can limit the length of caption title and descriptions in the thumbnails. This will NOT limit the length of captions from within the lightbox.''foogallery' ),
                    
'section' => __'Captions''foogallery' ),
                    
'default' => '',
                    
'type'    => 'radio',
                    
'spacer'  => '<span class="spacer"></span>',
                    
'choices' => array(
                        
'' => __'No''foogallery' ),
                        
'yes' => __'Yes''foogallery' ),
                    ),
                    
'row_data'=> array(
                        
'data-foogallery-change-selector' => 'input:radio',
                        
'data-foogallery-preview' => 'shortcode',
                        
'data-foogallery-value-selector'  => 'input:checked',
                    )
                );

                
$fields[] = array(
                    
'id'      => 'caption_title_length',
                    
'title'   => __'Max Title Length''foogallery' ),
                    
'desc'      => __'A max length of zero will not apply a limit.''foogallery '),
                    
'section' => __'Captions''foogallery' ),
                    
'type'    => 'number',
                    
'class'   => 'small-text',
                    
'default' => 0,
                    
'step'    => '1',
                    
'min'     => '0',
                    
'row_data' => array(
                        
'data-foogallery-change-selector'       => 'input',
                        
'data-foogallery-hidden'                => true,
                        
'data-foogallery-show-when-field'       => 'captions_limit_length',
                        
'data-foogallery-show-when-field-value' => 'yes',
                        
'data-foogallery-preview'               => 'shortcode'
                    
)
                );

                
$fields[] = array(
                    
'id'      => 'caption_desc_length',
                    
'title'   => __'Max Desc Length''foogallery' ),
                    
'desc'      => __'A max length of zero will not apply a limit.''foogallery '),
                    
'section' => __'Captions''foogallery' ),
                    
'type'    => 'number',
                    
'class'   => 'small-text',
                    
'default' => 0,
                    
'step'    => '1',
                    
'min'     => '0',
                    
'row_data' => array(
                        
'data-foogallery-change-selector'       => 'input',
                        
'data-foogallery-hidden'                => true,
                        
'data-foogallery-show-when-field'       => 'captions_limit_length',
                        
'data-foogallery-show-when-field-value' => 'yes',
                        
'data-foogallery-preview'               => 'shortcode'
                    
)
                );
                
//endregion

            
}
            return 
$fields;
        }

        function 
get_setting_from_gallery$gallery$key$default ) {
            global 
$current_foogallery;

            if ( isset( 
$current_foogallery ) && $current_foogallery === $gallery ) {
                return 
foogallery_gallery_template_setting$key$default );
            }

            return 
$gallery->get_setting$key$default );
        }

        
/**
         * Build up the gallery class attribute for the common fields
         *
         * @param $classes array
         * @param $gallery FooGallery
         *
         * @return array
         */
        
function add_common_fields_class_attributes$classes$gallery ) {
            
$template_data foogallery_get_gallery_template$gallery->gallery_template );

            
//check the template supports common fields
            
if ( $template_data && array_key_exists'common_fields_support'$template_data ) && true === $template_data['common_fields_support'] ) {

                
//add the gallery template core class
                
$classes[] = 'fg-' $gallery->gallery_template;

                
//get some default classes from common gallery settings
                
$classes[] = $this->get_setting_from_gallery$gallery'theme''fg-light' );
                
$classes[] = $this->get_setting_from_gallery$gallery'border_size''fg-border-thin' );
                
$classes[] = $this->get_setting_from_gallery$gallery'rounded_corners''' );
                
$classes[] = $this->get_setting_from_gallery$gallery'drop_shadow''fg-shadow-outline' );
                
$classes[] = $this->get_setting_from_gallery$gallery'inner_shadow''' );
                
$classes[] = $this->get_setting_from_gallery$gallery'loading_icon''fg-loading-default' );
                
$classes[] = $this->get_setting_from_gallery$gallery'loaded_effect''fg-loaded-fade-in' );

                
$caption_preset $this->get_setting_from_gallery$gallery,'hover_effect_preset''fg-custom' );

                
$classes[] = $caption_preset;

                if ( 
'fg-custom' === $caption_preset ) {
                    
//only set these caption classes if custom preset is selected
                    
$classes[] = $this->get_setting_from_gallery$gallery'hover_effect_color''' );
                    
$classes[] = $this->get_setting_from_gallery$gallery'hover_effect_scale''' );
                    
$classes[] = $this->get_setting_from_gallery$gallery'hover_effect_caption_visibility''fg-caption-hover' );
                    
$classes[] = $this->get_setting_from_gallery$gallery'hover_effect_transition''fg-hover-fade' );
                    
$classes[] = $this->get_setting_from_gallery$gallery'hover_effect_icon''fg-hover-zoom' );
                } else if ( 
strpos$caption_preset'fg-preset' ) !== false ) {
                    
//set a preset size
                    
$classes[] = $this->get_setting_from_gallery$gallery'hover_effect_preset_size''fg-preset-small' );
                }

                if ( 
foogallery_get_setting'enable_custom_ready' ) ) {
                    
$classes[] = 'fg-ready';
                }
            }

            return 
$classes;
        }

        
/**
         * Add the required data options for captions
         *
         * @param $options
         * @param $gallery    FooGallery
         *
         * @param $attributes array
         *
         * @return array
         */
        
function add_caption_data_options($options$gallery$attributes) {
            
$template_data foogallery_get_gallery_template$gallery->gallery_template );

            
//check the template supports common fields
            
if ( $template_data && array_key_exists'common_fields_support'$template_data ) && true === $template_data['common_fields_support'] ) {

                
$caption_title foogallery_gallery_template_setting'caption_title_source''' );
                
$caption_desc  foogallery_gallery_template_setting'caption_desc_source''' );

                
$options['item']['showCaptionTitle']       = $caption_title != 'none';
                
$options['item']['showCaptionDescription'] = $caption_desc != 'none';

                
$captions_limit_length foogallery_gallery_template_setting'captions_limit_length''' );

                if ( 
'yes' === $captions_limit_length ) {
                    
$caption_title_length                    foogallery_gallery_template_setting'caption_title_length''0' );
                    
$caption_desc_length                     foogallery_gallery_template_setting'caption_desc_length''0' );
                    
$options['item']['maxCaptionLength']     = intval$caption_title_length );
                    
$options['item']['maxDescriptionLength'] = intval$caption_desc_length );
                }
            }
            return 
$options;
        }

        
/**
         * Build up a arguments used in the preview of the gallery
         * @param $args
         * @param $post_data
         * @param $template
         *
         * @return mixed
         */
        
function preview_arguments$args$post_data$template ) {
            
$args['caption_title_source'] = $post_data[FOOGALLERY_META_SETTINGS][$template '_caption_title_source'];
            
$args['caption_desc_source'] = $post_data[FOOGALLERY_META_SETTINGS][$template '_caption_desc_source'];
            
$args['captions_limit_length'] = $post_data[FOOGALLERY_META_SETTINGS][$template '_captions_limit_length'];
            
$args['caption_title_length'] = $post_data[FOOGALLERY_META_SETTINGS][$template '_caption_title_length'];
            
$args['caption_desc_length'] = $post_data[FOOGALLERY_META_SETTINGS][$template '_caption_desc_length'];
            return 
$args;
        }

        
/**
         * Build up the gallery data attributes for the common fields
         *
         * @param $attributes array
         * @param $gallery FooGallery
         *
         * @return array
         */
        
function add_common_fields_data_attribute$attributes$gallery ) {
            
$template_data foogallery_get_gallery_template$gallery->gallery_template );

            
//check the template supports common fields
            
if ( $template_data && array_key_exists'common_fields_support'$template_data ) && true === $template_data['common_fields_support'] ) {
                
$attributes['data-fg-common-fields'] = true;
            }

            return 
$attributes;
        }

        
/***
         * Check if we have a value from FooBox free and change it if foobox free is no longer active
         * @param $value
         * @param $field
         * @param $gallery
         * @param $template
         *
         * @return string
         */
        
function check_downgrade_values($value$field$gallery$template) {

            if ( isset( 
$field['type'] ) ) {
                if ( 
'hover_effect_preset' === $field['id'] || 'loaded_effect' === $field['type'] ) {
                    if ( !
array_key_exists$value$field['choices'] ) ) {
                        
$value $field['default'];
                    }
                }
            }

            return 
$value;
        }
    }
}