1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Adds all functionality related to the common gallery fields that are used in the default gallery templates |
4
|
|
|
* Date: 12/09/2017 |
5
|
|
|
*/ |
6
|
|
|
if ( ! class_exists( 'FooGallery_Common_Fields' ) ) { |
7
|
|
|
|
8
|
|
|
class FooGallery_Common_Fields { |
9
|
|
|
|
10
|
|
|
function __construct() { |
11
|
|
|
//handle some default field types that all templates can reuse |
12
|
|
|
add_filter( 'foogallery_alter_gallery_template_field', array( $this, 'alter_gallery_template_field' ), 10, 2 ); |
13
|
|
|
|
14
|
|
|
//build up class attributes |
15
|
|
|
add_filter( 'foogallery_build_class_attribute', array( $this, 'add_common_fields_class_attributes' ), 10, 2 ); |
16
|
|
|
|
17
|
|
|
//add our common field data attribute |
18
|
|
|
add_filter( 'foogallery_build_container_attributes', array( $this, 'add_common_fields_data_attribute' ), 10, 2 ); |
19
|
|
|
|
20
|
|
|
//add common data options |
21
|
|
|
add_filter( 'foogallery_build_container_data_options', array( $this, 'add_caption_data_options' ), 10, 3 ); |
22
|
|
|
|
23
|
|
|
//build up any preview arguments |
24
|
|
|
add_filter( 'foogallery_preview_arguments', array( $this, 'preview_arguments' ), 10, 3 ); |
25
|
|
|
|
26
|
|
|
//add common fields to the templates that support it |
27
|
|
|
add_filter( 'foogallery_override_gallery_template_fields', array( $this, 'add_common_fields' ), 10, 2 ); |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
function alter_gallery_template_field( $field, $gallery ) { |
31
|
|
|
if ( $field ) { |
32
|
|
|
|
33
|
|
|
if ( isset( $field['type'] ) ) { |
34
|
|
|
switch ( $field['type'] ) { |
35
|
|
|
case 'thumb_link': |
36
|
|
|
$field['type'] = 'radio'; |
37
|
|
|
$field['choices'] = foogallery_gallery_template_field_thumb_link_choices(); |
38
|
|
|
break; |
39
|
|
|
case 'lightbox': |
40
|
|
|
$field['lightbox'] = true; |
41
|
|
|
$field['type'] = 'select'; |
42
|
|
|
$field['choices'] = foogallery_gallery_template_field_lightbox_choices(); |
43
|
|
|
break; |
44
|
|
|
} |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
if ( isset($field['help']) && $field['help'] ) { |
48
|
|
|
$field['type'] = 'help'; |
49
|
|
|
} |
50
|
|
|
} |
51
|
|
|
return $field; |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* Add common fields to the gallery template if supported |
56
|
|
|
* |
57
|
|
|
* @param $fields |
58
|
|
|
* @param $template |
59
|
|
|
* |
60
|
|
|
* @return array |
61
|
|
|
*/ |
62
|
|
|
function add_common_fields( $fields, $template ) { |
|
|
|
|
63
|
|
|
//check if the template supports the common fields |
64
|
|
|
if ( $template && array_key_exists( 'common_fields_support', $template ) && true === $template['common_fields_support'] ) { |
65
|
|
|
|
66
|
|
|
//region Appearance Fields |
67
|
|
|
$fields[] = array( |
68
|
|
|
'id' => 'theme', |
69
|
|
|
'title' => __( 'Theme', 'foogallery' ), |
70
|
|
|
'desc' => __( 'The overall appearance of the items in the gallery, affecting the border, background, font and shadow colors.', 'foogallery' ), |
71
|
|
|
'section' => __( 'Appearance', 'foogallery' ), |
72
|
|
|
'type' => 'radio', |
73
|
|
|
'default' => 'fg-light', |
74
|
|
|
'spacer' => '<span class="spacer"></span>', |
75
|
|
|
'choices' => array( |
76
|
|
|
'fg-light' => __( 'Light', 'foogallery' ), |
77
|
|
|
'fg-dark' => __( 'Dark', 'foogallery' ), |
78
|
|
|
'fg-custom' => __( 'Custom', 'foogallery' ) |
79
|
|
|
), |
80
|
|
|
'row_data' => array( |
81
|
|
|
'data-foogallery-change-selector' => 'input:radio', |
82
|
|
|
'data-foogallery-preview' => 'class' |
83
|
|
|
) |
84
|
|
|
); |
85
|
|
|
|
86
|
|
|
$fields[] = array( |
87
|
|
|
'id' => 'border_size', |
88
|
|
|
'title' => __( 'Border Size', 'foogallery' ), |
89
|
|
|
'desc' => __( 'The border size applied to each thumbnail', 'foogallery' ), |
90
|
|
|
'section' => __( 'Appearance', 'foogallery' ), |
91
|
|
|
'type' => 'radio', |
92
|
|
|
'spacer' => '<span class="spacer"></span>', |
93
|
|
|
'default' => 'fg-border-thin', |
94
|
|
|
'choices' => array( |
95
|
|
|
'' => __( 'None', 'foogallery' ), |
96
|
|
|
'fg-border-thin' => __( 'Thin', 'foogallery' ), |
97
|
|
|
'fg-border-medium' => __( 'Medium', 'foogallery' ), |
98
|
|
|
'fg-border-thick' => __( 'Thick', 'foogallery' ), |
99
|
|
|
), |
100
|
|
|
'row_data' => array( |
101
|
|
|
'data-foogallery-change-selector' => 'input:radio', |
102
|
|
|
'data-foogallery-preview' => 'class' |
103
|
|
|
) |
104
|
|
|
); |
105
|
|
|
|
106
|
|
|
$fields[] = array( |
107
|
|
|
'id' => 'rounded_corners', |
108
|
|
|
'title' => __( 'Rounded Corners', 'foogallery' ), |
109
|
|
|
'desc' => __( 'The border radius, or rounded corners applied to each thumbnail', 'foogallery' ), |
110
|
|
|
'section' => __( 'Appearance', 'foogallery' ), |
111
|
|
|
'type' => 'radio', |
112
|
|
|
'spacer' => '<span class="spacer"></span>', |
113
|
|
|
'default' => '', |
114
|
|
|
'choices' => array( |
115
|
|
|
'' => __( 'None', 'foogallery' ), |
116
|
|
|
'fg-round-small' => __( 'Small', 'foogallery' ), |
117
|
|
|
'fg-round-medium' => __( 'Medium', 'foogallery' ), |
118
|
|
|
'fg-round-large' => __( 'Large', 'foogallery' ), |
119
|
|
|
'fg-round-full' => __( 'Full', 'foogallery' ), |
120
|
|
|
), |
121
|
|
|
'row_data' => array( |
122
|
|
|
'data-foogallery-change-selector' => 'input:radio', |
123
|
|
|
'data-foogallery-preview' => 'class' |
124
|
|
|
) |
125
|
|
|
); |
126
|
|
|
|
127
|
|
|
$fields[] = array( |
128
|
|
|
'id' => 'drop_shadow', |
129
|
|
|
'title' => __( 'Drop Shadow', 'foogallery' ), |
130
|
|
|
'desc' => __( 'The outer or drop shadow applied to each thumbnail', 'foogallery' ), |
131
|
|
|
'section' => __( 'Appearance', 'foogallery' ), |
132
|
|
|
'type' => 'radio', |
133
|
|
|
'spacer' => '<span class="spacer"></span>', |
134
|
|
|
'default' => 'fg-shadow-outline', |
135
|
|
|
'choices' => array( |
136
|
|
|
'' => __( 'None', 'foogallery' ), |
137
|
|
|
'fg-shadow-outline' => __( 'Outline', 'foogallery' ), |
138
|
|
|
'fg-shadow-small' => __( 'Small', 'foogallery' ), |
139
|
|
|
'fg-shadow-medium' => __( 'Medium', 'foogallery' ), |
140
|
|
|
'fg-shadow-large' => __( 'Large', 'foogallery' ), |
141
|
|
|
), |
142
|
|
|
'row_data' => array( |
143
|
|
|
'data-foogallery-change-selector' => 'input:radio', |
144
|
|
|
'data-foogallery-preview' => 'class' |
145
|
|
|
) |
146
|
|
|
); |
147
|
|
|
|
148
|
|
|
$fields[] = array( |
149
|
|
|
'id' => 'inner_shadow', |
150
|
|
|
'title' => __( 'Inner Shadow', 'foogallery' ), |
151
|
|
|
'desc' => __( 'The inner shadow applied to each thumbnail', 'foogallery' ), |
152
|
|
|
'section' => __( 'Appearance', 'foogallery' ), |
153
|
|
|
'type' => 'radio', |
154
|
|
|
'spacer' => '<span class="spacer"></span>', |
155
|
|
|
'default' => '', |
156
|
|
|
'choices' => array( |
157
|
|
|
'' => __( 'None', 'foogallery' ), |
158
|
|
|
'fg-shadow-inset-small' => __( 'Small', 'foogallery' ), |
159
|
|
|
'fg-shadow-inset-medium' => __( 'Medium', 'foogallery' ), |
160
|
|
|
'fg-shadow-inset-large' => __( 'Large', 'foogallery' ), |
161
|
|
|
), |
162
|
|
|
'row_data' => array( |
163
|
|
|
'data-foogallery-change-selector' => 'input:radio', |
164
|
|
|
'data-foogallery-preview' => 'class' |
165
|
|
|
) |
166
|
|
|
); |
167
|
|
|
|
168
|
|
|
$fields[] = array( |
169
|
|
|
'id' => 'loading_icon', |
170
|
|
|
'title' => __( 'Loading Icon', 'foogallery' ), |
171
|
|
|
'desc' => __( 'An animated loading icon can be shown while the thumbnails are busy loading.', 'foogallery' ), |
172
|
|
|
'section' => __( 'Appearance', 'foogallery' ), |
173
|
|
|
'default' => 'fg-loading-default', |
174
|
|
|
'type' => 'htmlicon', |
175
|
|
|
'choices' => apply_filters( |
176
|
|
|
'foogallery_gallery_template_common_thumbnail_fields_loading_icon_choices', array( |
177
|
|
|
'' => array( 'label' => __( 'None', 'foogallery' ), 'html' => '<div class="foogallery-setting-loading_icon"></div>' ), |
178
|
|
|
'fg-loading-default' => array( 'label' => __( 'Default', 'foogallery' ), 'html' => '<div class="foogallery-setting-loading_icon fg-loading-default"><div class="fg-loader"></div></div>' ), |
179
|
|
|
'fg-loading-bars' => array( 'label' => __( 'Bars', 'foogallery' ), 'html' => '<div class="foogallery-setting-loading_icon fg-loading-bars"><div class="fg-loader"></div></div>' ), |
180
|
|
|
'fg-loading-dots' => array( 'label' => __( 'Dots', 'foogallery' ), 'html' => '<div class="foogallery-setting-loading_icon fg-loading-dots"><div class="fg-loader"></div></div>' ), |
181
|
|
|
'fg-loading-partial' => array( 'label' => __( 'Partial', 'foogallery' ), 'html' => '<div class="foogallery-setting-loading_icon fg-loading-partial"><div class="fg-loader"></div></div>' ), |
182
|
|
|
'fg-loading-pulse' => array( 'label' => __( 'Pulse', 'foogallery' ), 'html' => '<div class="foogallery-setting-loading_icon fg-loading-pulse"><div class="fg-loader"></div></div>' ), |
183
|
|
|
'fg-loading-trail' => array( 'label' => __( 'Trail', 'foogallery' ), 'html' => '<div class="foogallery-setting-loading_icon fg-loading-trail"><div class="fg-loader"></div></div>' ), |
184
|
|
|
) |
185
|
|
|
), |
186
|
|
|
'row_data' => array( |
187
|
|
|
'data-foogallery-change-selector' => 'input:radio', |
188
|
|
|
'data-foogallery-preview' => 'class' |
189
|
|
|
) |
190
|
|
|
); |
191
|
|
|
|
192
|
|
|
$fields[] = array( |
193
|
|
|
'id' => 'loaded_effect', |
194
|
|
|
'title' => __( 'Loaded Effect', 'foogallery' ), |
195
|
|
|
'desc' => __( 'The animation effect used to display the thumbnail, once it has loaded.', 'foogallery' ), |
196
|
|
|
'section' => __( 'Appearance', 'foogallery' ), |
197
|
|
|
'default' => 'fg-loaded-fade-in', |
198
|
|
|
'type' => 'select', |
199
|
|
|
'choices' => apply_filters( |
200
|
|
|
'foogallery_gallery_template_common_thumbnail_fields_loaded_effect_choices', array( |
201
|
|
|
'' => __( 'None', 'foogallery' ), |
202
|
|
|
'fg-loaded-fade-in' => __( 'Fade In', 'foogallery' ), |
203
|
|
|
'fg-loaded-slide-up' => __( 'Slide Up', 'foogallery' ), |
204
|
|
|
'fg-loaded-slide-down' => __( 'Slide Down', 'foogallery' ), |
205
|
|
|
'fg-loaded-slide-left' => __( 'Slide Left', 'foogallery' ), |
206
|
|
|
'fg-loaded-slide-right' => __( 'Slide Right', 'foogallery' ), |
207
|
|
|
'fg-loaded-scale-up' => __( 'Scale Up', 'foogallery' ), |
208
|
|
|
'fg-loaded-swing-down' => __( 'Swing Down', 'foogallery' ), |
209
|
|
|
'fg-loaded-drop' => __( 'Drop', 'foogallery' ), |
210
|
|
|
'fg-loaded-fly' => __( 'Fly', 'foogallery' ), |
211
|
|
|
'fg-loaded-flip' => __( 'Flip', 'foogallery' ), |
212
|
|
|
) |
213
|
|
|
), |
214
|
|
|
'row_data' => array( |
215
|
|
|
'data-foogallery-change-selector' => 'input:radio', |
216
|
|
|
'data-foogallery-preview' => 'class' |
217
|
|
|
) |
218
|
|
|
); |
219
|
|
|
//endregion |
220
|
|
|
|
221
|
|
|
//region Hover Effects Fields |
222
|
|
|
$fields[] = array( |
223
|
|
|
'id' => 'hover_effect_help', |
224
|
|
|
'title' => __( 'Hover Effect Help', 'foogallery' ), |
225
|
|
|
'desc' => __( 'A preset provides a stylish and pre-defined look & feel for when you hover over the thumbnails.', 'foogallery' ), |
226
|
|
|
'section' => __( 'Hover Effects', 'foogallery' ), |
227
|
|
|
'type' => 'help' |
228
|
|
|
); |
229
|
|
|
|
230
|
|
|
$fields[] = array( |
231
|
|
|
'id' => 'hover_effect_preset', |
232
|
|
|
'title' => __( 'Preset', 'foogallery' ), |
233
|
|
|
'section' => __( 'Hover Effects', 'foogallery' ), |
234
|
|
|
'default' => 'fg-custom', |
235
|
|
|
'type' => 'radio', |
236
|
|
|
'choices' => apply_filters( |
237
|
|
|
'foogallery_gallery_template_common_thumbnail_fields_hover_effect_preset_choices', array( |
238
|
|
|
'' => __( 'None', 'foogallery' ), |
239
|
|
|
'fg-custom' => __( 'Custom', 'foogallery' ), |
240
|
|
|
) |
241
|
|
|
), |
242
|
|
|
'spacer' => '<span class="spacer"></span>', |
243
|
|
|
'desc' => __( 'A preset styling that is used for the captions. If you want to define your own custom captions, then choose Custom.', 'foogallery' ), |
244
|
|
|
'row_data' => array( |
245
|
|
|
'data-foogallery-change-selector' => 'input:radio', |
246
|
|
|
'data-foogallery-value-selector' => 'input:checked', |
247
|
|
|
'data-foogallery-preview' => 'class' |
248
|
|
|
) |
249
|
|
|
); |
250
|
|
|
|
251
|
|
|
$fields[] = array( |
252
|
|
|
'id' => 'hover_effect_preset_size', |
253
|
|
|
'title' => __( 'Preset Size', 'foogallery' ), |
254
|
|
|
'section' => __( 'Hover Effects', 'foogallery' ), |
255
|
|
|
'default' => 'fg-preset-small', |
256
|
|
|
'spacer' => '<span class="spacer"></span>', |
257
|
|
|
'type' => 'radio', |
258
|
|
|
'choices' => apply_filters( |
259
|
|
|
'foogallery_gallery_template_common_thumbnail_fields_hover_effect_preset_size_choices', array( |
260
|
|
|
'fg-preset-small' => __( 'Small', 'foogallery' ), |
261
|
|
|
'fg-preset-medium' => __( 'Medium', 'foogallery' ), |
262
|
|
|
'fg-preset-large' => __( 'Large', 'foogallery' ), |
263
|
|
|
) |
264
|
|
|
), |
265
|
|
|
'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' ), |
266
|
|
|
'row_data' => array( |
267
|
|
|
'data-foogallery-change-selector' => 'input:radio', |
268
|
|
|
'data-foogallery-hidden' => true, |
269
|
|
|
'data-foogallery-show-when-field' => 'hover_effect_preset', |
270
|
|
|
'data-foogallery-show-when-field-operator' => 'indexOf', |
271
|
|
|
'data-foogallery-show-when-field-value' => 'fg-preset', |
272
|
|
|
'data-foogallery-preview' => 'class' |
273
|
|
|
) |
274
|
|
|
); |
275
|
|
|
|
276
|
|
|
$fields[] = array( |
277
|
|
|
'id' => 'hover_effect_color', |
278
|
|
|
'title' => __( 'Color Effect', 'foogallery' ), |
279
|
|
|
'section' => __( 'Hover Effects', 'foogallery' ), |
280
|
|
|
'default' => '', |
281
|
|
|
'spacer' => '<span class="spacer"></span>', |
282
|
|
|
'type' => 'radio', |
283
|
|
|
'choices' => apply_filters( |
284
|
|
|
'foogallery_gallery_template_common_thumbnail_fields_hover_effect_color_choices', array( |
285
|
|
|
'' => __( 'None', 'foogallery' ), |
286
|
|
|
'fg-hover-colorize' => __( 'Colorize', 'foogallery' ), |
287
|
|
|
'fg-hover-grayscale' => __( 'Greyscale', 'foogallery' ), |
288
|
|
|
) |
289
|
|
|
), |
290
|
|
|
'desc' => __( 'Choose an color effect that is applied when you hover over a thumbnail.', 'foogallery' ), |
291
|
|
|
'row_data' => array( |
292
|
|
|
'data-foogallery-change-selector' => 'input:radio', |
293
|
|
|
'data-foogallery-hidden' => true, |
294
|
|
|
'data-foogallery-show-when-field' => 'hover_effect_preset', |
295
|
|
|
'data-foogallery-show-when-field-value' => 'fg-custom', |
296
|
|
|
'data-foogallery-preview' => 'class' |
297
|
|
|
) |
298
|
|
|
); |
299
|
|
|
|
300
|
|
|
$fields[] = array( |
301
|
|
|
'id' => 'hover_effect_scale', |
302
|
|
|
'title' => __( 'Scaling Effect', 'foogallery' ), |
303
|
|
|
'section' => __( 'Hover Effects', 'foogallery' ), |
304
|
|
|
'default' => '', |
305
|
|
|
'spacer' => '<span class="spacer"></span>', |
306
|
|
|
'type' => 'radio', |
307
|
|
|
'choices' => apply_filters( |
308
|
|
|
'foogallery_gallery_template_common_thumbnail_fields_hover_effect_scale_choices', array( |
309
|
|
|
'' => __( 'None', 'foogallery' ), |
310
|
|
|
'fg-hover-scale' => __( 'Scaled', 'foogallery' ), |
311
|
|
|
) |
312
|
|
|
), |
313
|
|
|
'desc' => __( 'Apply a slight scaling effect when hovering over a thumbnail.', 'foogallery' ), |
314
|
|
|
'row_data' => array( |
315
|
|
|
'data-foogallery-change-selector' => 'input:radio', |
316
|
|
|
'data-foogallery-hidden' => true, |
317
|
|
|
'data-foogallery-show-when-field' => 'hover_effect_preset', |
318
|
|
|
'data-foogallery-show-when-field-value' => 'fg-custom', |
319
|
|
|
'data-foogallery-preview' => 'class' |
320
|
|
|
) |
321
|
|
|
); |
322
|
|
|
|
323
|
|
|
$fields[] = array( |
324
|
|
|
'id' => 'hover_effect_caption_visibility', |
325
|
|
|
'title' => __( 'Caption Visibility', 'foogallery' ), |
326
|
|
|
'section' => __( 'Hover Effects', 'foogallery' ), |
327
|
|
|
'default' => 'fg-caption-hover', |
328
|
|
|
'spacer' => '<span class="spacer"></span>', |
329
|
|
|
'type' => 'radio', |
330
|
|
|
'choices' => apply_filters( |
331
|
|
|
'foogallery_gallery_template_common_thumbnail_fields_hover_effect_caption_visibility_choices', array( |
332
|
|
|
'' => __( 'None', 'foogallery' ), |
333
|
|
|
'fg-caption-hover' => __( 'On Hover', 'foogallery' ), |
334
|
|
|
'fg-caption-always' => __( 'Always Visible', 'foogallery' ), |
335
|
|
|
) |
336
|
|
|
), |
337
|
|
|
'desc' => __( 'Choose how the captions will be displayed.', 'foogallery' ), |
338
|
|
|
'row_data' => array( |
339
|
|
|
'data-foogallery-change-selector' => 'input:radio', |
340
|
|
|
'data-foogallery-hidden' => true, |
341
|
|
|
'data-foogallery-show-when-field' => 'hover_effect_preset', |
342
|
|
|
'data-foogallery-show-when-field-value' => 'fg-custom', |
343
|
|
|
'data-foogallery-preview' => 'class' |
344
|
|
|
) |
345
|
|
|
); |
346
|
|
|
|
347
|
|
|
$fields[] = array( |
348
|
|
|
'id' => 'hover_effect_transition', |
349
|
|
|
'title' => __( 'Transition', 'foogallery' ), |
350
|
|
|
'section' => __( 'Hover Effects', 'foogallery' ), |
351
|
|
|
'default' => 'fg-hover-fade', |
352
|
|
|
'type' => 'select', |
353
|
|
|
'choices' => apply_filters( 'foogallery_gallery_template_common_thumbnail_fields_hover_effect_transition_choices', array( |
354
|
|
|
'fg-hover-instant' => __( 'Instant', 'foogallery' ), |
355
|
|
|
'fg-hover-fade' => __( 'Fade', 'foogallery' ), |
356
|
|
|
'fg-hover-slide-up' => __( 'Slide Up', 'foogallery' ), |
357
|
|
|
'fg-hover-slide-down' => __( 'Slide Down', 'foogallery' ), |
358
|
|
|
'fg-hover-slide-left' => __( 'Slide Left', 'foogallery' ), |
359
|
|
|
'fg-hover-slide-right' => __( 'Slide Right', 'foogallery' ), |
360
|
|
|
'fg-hover-push' => __( 'Push', 'foogallery' ) ) |
361
|
|
|
), |
362
|
|
|
'desc' => __( 'Choose what effect is used to show the caption when you hover over a thumbnail', 'foogallery' ), |
363
|
|
|
'row_data' => array( |
364
|
|
|
'data-foogallery-change-selector' => 'select', |
365
|
|
|
'data-foogallery-hidden' => true, |
366
|
|
|
'data-foogallery-show-when-field' => 'hover_effect_preset', |
367
|
|
|
'data-foogallery-show-when-field-value' => 'fg-custom', |
368
|
|
|
'data-foogallery-preview' => 'class' |
369
|
|
|
) |
370
|
|
|
); |
371
|
|
|
|
372
|
|
|
$fields[] = array( |
373
|
|
|
'id' => 'hover_effect_icon', |
374
|
|
|
'title' => __( 'Icon', 'foogallery' ), |
375
|
|
|
'desc' => __( 'Choose which icon is shown with the caption when you hover over a thumbnail', 'foogallery' ), |
376
|
|
|
'section' => __( 'Hover Effects', 'foogallery' ), |
377
|
|
|
'type' => 'htmlicon', |
378
|
|
|
'default' => 'fg-hover-zoom', |
379
|
|
|
'choices' => apply_filters( 'foogallery_gallery_template_common_thumbnail_fields_hover_effect_icon_choices', array( |
380
|
|
|
'' => array( 'label' => __( 'None', 'foogallery' ), 'html' => '<div class="foogallery-setting-caption_icon"></div>' ), |
381
|
|
|
'fg-hover-zoom' => array( 'label' => __( 'Zoom', 'foogallery' ), 'html' => '<div class="foogallery-setting-caption_icon fg-hover-zoom"></div>' ), |
382
|
|
|
'fg-hover-zoom2' => array( 'label' => __( 'Zoom 2', 'foogallery' ), 'html' => '<div class="foogallery-setting-caption_icon fg-hover-zoom2"></div>' ), |
383
|
|
|
'fg-hover-zoom3' => array( 'label' => __( 'Zoom 3', 'foogallery' ), 'html' => '<div class="foogallery-setting-caption_icon fg-hover-zoom3"></div>' ), |
384
|
|
|
'fg-hover-plus' => array( 'label' => __( 'Plus', 'foogallery' ), 'html' => '<div class="foogallery-setting-caption_icon fg-hover-plus"></div>' ), |
385
|
|
|
'fg-hover-circle-plus' => array( 'label' => __( 'Circle Plus', 'foogallery' ), 'html' => '<div class="foogallery-setting-caption_icon fg-hover-circle-plus"></div>' ), |
386
|
|
|
'fg-hover-eye' => array( 'label' => __( 'Eye', 'foogallery' ), 'html' => '<div class="foogallery-setting-caption_icon fg-hover-eye"></div>' ), |
387
|
|
|
'fg-hover-external' => array( 'label' => __( 'External', 'foogallery' ), 'html' => '<div class="foogallery-setting-caption_icon fg-hover-external"></div>' ), ) |
388
|
|
|
), |
389
|
|
|
'row_data' => array( |
390
|
|
|
'data-foogallery-change-selector' => 'input:radio', |
391
|
|
|
'data-foogallery-hidden' => true, |
392
|
|
|
'data-foogallery-show-when-field' => 'hover_effect_preset', |
393
|
|
|
'data-foogallery-show-when-field-value' => 'fg-custom', |
394
|
|
|
'data-foogallery-preview' => 'class' |
395
|
|
|
) |
396
|
|
|
); |
397
|
|
|
//endregion Hover Effects Fields |
398
|
|
|
|
399
|
|
|
//region Caption Fields |
400
|
|
|
$fields[] = array( |
401
|
|
|
'id' => 'captions_help', |
402
|
|
|
'title' => __( 'Captions Help', 'foogallery' ), |
403
|
|
|
'desc' => __( 'You can change when captions are shown using the "Hover Effects -> Caption Visibility" setting .', 'foogallery' ), |
404
|
|
|
'section' => __( 'Captions', 'foogallery' ), |
405
|
|
|
'type' => 'help' |
406
|
|
|
); |
407
|
|
|
|
408
|
|
|
$settings_link = sprintf( '<a target="blank" href="%s">%s</a>', foogallery_admin_settings_url(), __( 'settings', 'foogallery' ) ); |
409
|
|
|
|
410
|
|
|
$fields[] = array( |
411
|
|
|
'id' => 'caption_title', |
412
|
|
|
'title' => __( 'Title', 'foogallery' ), |
413
|
|
|
'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' ), |
414
|
|
|
'section' => __( 'Captions', 'foogallery' ), |
415
|
|
|
'type' => 'radio', |
416
|
|
|
'default' => '', |
417
|
|
|
'choices' => array( |
418
|
|
|
'none' => __( 'None', 'foogallery' ), |
419
|
|
|
'' => sprintf( __( 'Default (as per %s)', 'foogallery' ), $settings_link ), |
420
|
|
|
'title' => foogallery_get_attachment_field_friendly_name( 'title' ), |
421
|
|
|
'caption' => foogallery_get_attachment_field_friendly_name( 'caption' ), |
422
|
|
|
'alt' => foogallery_get_attachment_field_friendly_name( 'alt' ), |
423
|
|
|
'desc' => foogallery_get_attachment_field_friendly_name( 'desc' ), |
424
|
|
|
), |
425
|
|
|
'row_data' => array( |
426
|
|
|
'data-foogallery-change-selector' => 'input:radio', |
427
|
|
|
'data-foogallery-preview' => 'shortcode' |
428
|
|
|
) |
429
|
|
|
); |
430
|
|
|
|
431
|
|
|
$fields[] = array( |
432
|
|
|
'id' => 'caption_desc', |
433
|
|
|
'title' => __( 'Description', 'foogallery' ), |
434
|
|
|
'desc' => __( 'Decide where captions descriptions are pulled from. By default, the general settings are used, but it can be overridden per gallery', 'foogallery' ), |
435
|
|
|
'section' => __( 'Captions', 'foogallery' ), |
436
|
|
|
'type' => 'radio', |
437
|
|
|
'default' => '', |
438
|
|
|
'choices' => array( |
439
|
|
|
'none' => __( 'None', 'foogallery' ), |
440
|
|
|
'' => sprintf( __( 'Default (as per %s)', 'foogallery' ), $settings_link ), |
441
|
|
|
'title' => foogallery_get_attachment_field_friendly_name( 'title' ), |
442
|
|
|
'caption' => foogallery_get_attachment_field_friendly_name( 'caption' ), |
443
|
|
|
'alt' => foogallery_get_attachment_field_friendly_name( 'alt' ), |
444
|
|
|
'desc' => foogallery_get_attachment_field_friendly_name( 'desc' ), |
445
|
|
|
), |
446
|
|
|
'row_data' => array( |
447
|
|
|
'data-foogallery-change-selector' => 'input:radio', |
448
|
|
|
'data-foogallery-preview' => 'shortcode' |
449
|
|
|
) |
450
|
|
|
); |
451
|
|
|
|
452
|
|
|
$fields[] = array( |
453
|
|
|
'id' => 'captions_limit_length', |
454
|
|
|
'title' => __( 'Limit Caption Length', 'foogallery' ), |
455
|
|
|
'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' ), |
456
|
|
|
'section' => __( 'Captions', 'foogallery' ), |
457
|
|
|
'default' => '', |
458
|
|
|
'type' => 'radio', |
459
|
|
|
'spacer' => '<span class="spacer"></span>', |
460
|
|
|
'choices' => array( |
461
|
|
|
'' => __( 'No', 'foogallery' ), |
462
|
|
|
'yes' => __( 'Yes', 'foogallery' ), |
463
|
|
|
), |
464
|
|
|
'row_data'=> array( |
465
|
|
|
'data-foogallery-change-selector' => 'input:radio', |
466
|
|
|
'data-foogallery-preview' => 'shortcode', |
467
|
|
|
'data-foogallery-value-selector' => 'input:checked', |
468
|
|
|
) |
469
|
|
|
); |
470
|
|
|
|
471
|
|
|
$fields[] = array( |
472
|
|
|
'id' => 'caption_title_length', |
473
|
|
|
'title' => __( 'Max Title Length', 'foogallery' ), |
474
|
|
|
'desc' => __( 'A max length of zero will not apply a limit.', 'foogallery '), |
475
|
|
|
'section' => __( 'Captions', 'foogallery' ), |
476
|
|
|
'type' => 'number', |
477
|
|
|
'class' => 'small-text', |
478
|
|
|
'default' => 0, |
479
|
|
|
'step' => '1', |
480
|
|
|
'min' => '0', |
481
|
|
|
'row_data' => array( |
482
|
|
|
'data-foogallery-change-selector' => 'input', |
483
|
|
|
'data-foogallery-hidden' => true, |
484
|
|
|
'data-foogallery-show-when-field' => 'captions_limit_length', |
485
|
|
|
'data-foogallery-show-when-field-value' => 'yes', |
486
|
|
|
'data-foogallery-preview' => 'shortcode' |
487
|
|
|
) |
488
|
|
|
); |
489
|
|
|
|
490
|
|
|
$fields[] = array( |
491
|
|
|
'id' => 'caption_desc_length', |
492
|
|
|
'title' => __( 'Max Desc Length', 'foogallery' ), |
493
|
|
|
'desc' => __( 'A max length of zero will not apply a limit.', 'foogallery '), |
494
|
|
|
'section' => __( 'Captions', 'foogallery' ), |
495
|
|
|
'type' => 'number', |
496
|
|
|
'class' => 'small-text', |
497
|
|
|
'default' => 0, |
498
|
|
|
'step' => '1', |
499
|
|
|
'min' => '0', |
500
|
|
|
'row_data' => array( |
501
|
|
|
'data-foogallery-change-selector' => 'input', |
502
|
|
|
'data-foogallery-hidden' => true, |
503
|
|
|
'data-foogallery-show-when-field' => 'captions_limit_length', |
504
|
|
|
'data-foogallery-show-when-field-value' => 'yes', |
505
|
|
|
'data-foogallery-preview' => 'shortcode' |
506
|
|
|
) |
507
|
|
|
); |
508
|
|
|
//endregion |
509
|
|
|
|
510
|
|
|
} |
511
|
|
|
return $fields; |
512
|
|
|
} |
513
|
|
|
|
514
|
|
|
/** |
515
|
|
|
* Build up the gallery class attribute for the common fields |
516
|
|
|
* |
517
|
|
|
* @param $classes array |
518
|
|
|
* @param $gallery FooGallery |
519
|
|
|
* |
520
|
|
|
* @return array |
521
|
|
|
*/ |
522
|
|
|
function add_common_fields_class_attributes( $classes, $gallery ) { |
|
|
|
|
523
|
|
|
$template_data = foogallery_get_gallery_template( $gallery->gallery_template ); |
524
|
|
|
|
525
|
|
|
//check the template supports common fields |
526
|
|
|
if ( $template_data && array_key_exists( 'common_fields_support', $template_data ) && true === $template_data['common_fields_support'] ) { |
527
|
|
|
|
528
|
|
|
//add the gallery template core class |
529
|
|
|
$classes[] = 'fg-' . $gallery->gallery_template; |
530
|
|
|
|
531
|
|
|
//get some default classes from common gallery settings |
532
|
|
|
$classes[] = $gallery->get_setting( 'theme', 'fg-light' ); |
533
|
|
|
$classes[] = $gallery->get_setting( 'border_size', 'fg-border-thin' ); |
534
|
|
|
$classes[] = $gallery->get_setting( 'rounded_corners', '' ); |
535
|
|
|
$classes[] = $gallery->get_setting( 'drop_shadow', 'fg-shadow-outline' ); |
536
|
|
|
$classes[] = $gallery->get_setting( 'inner_shadow', '' ); |
537
|
|
|
$classes[] = $gallery->get_setting( 'loading_icon', 'fg-loading-default' ); |
538
|
|
|
$classes[] = $gallery->get_setting( 'loaded_effect', 'fg-loaded-fade-in' ); |
539
|
|
|
|
540
|
|
|
$caption_preset = $gallery->get_setting( 'hover_effect_preset', 'fg-custom' ); |
541
|
|
|
|
542
|
|
|
$classes[] = $caption_preset; |
543
|
|
|
|
544
|
|
|
if ( 'fg-custom' === $caption_preset ) { |
545
|
|
|
//only set these caption classes if custom preset is selected |
546
|
|
|
$classes[] = $gallery->get_setting( 'hover_effect_color', '' ); |
547
|
|
|
$classes[] = $gallery->get_setting( 'hover_effect_scale', '' ); |
548
|
|
|
$classes[] = $gallery->get_setting( 'hover_effect_caption_visibility', 'fg-caption-hover' ); |
549
|
|
|
$classes[] = $gallery->get_setting( 'hover_effect_transition', 'fg-hover-fade' ); |
550
|
|
|
$classes[] = $gallery->get_setting( 'hover_effect_icon', 'fg-hover-zoom' ); |
551
|
|
|
} else if ( strpos( $caption_preset, 'fg-preset' ) !== false ) { |
552
|
|
|
//set a preset size |
553
|
|
|
$classes[] = $gallery->get_setting( 'hover_effect_preset_size', 'fg-preset-small' ); |
554
|
|
|
} |
555
|
|
|
} |
556
|
|
|
|
557
|
|
|
return $classes; |
558
|
|
|
} |
559
|
|
|
|
560
|
|
|
/** |
561
|
|
|
* Add the required data options for captions |
562
|
|
|
* |
563
|
|
|
* @param $options |
564
|
|
|
* @param $gallery FooGallery |
565
|
|
|
* |
566
|
|
|
* @param $attributes array |
567
|
|
|
* |
568
|
|
|
* @return array |
569
|
|
|
*/ |
570
|
|
|
function add_caption_data_options($options, $gallery, $attributes) { |
|
|
|
|
571
|
|
|
$template_data = foogallery_get_gallery_template( $gallery->gallery_template ); |
572
|
|
|
|
573
|
|
|
//check the template supports common fields |
574
|
|
|
if ( $template_data && array_key_exists( 'common_fields_support', $template_data ) && true === $template_data['common_fields_support'] ) { |
575
|
|
|
|
576
|
|
|
$caption_title = foogallery_gallery_template_setting( 'caption_title', '' ); |
577
|
|
|
$caption_desc = foogallery_gallery_template_setting( 'caption_desc', '' ); |
578
|
|
|
|
579
|
|
|
$options['item']['showCaptionTitle'] = $caption_title != 'none'; |
580
|
|
|
$options['item']['showCaptionDescription'] = $caption_desc != 'none'; |
581
|
|
|
|
582
|
|
|
$captions_limit_length = foogallery_gallery_template_setting( 'captions_limit_length', '' ); |
583
|
|
|
|
584
|
|
|
if ( 'yes' === $captions_limit_length ) { |
585
|
|
|
$caption_title_length = foogallery_gallery_template_setting( 'caption_title_length', '0' ); |
586
|
|
|
$caption_desc_length = foogallery_gallery_template_setting( 'caption_desc_length', '0' ); |
587
|
|
|
$options['item']['maxCaptionLength'] = intval( $caption_title_length ); |
588
|
|
|
$options['item']['maxDescriptionLength'] = intval( $caption_desc_length ); |
589
|
|
|
} |
590
|
|
|
} |
591
|
|
|
return $options; |
592
|
|
|
} |
593
|
|
|
|
594
|
|
|
/** |
595
|
|
|
* Build up a arguments used in the preview of the gallery |
596
|
|
|
* @param $args |
597
|
|
|
* @param $post_data |
598
|
|
|
* @param $template |
599
|
|
|
* |
600
|
|
|
* @return mixed |
601
|
|
|
*/ |
602
|
|
|
function preview_arguments( $args, $post_data, $template ) { |
|
|
|
|
603
|
|
|
$args['caption_title'] = $post_data[FOOGALLERY_META_SETTINGS][$template . '_caption_title']; |
604
|
|
|
$args['caption_desc'] = $post_data[FOOGALLERY_META_SETTINGS][$template . '_caption_desc']; |
605
|
|
|
$args['captions_limit_length'] = $post_data[FOOGALLERY_META_SETTINGS][$template . '_captions_limit_length']; |
606
|
|
|
$args['caption_title_length'] = $post_data[FOOGALLERY_META_SETTINGS][$template . '_caption_title_length']; |
607
|
|
|
$args['caption_desc_length'] = $post_data[FOOGALLERY_META_SETTINGS][$template . '_caption_desc_length']; |
608
|
|
|
return $args; |
609
|
|
|
} |
610
|
|
|
|
611
|
|
|
/** |
612
|
|
|
* Build up the gallery data attributes for the common fields |
613
|
|
|
* |
614
|
|
|
* @param $attributes array |
615
|
|
|
* @param $gallery FooGallery |
616
|
|
|
* |
617
|
|
|
* @return array |
618
|
|
|
*/ |
619
|
|
|
function add_common_fields_data_attribute( $attributes, $gallery ) { |
|
|
|
|
620
|
|
|
$template_data = foogallery_get_gallery_template( $gallery->gallery_template ); |
621
|
|
|
|
622
|
|
|
//check the template supports common fields |
623
|
|
|
if ( $template_data && array_key_exists( 'common_fields_support', $template_data ) && true === $template_data['common_fields_support'] ) { |
624
|
|
|
$attributes['data-fg-common-fields'] = true; |
625
|
|
|
} |
626
|
|
|
|
627
|
|
|
return $attributes; |
628
|
|
|
} |
629
|
|
|
} |
630
|
|
|
} |
Adding explicit visibility (
private
,protected
, orpublic
) is generally recommend to communicate to other developers how, and from where this method is intended to be used.