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