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