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