PluginProbe ʕ •ᴥ•ʔ
Photo Gallery by FooGallery : Responsive Image Gallery, Masonry Gallery & Carousel / trunk
Photo Gallery by FooGallery : Responsive Image Gallery, Masonry Gallery & Carousel vtrunk
trunk 1.10.3 2.0.24 2.1.34 2.2.44 2.3.3 2.4.32 3.0.6 3.1.11 3.1.12 3.1.13 3.1.20 3.1.25 3.1.26 3.1.26.1 3.1.26.2
foogallery / includes / class-foogallery-common-fields.php
foogallery / includes Last commit date
admin 8 months ago compatibility 8 months ago extensions 8 months ago foopluginbase 8 months ago public 8 months ago thumbs 8 months ago .DS_Store 8 months ago class-attachment-filters.php 8 months ago class-foogallery-animated-gif-support.php 8 months ago class-foogallery-attachment-custom-class.php 8 months ago class-foogallery-attachment-type.php 8 months ago class-foogallery-attachment.php 8 months ago class-foogallery-cache.php 8 months ago class-foogallery-common-fields.php 8 months ago class-foogallery-crop-position.php 8 months ago class-foogallery-datasource-media_library.php 8 months ago class-foogallery-debug.php 8 months ago class-foogallery-extensions-compatibility.php 8 months ago class-foogallery-force-https.php 8 months ago class-foogallery-lazyload.php 8 months ago class-foogallery-lightbox.php 8 months ago class-foogallery-paging.php 8 months ago class-foogallery-password-protect.php 8 months ago class-foogallery-sitemaps.php 8 months ago class-foogallery-widget.php 8 months ago class-foogallery.php 8 months ago class-gallery-advanced-settings.php 8 months ago class-il8n.php 8 months ago class-override-thumbnail.php 8 months ago class-posttypes.php 8 months ago class-retina.php 8 months ago class-thumbnail-dimensions.php 8 months ago class-thumbnails.php 8 months ago class-version-check.php 8 months ago constants.php 8 months ago functions.php 8 months ago includes.php 8 months ago index.php 12 years ago render-functions.php 8 months ago
class-foogallery-common-fields.php
943 lines
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 add_filter( 'foogallery_build_container_attributes', array( $this, 'add_common_fields_attributes' ), 10, 2 );
24
25 //add common fields to the templates that support it
26 add_filter( 'foogallery_override_gallery_template_fields', array( $this, 'add_common_fields' ), 10, 2 );
27
28 //check that we are no longer on pro and have previously used a preset or a loaded effect
29 add_filter( 'foogallery_render_gallery_template_field_value', array( $this, 'check_downgrade_values' ), 10, 4 );
30
31 //override settings for older versions
32 add_filter( 'foogallery_settings_override', array( $this, 'override_settings_for_older_versions' ), 10, 3 );
33 }
34
35 function alter_gallery_template_field( $field, $gallery ) {
36 if ( $field ) {
37
38 if ( isset( $field['type'] ) ) {
39 switch ( $field['type'] ) {
40 case 'thumb_link':
41 $field['type'] = 'radio';
42 $field['class'] = 'foogallery-radios-stacked';
43 $field['choices'] = foogallery_gallery_template_field_thumb_link_choices();
44 if ( !isset( $field['row_data'] ) ) {
45 $field['row_data'] = array(
46 'data-foogallery-change-selector' => 'input:radio',
47 'data-foogallery-value-selector' => 'input:checked',
48 'data-foogallery-preview' => 'shortcode',
49 );
50 }
51 break;
52 case 'lightbox':
53 $field['lightbox'] = true;
54 $field['title'] = __( 'Lightbox', 'foogallery' );
55 $field['type'] = 'select';
56 $field['choices'] = foogallery_gallery_template_field_lightbox_choices();
57 if ( !array_key_exists( 'desc', $field ) ) {
58 $field['desc'] = __( 'Choose which lightbox you want to use. The lightbox will generally only work if you set the thumbnail link to "Full Size Image".', 'foogallery' );
59 }
60 if ( !array_key_exists( 'section', $field ) ) {
61 $field['section'] = __( 'Lightbox', 'foogallery' );
62 }
63 $field['subsection'] = array( 'lightbox-general' => __( 'General', 'foogallery' ) );
64 $field['default'] = 'foogallery';
65
66 if ( !isset( $field['row_data'] ) ) {
67 $field['row_data'] = array(
68 'data-foogallery-change-selector' => 'select',
69 'data-foogallery-value-selector' => 'select',
70 'data-foogallery-preview' => 'shortcode',
71 );
72 }
73 break;
74 }
75 }
76
77 if ( isset($field['help']) && $field['help'] ) {
78 $field['type'] = 'help';
79 }
80 }
81 return $field;
82 }
83
84 /**
85 * Add common fields to the gallery template if supported
86 *
87 * @param $fields
88 * @param $template
89 *
90 * @return array
91 */
92 function add_common_fields( $fields, $template ) {
93 //check if the template supports the common fields
94 if ( $template && array_key_exists( 'common_fields_support', $template ) && true === $template['common_fields_support'] ) {
95
96 //region Appearance Fields
97 $fields[] = array(
98 'id' => 'theme_custom_help',
99 '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' ),
100 'section' => __( 'Appearance', 'foogallery' ),
101 'type' => 'help',
102 'row_data' => array(
103 'data-foogallery-hidden' => true,
104 'data-foogallery-show-when-field' => 'theme',
105 'data-foogallery-show-when-field-value' => 'fg-custom',
106 )
107 );
108
109 $fields[] = array(
110 'id' => 'theme',
111 'title' => __( 'Theme', 'foogallery' ),
112 'desc' => __( 'The overall appearance of the items in the gallery, affecting the border, background, font and shadow colors.', 'foogallery' ),
113 'section' => __( 'Appearance', 'foogallery' ),
114 'type' => 'radio',
115 'default' => 'fg-light',
116 'choices' => array(
117 'fg-light' => __( 'Light', 'foogallery' ),
118 'fg-dark' => __( 'Dark', 'foogallery' ),
119 'fg-custom' => __( 'Custom', 'foogallery' )
120 ),
121 'row_data' => array(
122 'data-foogallery-change-selector' => 'input:radio',
123 'data-foogallery-value-selector' => 'input:checked',
124 'data-foogallery-preview' => 'shortcode'
125 )
126 );
127
128 $fields[] = array(
129 'id' => 'border_size',
130 'title' => __( 'Border Size', 'foogallery' ),
131 'desc' => __( 'The border size applied to each thumbnail', 'foogallery' ),
132 'section' => __( 'Appearance', 'foogallery' ),
133 'type' => 'radio',
134 'default' => 'fg-border-thin',
135 'choices' => array(
136 '' => __( 'None', 'foogallery' ),
137 'fg-border-thin' => __( 'Thin', 'foogallery' ),
138 'fg-border-medium' => __( 'Medium', 'foogallery' ),
139 'fg-border-thick' => __( 'Thick', 'foogallery' ),
140 ),
141 'row_data' => array(
142 'data-foogallery-change-selector' => 'input:radio',
143 'data-foogallery-preview' => 'shortcode'
144 )
145 );
146
147 $fields[] = array(
148 'id' => 'rounded_corners',
149 'title' => __( 'Rounded Corners', 'foogallery' ),
150 'desc' => __( 'The border radius, or rounded corners applied to each thumbnail', 'foogallery' ),
151 'section' => __( 'Appearance', 'foogallery' ),
152 'type' => 'radio',
153 'default' => '',
154 'choices' => array(
155 '' => __( 'None', 'foogallery' ),
156 'fg-round-small' => __( 'Small', 'foogallery' ),
157 'fg-round-medium' => __( 'Medium', 'foogallery' ),
158 'fg-round-large' => __( 'Large', 'foogallery' ),
159 'fg-round-full' => __( 'Full', 'foogallery' ),
160 ),
161 'row_data' => array(
162 'data-foogallery-change-selector' => 'input:radio',
163 'data-foogallery-preview' => 'shortcode'
164 )
165 );
166
167 $fields[] = array(
168 'id' => 'drop_shadow',
169 'title' => __( 'Drop Shadow', 'foogallery' ),
170 'desc' => __( 'The outer or drop shadow applied to each thumbnail', 'foogallery' ),
171 'section' => __( 'Appearance', 'foogallery' ),
172 'type' => 'radio',
173 'default' => 'fg-shadow-outline',
174 'choices' => array(
175 '' => __( 'None', 'foogallery' ),
176 'fg-shadow-outline' => __( 'Outline', 'foogallery' ),
177 'fg-shadow-small' => __( 'Small', 'foogallery' ),
178 'fg-shadow-medium' => __( 'Medium', 'foogallery' ),
179 'fg-shadow-large' => __( 'Large', 'foogallery' ),
180 ),
181 'row_data' => array(
182 'data-foogallery-change-selector' => 'input:radio',
183 'data-foogallery-preview' => 'shortcode'
184 )
185 );
186
187 $fields[] = array(
188 'id' => 'inner_shadow',
189 'title' => __( 'Inner Shadow', 'foogallery' ),
190 'desc' => __( 'The inner shadow applied to each thumbnail', 'foogallery' ),
191 'section' => __( 'Appearance', 'foogallery' ),
192 'type' => 'radio',
193 'default' => '',
194 'choices' => array(
195 '' => __( 'None', 'foogallery' ),
196 'fg-shadow-inset-outline' => __( 'Outline', 'foogallery' ),
197 'fg-shadow-inset-small' => __( 'Small', 'foogallery' ),
198 'fg-shadow-inset-medium' => __( 'Medium', 'foogallery' ),
199 'fg-shadow-inset-large' => __( 'Large', 'foogallery' ),
200 ),
201 'row_data' => array(
202 'data-foogallery-change-selector' => 'input:radio',
203 'data-foogallery-preview' => 'shortcode'
204 )
205 );
206
207 $fields[] = array(
208 'id' => 'loading_icon',
209 'title' => __( 'Loading Icon', 'foogallery' ),
210 'desc' => __( 'An animated loading icon can be shown while the thumbnails are busy loading.', 'foogallery' ),
211 'section' => __( 'Appearance', 'foogallery' ),
212 'default' => 'fg-loading-default',
213 'type' => 'htmlicon',
214 'choices' => apply_filters(
215 'foogallery_gallery_template_common_thumbnail_fields_loading_icon_choices', array(
216 '' => array( 'label' => __( 'None', 'foogallery' ), 'html' => '<div class="foogallery-setting-loading_icon"></div>' ),
217 'fg-loading-default' => array( 'label' => __( 'Default', 'foogallery' ), 'html' => '<div class="foogallery-setting-loading_icon foogallery fg-loading-default"><div class="fg-loading"><div class="fg-loader"></div></div></div>' ),
218 'fg-loading-bars' => array( 'label' => __( 'Bars', 'foogallery' ), 'html' => '<div class="foogallery-setting-loading_icon foogallery fg-loading-bars"><div class="fg-loading"><div class="fg-loader"></div></div></div>' ),
219 'fg-loading-dots' => array( 'label' => __( 'Dots', 'foogallery' ), 'html' => '<div class="foogallery-setting-loading_icon foogallery fg-loading-dots"><div class="fg-loading"><div class="fg-loader"></div></div></div>' ),
220 'fg-loading-partial' => array( 'label' => __( 'Partial', 'foogallery' ), 'html' => '<div class="foogallery-setting-loading_icon foogallery fg-loading-partial"><div class="fg-loading"><div class="fg-loader"></div></div></div>' ),
221 'fg-loading-pulse' => array( 'label' => __( 'Pulse', 'foogallery' ), 'html' => '<div class="foogallery-setting-loading_icon foogallery fg-loading-pulse"><div class="fg-loading"><div class="fg-loader"></div></div></div>' ),
222 'fg-loading-trail' => array( 'label' => __( 'Trail', 'foogallery' ), 'html' => '<div class="foogallery-setting-loading_icon foogallery fg-loading-trail"><div class="fg-loading"><div class="fg-loader"></div></div></div>' ),
223 )
224 ),
225 'row_data' => array(
226 'data-foogallery-change-selector' => 'input:radio',
227 'data-foogallery-value-selector' => 'input:checked',
228 'data-foogallery-preview' => 'shortcode'
229 )
230 );
231
232 $fields[] = array(
233 'id' => 'loaded_effect',
234 'title' => __( 'Loaded Effect', 'foogallery' ),
235 'desc' => __( 'The animation effect used to display the thumbnail, once it has loaded.', 'foogallery' ),
236 'section' => __( 'Appearance', 'foogallery' ),
237 'default' => 'fg-loaded-fade-in',
238 'type' => 'radio',
239 'choices' => apply_filters(
240 'foogallery_gallery_template_common_thumbnail_fields_loaded_effect_choices', array(
241 '' => __( 'None', 'foogallery' ),
242 'fg-loaded-fade-in' => __( 'Fade In', 'foogallery' ),
243 'fg-loaded-slide-up' => __( 'Slide Up', 'foogallery' ),
244 'fg-loaded-slide-down' => __( 'Slide Down', 'foogallery' ),
245 'fg-loaded-slide-left' => __( 'Slide Left', 'foogallery' ),
246 'fg-loaded-slide-right' => __( 'Slide Right', 'foogallery' ),
247 'fg-loaded-scale-up' => __( 'Scale Up', 'foogallery' ),
248 'fg-loaded-swing-down' => __( 'Swing Down', 'foogallery' ),
249 'fg-loaded-drop' => __( 'Drop', 'foogallery' ),
250 'fg-loaded-fly' => __( 'Fly', 'foogallery' ),
251 'fg-loaded-flip' => __( 'Flip', 'foogallery' ),
252 )
253 ),
254 'row_data' => array(
255 'data-foogallery-change-selector' => 'input:radio',
256 'data-foogallery-value-selector' => 'input:checked',
257 'data-foogallery-preview' => 'shortcode'
258 ),
259 'class' => 'foogallery-radios-12em',
260 );
261 //endregion
262
263 //region Hover Effects Fields
264 $fields[] = array(
265 'id' => 'hover_effect_type',
266 'title' => __( 'Hover Effect Type', 'foogallery' ),
267 'section' => __( 'Hover Effects', 'foogallery' ),
268 'default' => 'normal',
269 'type' => 'radio',
270 'choices' => apply_filters(
271 'foogallery_gallery_template_common_thumbnail_fields_hover_effect_type_choices', array(
272 'none' => array(
273 'label' => __( 'None', 'foogallery' ),
274 'tooltip' => __( 'No hover effect will be shown.', 'foogallery' )
275 ),
276 'normal' => array(
277 'label' => __( 'Normal (icons, captions, color, scaling & transitions)', 'foogallery' ),
278 'tooltip' => __( 'The standard hover effects with icons, captions, color, scaling & transitions', 'foogallery' )
279 ),
280 'preset' =>array(
281 'label' => __( 'Presets (stylish, pre-defined look & feel)', 'foogallery' ),
282 'tooltip' => __( 'A preset provides a stylish, pre-defined look & feel for the effect when you hover over the thumbnails.', 'foogallery' )
283 )
284 )
285 ),
286 'desc' => __( 'What type of hover effect do you want to show for your thumbnails?', 'foogallery' ),
287 'row_data' => array(
288 'data-foogallery-change-selector' => 'input:radio',
289 'data-foogallery-value-selector' => 'input:checked',
290 'data-foogallery-preview' => 'shortcode'
291 ),
292 'class' => 'foogallery-radios-stacked'
293 );
294
295 $fields[] = array(
296 'id' => 'hover_effect_preset',
297 'title' => __( 'Preset', 'foogallery' ),
298 'section' => __( 'Hover Effects', 'foogallery' ),
299 'default' => 'fg-preset fg-brad',
300 'type' => 'radio',
301 'choices' => apply_filters(
302 'foogallery_gallery_template_common_thumbnail_fields_hover_effect_preset_choices', array(
303 'fg-preset fg-brad' => __( 'Default', 'foogallery' ),
304 )
305 ),
306 'desc' => __( 'A preset styling that is used for the hover effect.', 'foogallery' ),
307 'row_data' => array(
308 'data-foogallery-change-selector' => 'input:radio',
309 'data-foogallery-value-selector' => 'input:checked',
310 'data-foogallery-preview' => 'shortcode',
311 'data-foogallery-hidden' => true,
312 'data-foogallery-show-when-field' => 'hover_effect_type',
313 'data-foogallery-show-when-field-value' => 'preset',
314 ),
315 'class' => 'foogallery-radios-12em',
316 );
317
318 $fields[] = array(
319 'id' => 'hover_effect_preset_size',
320 'title' => __( 'Preset Size', 'foogallery' ),
321 'section' => __( 'Hover Effects', 'foogallery' ),
322 'default' => 'fg-preset-small',
323 'type' => 'radio',
324 'choices' => apply_filters(
325 'foogallery_gallery_template_common_thumbnail_fields_hover_effect_preset_size_choices', array(
326 'fg-preset-small' => __( 'Small', 'foogallery' ),
327 'fg-preset-medium' => __( 'Medium', 'foogallery' ),
328 'fg-preset-large' => __( 'Large', 'foogallery' ),
329 )
330 ),
331 'desc' => __( 'Choose an appropriate size for the preset hover 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' ),
332 'row_data' => array(
333 'data-foogallery-change-selector' => 'input:radio',
334 'data-foogallery-hidden' => true,
335 'data-foogallery-show-when-field' => 'hover_effect_type',
336 'data-foogallery-show-when-field-value' => 'preset',
337 'data-foogallery-preview' => 'shortcode'
338 )
339 );
340
341 $fields[] = array(
342 'id' => 'caption_invert_color',
343 'title' => __( 'Theme', 'foogallery' ),
344 'desc' => __( 'Choose a color theme that will be used for the hover effect.', 'foogallery' ),
345 'section' => __( 'Hover Effects', 'foogallery' ),
346 'type' => 'radio',
347 'default' => '',
348 'choices' => apply_filters( 'foogallery_gallery_template_common_thumbnail_fields_caption_invert_color_choices', array(
349 '' => array(
350 'label' => __( 'Dark', 'foogallery' ),
351 'tooltip' => __('A dark overlay with white text is shown on hover', 'foogallery'),
352 ),
353 'fg-light-overlays' => array(
354 'label' => __( 'Light', 'foogallery' ),
355 'tooltip' => __('A white overlay with dark text is shown on hover', 'foogallery'),
356 ),
357 'fg-transparent-overlays' => array(
358 'label' => __( 'Transparent', 'foogallery' ),
359 'tooltip' => __('A transparent overlay with white text is shown on hover', 'foogallery'),
360 ),
361 ) ),
362 'row_data' => array(
363 'data-foogallery-change-selector' => 'input:radio',
364 'data-foogallery-hidden' => true,
365 'data-foogallery-show-when-field' => 'hover_effect_type',
366 'data-foogallery-show-when-field-value' => 'normal',
367 'data-foogallery-preview' => 'shortcode'
368 )
369 );
370
371 $fields[] = array(
372 'id' => 'hover_effect_color',
373 'title' => __( 'Color Effect', 'foogallery' ),
374 'section' => __( 'Hover Effects', 'foogallery' ),
375 'default' => '',
376 'type' => 'radio',
377 'choices' => apply_filters(
378 'foogallery_gallery_template_common_thumbnail_fields_hover_effect_color_choices', array(
379 '' => __( 'None', 'foogallery' ),
380 'fg-hover-colorize' => __( 'Colorize', 'foogallery' ),
381 'fg-hover-grayscale' => __( 'Greyscale', 'foogallery' ),
382 )
383 ),
384 'desc' => __( 'Choose an color effect that is applied when you hover over a thumbnail.', 'foogallery' ),
385 'row_data' => array(
386 'data-foogallery-change-selector' => 'input:radio',
387 'data-foogallery-hidden' => true,
388 'data-foogallery-show-when-field' => 'hover_effect_type',
389 'data-foogallery-show-when-field-value' => 'normal',
390 'data-foogallery-preview' => 'shortcode'
391 )
392 );
393
394 $fields[] = array(
395 'id' => 'hover_effect_scale',
396 'title' => __( 'Scaling Effect', 'foogallery' ),
397 'section' => __( 'Hover Effects', 'foogallery' ),
398 'default' => '',
399 'type' => 'radio',
400 'choices' => apply_filters(
401 'foogallery_gallery_template_common_thumbnail_fields_hover_effect_scale_choices', array(
402 '' => __( 'None', 'foogallery' ),
403 'fg-hover-scale' => __( 'Scaled', 'foogallery' ),
404 'fg-hover-zoomed' => __( 'Zoomed', 'foogallery' ),
405 'fg-hover-semi-zoomed' => __( 'Semi Zoomed', 'foogallery' ),
406 )
407 ),
408 'desc' => __( 'Apply a slight scaling effect when hovering over a thumbnail.', 'foogallery' ),
409 'row_data' => array(
410 'data-foogallery-change-selector' => 'input:radio',
411 'data-foogallery-hidden' => true,
412 'data-foogallery-show-when-field' => 'hover_effect_type',
413 'data-foogallery-show-when-field-value' => 'normal',
414 'data-foogallery-preview' => 'shortcode'
415 )
416 );
417
418 $fields[] = array(
419 'id' => 'hover_effect_transition',
420 'title' => __( 'Transition', 'foogallery' ),
421 'section' => __( 'Hover Effects', 'foogallery' ),
422 'default' => 'fg-hover-fade',
423 'type' => 'radio',
424 'choices' => apply_filters( 'foogallery_gallery_template_common_thumbnail_fields_hover_effect_transition_choices', array(
425 'fg-hover-instant' => __( 'Instant', 'foogallery' ),
426 'fg-hover-fade' => __( 'Fade', 'foogallery' ),
427 'fg-hover-slide-up' => __( 'Slide Up', 'foogallery' ),
428 'fg-hover-slide-down' => __( 'Slide Down', 'foogallery' ),
429 'fg-hover-slide-left' => __( 'Slide Left', 'foogallery' ),
430 'fg-hover-slide-right' => __( 'Slide Right', 'foogallery' ),
431 'fg-hover-push' => __( 'Push', 'foogallery' ) )
432 ),
433 'desc' => __( 'Choose what effect is used to show the caption when you hover over a thumbnail', 'foogallery' ),
434 'row_data' => array(
435 'data-foogallery-change-selector' => 'input:radio',
436 'data-foogallery-value-selector' => 'input:checked',
437 'data-foogallery-hidden' => true,
438 'data-foogallery-show-when-field' => 'hover_effect_type',
439 'data-foogallery-show-when-field-value' => 'normal',
440 'data-foogallery-preview' => 'shortcode'
441 )
442 );
443
444 $fields[] = array(
445 'id' => 'hover_effect_icon',
446 'title' => __( 'Icon', 'foogallery' ),
447 'desc' => __( 'Choose which icon is shown when you hover over a thumbnail', 'foogallery' ),
448 'section' => __( 'Hover Effects', 'foogallery' ),
449 'type' => 'htmlicon',
450 'default' => 'fg-hover-zoom',
451 'choices' => apply_filters( 'foogallery_gallery_template_common_thumbnail_fields_hover_effect_icon_choices', array(
452 '' => array( 'label' => __( 'None', 'foogallery' ), 'html' => '<div class="foogallery-setting-caption_icon"></div>' ),
453 'fg-hover-zoom' => array( 'label' => __( 'Zoom', 'foogallery' ), 'html' => '<div class="foogallery-setting-caption_icon fg-hover-zoom"></div>' ),
454 'fg-hover-zoom2' => array( 'label' => __( 'Zoom 2', 'foogallery' ), 'html' => '<div class="foogallery-setting-caption_icon fg-hover-zoom2"></div>' ),
455 'fg-hover-zoom3' => array( 'label' => __( 'Zoom 3', 'foogallery' ), 'html' => '<div class="foogallery-setting-caption_icon fg-hover-zoom3"></div>' ),
456 'fg-hover-zoom4' => array( 'label' => __( 'Zoom 4', 'foogallery' ), 'html' => '<div class="foogallery-setting-caption_icon fg-hover-zoom4"></div>' ),
457 'fg-hover-zoom5' => array( 'label' => __( 'Zoom 5', 'foogallery' ), 'html' => '<div class="foogallery-setting-caption_icon fg-hover-zoom5"></div>' ),
458 'fg-hover-plus' => array( 'label' => __( 'Plus', 'foogallery' ), 'html' => '<div class="foogallery-setting-caption_icon fg-hover-plus"></div>' ),
459 'fg-hover-plus2' => array( 'label' => __( 'Plus 2', 'foogallery' ), 'html' => '<div class="foogallery-setting-caption_icon fg-hover-plus2"></div>' ),
460 'fg-hover-plus3' => array( 'label' => __( 'Plus 3', 'foogallery' ), 'html' => '<div class="foogallery-setting-caption_icon fg-hover-plus3"></div>' ),
461 'fg-hover-circle-plus' => array( 'label' => __( 'Circle Plus', 'foogallery' ), 'html' => '<div class="foogallery-setting-caption_icon fg-hover-circle-plus"></div>' ),
462 'fg-hover-circle-plus2'=> array( 'label' => __( 'Circle Plus 2', 'foogallery' ), 'html' => '<div class="foogallery-setting-caption_icon fg-hover-circle-plus2"></div>' ),
463 'fg-hover-square-plus' => array( 'label' => __( 'Square Plus', 'foogallery' ), 'html' => '<div class="foogallery-setting-caption_icon fg-hover-square-plus"></div>' ),
464 'fg-hover-eye' => array( 'label' => __( 'Eye', 'foogallery' ), 'html' => '<div class="foogallery-setting-caption_icon fg-hover-eye"></div>' ),
465 'fg-hover-external' => array( 'label' => __( 'External', 'foogallery' ), 'html' => '<div class="foogallery-setting-caption_icon fg-hover-external"></div>' ),
466 )
467 ),
468 'row_data' => array(
469 'data-foogallery-change-selector' => 'input:radio',
470 'data-foogallery-value-selector' => 'input:checked',
471 'data-foogallery-hidden' => true,
472 'data-foogallery-show-when-field' => 'hover_effect_type',
473 'data-foogallery-show-when-field-value' => 'normal',
474 'data-foogallery-preview' => 'shortcode'
475 )
476 );
477
478 $fields[] = array(
479 'id' => 'hover_effect_icon_size',
480 'title' => __( 'Icon Size', 'foogallery' ),
481 'desc' => __( 'Choose the size of the icon that is displayed when you hover over a thumbnail.', 'foogallery' ),
482 'section' => __( 'Hover Effects', 'foogallery' ),
483 'type' => 'radio',
484 'default' => '',
485 'choices' => array(
486 '' => __( 'Default', 'foogallery' ),
487 '48' => __( '1.5x', 'foogallery' ),
488 '64' => __( '2x', 'foogallery' ),
489 '80' => __( '2.5x', 'foogallery' ),
490 '96' => __( '3x', 'foogallery' ),
491 ),
492 'row_data' => array(
493 'data-foogallery-change-selector' => 'input:radio',
494 'data-foogallery-value-selector' => 'input:checked',
495 'data-foogallery-hidden' => true,
496 'data-foogallery-show-when-field' => 'hover_effect_type',
497 'data-foogallery-show-when-field-value' => 'normal',
498 'data-foogallery-preview' => 'shortcode'
499 )
500 );
501 //endregion Hover Effects Fields
502
503 //region Caption Fields
504 $fields[] = array(
505 'id' => 'hover_effect_caption_visibility',
506 'title' => __( 'Caption Visibility', 'foogallery' ),
507 'section' => __( 'Captions', 'foogallery' ),
508 'default' => 'fg-caption-hover',
509 'type' => 'radio',
510 'choices' => apply_filters(
511 'foogallery_gallery_template_common_thumbnail_fields_hover_effect_caption_visibility_choices', array(
512 '' => __( 'Not shown', 'foogallery' ),
513 'fg-caption-hover' => __( 'On Hover', 'foogallery' ),
514 'fg-caption-always' => __( 'Always Visible', 'foogallery' ),
515 )
516 ),
517 'desc' => __( 'Choose when the captions will be displayed.', 'foogallery' ),
518 'row_data' => array(
519 'data-foogallery-change-selector' => 'input:radio',
520 'data-foogallery-hidden' => true,
521 'data-foogallery-show-when-field' => 'hover_effect_type',
522 'data-foogallery-show-when-field-value' => 'normal',
523 'data-foogallery-preview' => 'shortcode'
524 )
525 );
526
527 $fields[] = array(
528 'id' => 'caption_visibility_no_hover_effect',
529 'title' => __( 'Caption Visibility', 'foogallery' ),
530 'section' => __( 'Captions', 'foogallery' ),
531 'default' => '',
532 'type' => 'radio',
533 'choices' => apply_filters(
534 'foogallery_gallery_template_common_thumbnail_fields_caption_visibility_no_hover_effect_choices', array(
535 '' => __( 'Not shown', 'foogallery' ),
536 'fg-caption-always' => __( 'Always Visible', 'foogallery' ),
537 )
538 ),
539 'desc' => __( 'Choose when the captions will be displayed.', 'foogallery' ),
540 'row_data' => array(
541 'data-foogallery-change-selector' => 'input:radio',
542 'data-foogallery-hidden' => true,
543 'data-foogallery-show-when-field' => 'hover_effect_type',
544 'data-foogallery-show-when-field-value' => 'none',
545 'data-foogallery-preview' => 'shortcode'
546 )
547 );
548
549 $fields[] = array(
550 'id' => 'caption_color_no_hover_effect',
551 'title' => __( 'Caption Theme', 'foogallery' ),
552 'desc' => __( 'Choose the color theme for the captions.', 'foogallery' ),
553 'section' => __( 'Captions', 'foogallery' ),
554 'type' => 'radio',
555 'default' => '',
556 'choices' => apply_filters( 'foogallery_gallery_template_common_thumbnail_fields_caption_color_no_hover_effect_choices', array(
557 '' => array(
558 'label' => __( 'Dark', 'foogallery' ),
559 'tooltip' => __('A dark overlay with white text is shown for the captions', 'foogallery'),
560 ),
561 'fg-light-overlays' => array(
562 'label' => __( 'Light', 'foogallery' ),
563 'tooltip' => __('A white overlay with dark text is shown for the captions', 'foogallery'),
564 ),
565 'fg-transparent-overlays' => array(
566 'label' => __( 'Transparent', 'foogallery' ),
567 'tooltip' => __('A transparent overlay with white text is shown for the captions', 'foogallery'),
568 ),
569 ) ),
570 'row_data' => array(
571 'data-foogallery-change-selector' => 'input:radio',
572 'data-foogallery-hidden' => true,
573 'data-foogallery-show-when-field' => 'hover_effect_type',
574 'data-foogallery-show-when-field-value' => 'none',
575 'data-foogallery-preview' => 'shortcode'
576 )
577 );
578
579 $fields[] = array(
580 'id' => 'caption_alignment',
581 'title' => __( 'Caption Alignment', 'foogallery' ),
582 'desc' => __( 'Change the horizontal alignment of the thumbnail captions', 'foogallery' ),
583 'section' => __( 'Captions', 'foogallery' ),
584 'type' => 'radio',
585 'default' => '',
586 'choices' => array(
587 '' => __( 'Default', 'foogallery' ),
588 'fg-c-l' => __( 'Left', 'foogallery' ),
589 'fg-c-c' => __( 'Center', 'foogallery' ),
590 'fg-c-r' => __( 'Right', 'foogallery' ),
591 'fg-c-j' => __( 'Justify', 'foogallery' ),
592 ),
593 'row_data' => array(
594 'data-foogallery-change-selector' => 'input:radio',
595 'data-foogallery-preview' => 'shortcode'
596 )
597 );
598
599 $settings_link = sprintf( '<a target="blank" href="%s">%s</a>', foogallery_admin_settings_url(), __( 'settings', 'foogallery' ) );
600
601 $fields[] = array(
602 'id' => 'caption_title_source',
603 'title' => __( 'Title', 'foogallery' ),
604 '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' ),
605 'section' => __( 'Captions', 'foogallery' ),
606 'type' => 'radio',
607 'class' => 'foogallery-radios-stacked',
608 'default' => '',
609 'choices' => array(
610 'none' => __( 'None', 'foogallery' ),
611 '' => sprintf( __( 'Default (as per %s)', 'foogallery' ), $settings_link ),
612 'title' => foogallery_get_attachment_field_friendly_name( 'title' ),
613 'caption' => foogallery_get_attachment_field_friendly_name( 'caption' ),
614 'alt' => foogallery_get_attachment_field_friendly_name( 'alt' ),
615 'desc' => foogallery_get_attachment_field_friendly_name( 'desc' ),
616 ),
617 'row_data' => array(
618 'data-foogallery-change-selector' => 'input:radio',
619 'data-foogallery-preview' => 'shortcode'
620 )
621 );
622
623 $fields[] = array(
624 'id' => 'caption_desc_source',
625 'title' => __( 'Description', 'foogallery' ),
626 'desc' => __( 'Decide where captions descriptions are pulled from. By default, the general settings are used, but it can be overridden per gallery', 'foogallery' ),
627 'section' => __( 'Captions', 'foogallery' ),
628 'type' => 'radio',
629 'class' => 'foogallery-radios-stacked',
630 'default' => '',
631 'choices' => array(
632 'none' => __( 'None', 'foogallery' ),
633 '' => sprintf( __( 'Default (as per %s)', 'foogallery' ), $settings_link ),
634 'title' => foogallery_get_attachment_field_friendly_name( 'title' ),
635 'caption' => foogallery_get_attachment_field_friendly_name( 'caption' ),
636 'alt' => foogallery_get_attachment_field_friendly_name( 'alt' ),
637 'desc' => foogallery_get_attachment_field_friendly_name( 'desc' ),
638 ),
639 'row_data' => array(
640 'data-foogallery-change-selector' => 'input:radio',
641 'data-foogallery-preview' => 'shortcode'
642 )
643 );
644
645 $fields[] = array(
646 'id' => 'captions_limit_length',
647 'title' => __( 'Limit Caption Length', 'foogallery' ),
648 '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' ),
649 'section' => __( 'Captions', 'foogallery' ),
650 'default' => 'clamp',
651 'type' => 'radio',
652 'class' => 'foogallery-radios-stacked',
653 'choices' => array(
654 '' => __( 'No', 'foogallery' ),
655 'yes' => array(
656 'label' => __( 'Yes (by character length)', 'foogallery' ),
657 'tooltip' => __( 'Limit the length of the caption title and description by character length.', 'foogallery' ),
658 ),
659 'clamp' => array(
660 'label' => __( 'Yes (by lines)', 'foogallery' ),
661 'tooltip' => __( 'Limit the length of the caption title and description by the number of lines.', 'foogallery' ),
662 )
663 ),
664 'row_data'=> array(
665 'data-foogallery-change-selector' => 'input:radio',
666 'data-foogallery-preview' => 'shortcode',
667 'data-foogallery-value-selector' => 'input:checked',
668 )
669 );
670
671 $fields[] = array(
672 'id' => 'caption_title_length',
673 'title' => __( 'Max Title Length', 'foogallery' ),
674 'desc' => __( 'A max length of zero will not apply a limit.', 'foogallery '),
675 'section' => __( 'Captions', 'foogallery' ),
676 'type' => 'number',
677 'class' => 'small-text',
678 'default' => 0,
679 'step' => '1',
680 'min' => '0',
681 'row_data' => array(
682 'data-foogallery-change-selector' => 'input',
683 'data-foogallery-hidden' => true,
684 'data-foogallery-show-when-field' => 'captions_limit_length',
685 'data-foogallery-show-when-field-value' => 'yes',
686 'data-foogallery-preview' => 'shortcode'
687 )
688 );
689
690 $fields[] = array(
691 'id' => 'caption_desc_length',
692 'title' => __( 'Max Desc Length', 'foogallery' ),
693 'desc' => __( 'A max length of zero will not apply a limit.', 'foogallery '),
694 'section' => __( 'Captions', 'foogallery' ),
695 'type' => 'number',
696 'class' => 'small-text',
697 'default' => 0,
698 'step' => '1',
699 'min' => '0',
700 'row_data' => array(
701 'data-foogallery-change-selector' => 'input',
702 'data-foogallery-hidden' => true,
703 'data-foogallery-show-when-field' => 'captions_limit_length',
704 'data-foogallery-show-when-field-value' => 'yes',
705 'data-foogallery-preview' => 'shortcode'
706 )
707 );
708
709 $fields[] = array(
710 'id' => 'caption_title_clamp',
711 'title' => __( 'Max Title Lines', 'foogallery' ),
712 'desc' => __( 'A max number of lines of text to display. A value of zero will not apply a limit.', 'foogallery '),
713 'section' => __( 'Captions', 'foogallery' ),
714 'type' => 'number',
715 'class' => 'small-text',
716 'default' => 1,
717 'step' => '1',
718 'min' => '0',
719 'row_data' => array(
720 'data-foogallery-change-selector' => 'input',
721 'data-foogallery-hidden' => true,
722 'data-foogallery-show-when-field' => 'captions_limit_length',
723 'data-foogallery-show-when-field-value' => 'clamp',
724 'data-foogallery-preview' => 'shortcode'
725 )
726 );
727
728 $fields[] = array(
729 'id' => 'caption_desc_clamp',
730 'title' => __( 'Max Desc Lines', 'foogallery' ),
731 'desc' => __( 'A max number of lines of text to display. A value of zero will not apply a limit.', 'foogallery '),
732 'section' => __( 'Captions', 'foogallery' ),
733 'type' => 'number',
734 'class' => 'small-text',
735 'default' => 2,
736 'step' => '1',
737 'min' => '0',
738 'row_data' => array(
739 'data-foogallery-change-selector' => 'input',
740 'data-foogallery-hidden' => true,
741 'data-foogallery-show-when-field' => 'captions_limit_length',
742 'data-foogallery-show-when-field-value' => 'clamp',
743 'data-foogallery-preview' => 'shortcode'
744 )
745 );
746 //endregion
747
748 }
749 return $fields;
750 }
751
752 /**
753 * Build up the gallery class attribute for the common fields
754 *
755 * @param $classes array
756 * @param $gallery FooGallery
757 *
758 * @return array
759 */
760 function add_common_fields_class_attributes( $classes, $gallery ) {
761 if ( foogallery_current_gallery_check_template_has_supported_feature('common_fields_support' ) ) {
762
763 //add the gallery template core class
764 $classes[] = 'fg-' . $gallery->gallery_template;
765
766 //always add the fg-ready class, to avoid some javascript errors.
767 $classes[] = 'fg-ready';
768
769 //get some default classes from common gallery settings
770 $classes[] = foogallery_gallery_template_setting( 'theme', 'fg-light' );
771 $classes[] = foogallery_gallery_template_setting( 'border_size', 'fg-border-thin' );
772 $classes[] = foogallery_gallery_template_setting( 'rounded_corners', '' );
773 $classes[] = foogallery_gallery_template_setting( 'drop_shadow', 'fg-shadow-outline' );
774 $classes[] = foogallery_gallery_template_setting( 'inner_shadow', '' );
775 $classes[] = foogallery_gallery_template_setting( 'loading_icon', 'fg-loading-default' );
776 $classes[] = foogallery_gallery_template_setting( 'loaded_effect', 'fg-loaded-fade-in' );
777
778 $hover_effect_type = foogallery_gallery_template_setting( 'hover_effect_type', '' );
779
780 if ( 'normal' === $hover_effect_type ) {
781 $classes[] = foogallery_gallery_template_setting( 'hover_effect_color', '' );
782 $classes[] = foogallery_gallery_template_setting( 'hover_effect_scale', '' );
783 $classes[] = foogallery_gallery_template_setting( 'hover_effect_caption_visibility', 'fg-caption-hover' );
784 $classes[] = foogallery_gallery_template_setting( 'hover_effect_transition', 'fg-hover-fade' );
785 $classes[] = foogallery_gallery_template_setting( 'hover_effect_icon', 'fg-hover-zoom' );
786 $classes[] = foogallery_gallery_template_setting( 'caption_invert_color', '' );
787 } else if ( 'none' === $hover_effect_type ) {
788 $classes[] = foogallery_gallery_template_setting( 'caption_visibility_no_hover_effect', '' );
789 $classes[] = foogallery_gallery_template_setting( 'caption_color_no_hover_effect', '' );
790 } else if ( 'preset' === $hover_effect_type ) {
791 $classes[] = foogallery_gallery_template_setting( 'hover_effect_preset', 'fg-preset fg-brad' );
792 $classes[] = foogallery_gallery_template_setting( 'hover_effect_preset_size', 'fg-preset-small' );
793 }
794
795 $classes[] = foogallery_gallery_template_setting( 'caption_alignment', '' );
796
797 if ( 'preset' === foogallery_gallery_template_setting( 'hover_effect_type', '' ) ) {
798 $classes[] = foogallery_gallery_template_setting( 'hover_effect_preset', 'fg-preset fg-brad' );
799 $classes[] = foogallery_gallery_template_setting( 'hover_effect_preset_size', 'fg-preset-small' );
800 }
801 }
802
803 return $classes;
804 }
805
806 /**
807 * Add the required data options for captions
808 *
809 * @param $options
810 * @param $gallery FooGallery
811 *
812 * @param $attributes array
813 *
814 * @return array
815 */
816 function add_caption_data_options($options, $gallery, $attributes) {
817 //check the template supports common fields
818 if ( foogallery_current_gallery_check_template_has_supported_feature('common_fields_support' ) ) {
819
820 $caption_title = foogallery_gallery_template_setting( 'caption_title_source', '' );
821 $caption_desc = foogallery_gallery_template_setting( 'caption_desc_source', '' );
822
823 $options['item']['showCaptionTitle'] = $caption_title !== 'none';
824 $options['item']['showCaptionDescription'] = $caption_desc !== 'none';
825
826 $captions_limit_length = foogallery_gallery_template_setting( 'captions_limit_length', 'clamp' );
827
828 if ( 'yes' === $captions_limit_length ) {
829 $caption_title_length = foogallery_gallery_template_setting( 'caption_title_length', '0' );
830 $caption_desc_length = foogallery_gallery_template_setting( 'caption_desc_length', '0' );
831 $options['item']['maxCaptionLength'] = intval( $caption_title_length );
832 $options['item']['maxDescriptionLength'] = intval( $caption_desc_length );
833 }
834 }
835 return $options;
836 }
837
838 function add_common_fields_attributes($attributes, $gallery) {
839 //check the template supports common fields
840 if ( foogallery_current_gallery_check_template_has_supported_feature('common_fields_support' ) ) {
841 $captions_limit_length = foogallery_gallery_template_setting( 'captions_limit_length', 'clamp' );
842
843 if ( 'clamp' === $captions_limit_length ) {
844 $caption_title_clamp = intval( foogallery_gallery_template_setting( 'caption_title_clamp', '0' ) );
845 $caption_desc_clamp = intval( foogallery_gallery_template_setting( 'caption_desc_clamp', '0' ) );
846 } else {
847 $caption_title_clamp = $caption_desc_clamp = 0;
848 }
849 $style = "--fg-title-line-clamp: {$caption_title_clamp}; --fg-description-line-clamp: {$caption_desc_clamp};";
850 if ( empty( $attributes['style'] ) ) {
851 $attributes['style'] = $style;
852 } else {
853 $attributes['style'] .= $style;
854 }
855 }
856
857 return $attributes;
858 }
859
860 /**
861 * Build up the gallery data attributes for the common fields
862 *
863 * @param $attributes array
864 * @param $gallery FooGallery
865 *
866 * @return array
867 */
868 function add_common_fields_data_attribute( $attributes, $gallery ) {
869 //check the template supports common fields
870 if ( is_admin() && foogallery_current_gallery_check_template_has_supported_feature('common_fields_support' ) ) {
871 $attributes['data-fg-common-fields'] = true;
872 }
873
874 $icon_size = intval( foogallery_gallery_template_setting( 'hover_effect_icon_size', '0' ) );
875 if ( $icon_size > 0 ) {
876 $style = "--fg-icon-size: {$icon_size}px;";
877 if ( empty($attributes['style']) ) {
878 $attributes['style'] = $style;
879 } else {
880 $attributes['style'] .= $style;
881 }
882 }
883
884 return $attributes;
885 }
886
887 /***
888 * Check if we have a value from PRO and change it if PRO is no longer active
889 * @param $value
890 * @param $field
891 * @param $gallery
892 * @param $template
893 *
894 * @return string
895 */
896 function check_downgrade_values($value, $field, $gallery, $template) {
897
898 if ( isset( $field['type'] ) ) {
899 if ( 'hover_effect_preset' === $field['id'] || 'loaded_effect' === $field['type'] ) {
900 if ( !array_key_exists( $value, $field['choices'] ) ) {
901 $value = $field['default'];
902 }
903 }
904 }
905
906 return $value;
907 }
908
909 /**
910 * Override settings from older versions (pre v1.9.13)
911 *
912 * @param $settings
913 * @param $gallery_template
914 * @param $foogallery
915 *
916 * @return array
917 */
918 function override_settings_for_older_versions( $settings, $gallery_template, $foogallery ) {
919 if ( is_array( $settings ) ) {
920 if ( ! array_key_exists( $gallery_template . '_hover_effect_type', $settings ) ) {
921 //we have no hover effect type
922
923 if ( array_key_exists( $gallery_template . '_hover_effect_preset', $settings ) ) {
924 $hover_effect_preset = $settings[ $gallery_template . '_hover_effect_preset' ];
925
926 if ( 'fg-custom' === $hover_effect_preset ) {
927 $settings[ $gallery_template . '_hover_effect_type' ] = 'normal';
928 } else if ( '' === $hover_effect_preset ) {
929 $settings[ $gallery_template . '_hover_effect_type' ] = 'none';
930 } else if ( strpos( $hover_effect_preset, 'fg-preset' ) !== false ) {
931 $settings[ $gallery_template . '_hover_effect_type' ] = 'preset';
932 }
933 } else {
934 //no hover effect type or hover effect preset set
935 $settings[ $gallery_template . '_hover_effect_type' ] = 'normal';
936 }
937 }
938 }
939
940 return $settings;
941 }
942 }
943 }