GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — feature/gallery-template-clien... ( 680944...fadc9b )
by Brad
04:57 queued 28s
created

alter_gallery_template_field()   B

Complexity

Conditions 6
Paths 7

Size

Total Lines 20
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 6
eloc 15
nc 7
nop 2
dl 0
loc 20
rs 8.8571
c 0
b 0
f 0
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 common data options
18
			add_filter( 'foogallery_build_container_data_options', array( $this, 'add_caption_data_options' ), 10, 3 );
19
20
			//build up any preview arguments
21
			add_filter( 'foogallery_preview_arguments', array( $this, 'preview_arguments' ), 10, 3 );
22
23
            //add common fields to the templates that support it
24
            add_filter( 'foogallery_override_gallery_template_fields', array( $this, 'add_common_fields' ), 10, 2 );
25
		}
26
27
        function alter_gallery_template_field( $field, $gallery ) {
28
            if ( $field ) {
29
                switch ( $field['type'] ) {
30
                    case 'thumb_link':
31
                        $field['type'] = 'radio';
32
                        $field['choices'] = foogallery_gallery_template_field_thumb_link_choices();
33
                        break;
34
                    case 'lightbox':
35
                        $field['lightbox'] = true;
36
                        $field['type'] = 'select';
37
                        $field['choices'] = foogallery_gallery_template_field_lightbox_choices();
38
                        break;
39
                }
40
41
                if ( isset($field['help']) && $field['help'] ) {
42
                    $field['type'] = 'help';
43
                }
44
            }
45
            return $field;
46
        }
47
48
		/**
49
		 * Add common fields to the gallery template if supported
50
		 *
51
		 * @param $fields
52
		 * @param $template
53
		 *
54
		 * @return array
55
		 */
56
		function add_common_fields( $fields, $template ) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
57
			//check if the template supports the common fields
58
			if ( $template && array_key_exists( 'common_fields_support', $template ) && true === $template['common_fields_support'] ) {
59
60
				//region Appearance Fields
61
				$fields[] = array(
62
					'id'       => 'theme',
63
					'title'    => __( 'Theme', 'foogallery' ),
64
					'desc'     => __( 'The overall appearance of the items in the gallery, affecting the border, background, font and shadow colors.', 'foogallery' ),
65
					'section'  => __( 'Appearance', 'foogallery' ),
66
					'type'     => 'radio',
67
					'default'  => 'fg-light',
68
					'spacer'   => '<span class="spacer"></span>',
69
					'choices'  => array(
70
						'fg-light'  => __( 'Light', 'foogallery' ),
71
						'fg-dark'   => __( 'Dark', 'foogallery' ),
72
						'fg-custom' => __( 'Custom', 'foogallery' )
73
					),
74
					'row_data' => array(
75
						'data-foogallery-change-selector' => 'input:radio',
76
						'data-foogallery-preview'         => 'class'
77
					)
78
				);
79
80
				$fields[] = array(
81
					'id'       => 'border_size',
82
					'title'    => __( 'Border Size', 'foogallery' ),
83
					'desc'     => __( 'The border size applied to each thumbnail', 'foogallery' ),
84
					'section'  => __( 'Appearance', 'foogallery' ),
85
					'type'     => 'radio',
86
					'spacer'   => '<span class="spacer"></span>',
87
					'default'  => 'fg-border-thin',
88
					'choices'  => array(
89
						''                 => __( 'None', 'foogallery' ),
90
						'fg-border-thin'   => __( 'Thin', 'foogallery' ),
91
						'fg-border-medium' => __( 'Medium', 'foogallery' ),
92
						'fg-border-thick'  => __( 'Thick', 'foogallery' ),
93
					),
94
					'row_data' => array(
95
						'data-foogallery-change-selector' => 'input:radio',
96
						'data-foogallery-preview'         => 'class'
97
					)
98
				);
99
100
				$fields[] = array(
101
					'id'       => 'rounded_corners',
102
					'title'    => __( 'Rounded Corners', 'foogallery' ),
103
					'desc'     => __( 'The border radius, or rounded corners applied to each thumbnail', 'foogallery' ),
104
					'section'  => __( 'Appearance', 'foogallery' ),
105
					'type'     => 'radio',
106
					'spacer'   => '<span class="spacer"></span>',
107
					'default'  => '',
108
					'choices'  => array(
109
						''                => __( 'None', 'foogallery' ),
110
						'fg-round-small'  => __( 'Small', 'foogallery' ),
111
						'fg-round-medium' => __( 'Medium', 'foogallery' ),
112
						'fg-round-large'  => __( 'Large', 'foogallery' ),
113
						'fg-round-full'   => __( 'Full', 'foogallery' ),
114
					),
115
					'row_data' => array(
116
						'data-foogallery-change-selector' => 'input:radio',
117
						'data-foogallery-preview'         => 'class'
118
					)
119
				);
120
121
				$fields[] = array(
122
					'id'       => 'drop_shadow',
123
					'title'    => __( 'Drop Shadow', 'foogallery' ),
124
					'desc'     => __( 'The outer or drop shadow applied to each thumbnail', 'foogallery' ),
125
					'section'  => __( 'Appearance', 'foogallery' ),
126
					'type'     => 'radio',
127
					'spacer'   => '<span class="spacer"></span>',
128
					'default'  => 'fg-shadow-outline',
129
					'choices'  => array(
130
						''                  => __( 'None', 'foogallery' ),
131
						'fg-shadow-outline' => __( 'Outline', 'foogallery' ),
132
						'fg-shadow-small'   => __( 'Small', 'foogallery' ),
133
						'fg-shadow-medium'  => __( 'Medium', 'foogallery' ),
134
						'fg-shadow-large'   => __( 'Large', 'foogallery' ),
135
					),
136
					'row_data' => array(
137
						'data-foogallery-change-selector' => 'input:radio',
138
						'data-foogallery-preview'         => 'class'
139
					)
140
				);
141
142
				$fields[] = array(
143
					'id'       => 'inner_shadow',
144
					'title'    => __( 'Inner Shadow', 'foogallery' ),
145
					'desc'     => __( 'The inner shadow applied to each thumbnail', 'foogallery' ),
146
					'section'  => __( 'Appearance', 'foogallery' ),
147
					'type'     => 'radio',
148
					'spacer'   => '<span class="spacer"></span>',
149
					'default'  => '',
150
					'choices'  => array(
151
						''                       => __( 'None', 'foogallery' ),
152
						'fg-shadow-inset-small'  => __( 'Small', 'foogallery' ),
153
						'fg-shadow-inset-medium' => __( 'Medium', 'foogallery' ),
154
						'fg-shadow-inset-large'  => __( 'Large', 'foogallery' ),
155
					),
156
					'row_data' => array(
157
						'data-foogallery-change-selector' => 'input:radio',
158
						'data-foogallery-preview'         => 'class'
159
					)
160
				);
161
162
				$fields[] = array(
163
					'id'       => 'loading_icon',
164
					'title'    => __( 'Loading Icon', 'foogallery' ),
165
					'desc'     => __( 'An animated loading icon can be shown while the thumbnails are busy loading.', 'foogallery' ),
166
					'section'  => __( 'Appearance', 'foogallery' ),
167
					'default'  => 'fg-loading-default',
168
					'type'     => 'htmlicon',
169
					'choices'  => apply_filters(
170
						'foogallery_gallery_template_common_thumbnail_fields_loading_icon_choices', array(
171
						''                   => array( 'label' => __( 'None', 'foogallery' ), 'html' => '<div class="foogallery-setting-loading_icon"></div>' ),
172
						'fg-loading-default' => array( 'label' => __( 'Default', 'foogallery' ), 'html' => '<div class="foogallery-setting-loading_icon fg-loading-default"><div class="fg-loader"></div></div>' ),
173
						'fg-loading-bars'    => array( 'label' => __( 'Bars', 'foogallery' ), 'html' => '<div class="foogallery-setting-loading_icon fg-loading-bars"><div class="fg-loader"></div></div>' ),
174
						'fg-loading-dots'    => array( 'label' => __( 'Dots', 'foogallery' ), 'html' => '<div class="foogallery-setting-loading_icon fg-loading-dots"><div class="fg-loader"></div></div>' ),
175
						'fg-loading-partial' => array( 'label' => __( 'Partial', 'foogallery' ), 'html' => '<div class="foogallery-setting-loading_icon fg-loading-partial"><div class="fg-loader"></div></div>' ),
176
						'fg-loading-pulse'   => array( 'label' => __( 'Pulse', 'foogallery' ), 'html' => '<div class="foogallery-setting-loading_icon fg-loading-pulse"><div class="fg-loader"></div></div>' ),
177
						'fg-loading-trail'   => array( 'label' => __( 'Trail', 'foogallery' ), 'html' => '<div class="foogallery-setting-loading_icon fg-loading-trail"><div class="fg-loader"></div></div>' ),
178
					)
179
					),
180
					'row_data' => array(
181
						'data-foogallery-change-selector' => 'input:radio',
182
						'data-foogallery-preview'         => 'class'
183
					)
184
				);
185
186
				$fields[] = array(
187
					'id'       => 'loaded_effect',
188
					'title'    => __( 'Loaded Effect', 'foogallery' ),
189
					'desc'     => __( 'The animation effect used to display the thumbnail, once it has loaded.', 'foogallery' ),
190
					'section'  => __( 'Appearance', 'foogallery' ),
191
					'default'  => 'fg-loaded-fade-in',
192
					'type'     => 'select',
193
					'choices'  => apply_filters(
194
						'foogallery_gallery_template_common_thumbnail_fields_loaded_effect_choices', array(
195
						''                      => __( 'None', 'foogallery' ),
196
						'fg-loaded-fade-in'     => __( 'Fade In', 'foogallery' ),
197
						'fg-loaded-slide-up'    => __( 'Slide Up', 'foogallery' ),
198
						'fg-loaded-slide-down'  => __( 'Slide Down', 'foogallery' ),
199
						'fg-loaded-slide-left'  => __( 'Slide Left', 'foogallery' ),
200
						'fg-loaded-slide-right' => __( 'Slide Right', 'foogallery' ),
201
						'fg-loaded-scale-up'    => __( 'Scale Up', 'foogallery' ),
202
						'fg-loaded-swing-down'  => __( 'Swing Down', 'foogallery' ),
203
						'fg-loaded-drop'        => __( 'Drop', 'foogallery' ),
204
						'fg-loaded-fly'         => __( 'Fly', 'foogallery' ),
205
						'fg-loaded-flip'        => __( 'Flip', 'foogallery' ),
206
					)
207
					),
208
					'row_data' => array(
209
						'data-foogallery-change-selector' => 'input:radio',
210
						'data-foogallery-preview'         => 'class'
211
					)
212
				);
213
				//endregion
214
215
				//region Hover Effects Fields
216
				$fields[] = array(
217
					'id'      => 'hover_effect_help',
218
					'title'   => __( 'Hover Effect Help', 'foogallery' ),
219
					'desc'    => __( 'A preset provides a stylish and pre-defined look &amp; feel for when you hover over the thumbnails.', 'foogallery' ),
220
					'section' => __( 'Hover Effects', 'foogallery' ),
221
					'type'    => 'help'
222
				);
223
224
				$fields[] = array(
225
					'id'       => 'hover_effect_preset',
226
					'title'    => __( 'Preset', 'foogallery' ),
227
					'section'  => __( 'Hover Effects', 'foogallery' ),
228
					'default'  => 'fg-custom',
229
					'type'     => 'radio',
230
					'choices'  => apply_filters(
231
						'foogallery_gallery_template_common_thumbnail_fields_hover_effect_preset_choices', array(
232
						''                     => __( 'None', 'foogallery' ),
233
						'fg-custom' => __( 'Custom', 'foogallery' ),
234
					)
235
					),
236
					'spacer'   => '<span class="spacer"></span>',
237
					'desc'     => __( 'A preset styling that is used for the captions. If you want to define your own custom captions, then choose Custom.', 'foogallery' ),
238
					'row_data' => array(
239
						'data-foogallery-change-selector' => 'input:radio',
240
						'data-foogallery-value-selector'  => 'input:checked',
241
						'data-foogallery-preview'         => 'class'
242
					)
243
				);
244
245
				$fields[] = array(
246
					'id'       => 'hover_effect_preset_size',
247
					'title'    => __( 'Preset Size', 'foogallery' ),
248
					'section'  => __( 'Hover Effects', 'foogallery' ),
249
					'default'  => 'fg-preset-small',
250
					'spacer'   => '<span class="spacer"></span>',
251
					'type'     => 'radio',
252
					'choices'  => apply_filters(
253
						'foogallery_gallery_template_common_thumbnail_fields_hover_effect_preset_size_choices', array(
254
						'fg-preset-small'  => __( 'Small', 'foogallery' ),
255
						'fg-preset-medium' => __( 'Medium', 'foogallery' ),
256
						'fg-preset-large'  => __( 'Large', 'foogallery' ),
257
					)
258
					),
259
					'desc'     => __( 'Choose an appropriate size for the preset caption effects, based on the size of your thumbs. Choose small for thumbs 150-200 wide, medium for thumbs 200-400 wide, and large for thumbs over 400 wide.', 'foogallery' ),
260
					'row_data' => array(
261
						'data-foogallery-change-selector'          => 'input:radio',
262
						'data-foogallery-hidden'                   => true,
263
						'data-foogallery-show-when-field'          => 'hover_effect_preset',
264
						'data-foogallery-show-when-field-operator' => 'indexOf',
265
						'data-foogallery-show-when-field-value'    => 'fg-preset',
266
						'data-foogallery-preview'                  => 'class'
267
					)
268
				);
269
270
				$fields[] = array(
271
					'id'       => 'hover_effect_color',
272
					'title'    => __( 'Color Effect', 'foogallery' ),
273
					'section'  => __( 'Hover Effects', 'foogallery' ),
274
					'default'  => '',
275
					'spacer'   => '<span class="spacer"></span>',
276
					'type'     => 'radio',
277
					'choices'  => apply_filters(
278
						'foogallery_gallery_template_common_thumbnail_fields_hover_effect_color_choices', array(
279
						''                   => __( 'None', 'foogallery' ),
280
						'fg-hover-colorize'  => __( 'Colorize', 'foogallery' ),
281
						'fg-hover-grayscale' => __( 'Greyscale', 'foogallery' ),
282
					)
283
					),
284
					'desc'     => __( 'Choose an color effect that is applied when you hover over a thumbnail.', 'foogallery' ),
285
					'row_data' => array(
286
						'data-foogallery-change-selector'       => 'input:radio',
287
						'data-foogallery-hidden'                => true,
288
						'data-foogallery-show-when-field'       => 'hover_effect_preset',
289
						'data-foogallery-show-when-field-value' => 'fg-custom',
290
						'data-foogallery-preview'               => 'class'
291
					)
292
				);
293
294
				$fields[] = array(
295
					'id'       => 'hover_effect_scale',
296
					'title'    => __( 'Scaling Effect', 'foogallery' ),
297
					'section'  => __( 'Hover Effects', 'foogallery' ),
298
					'default'  => '',
299
					'spacer'   => '<span class="spacer"></span>',
300
					'type'     => 'radio',
301
					'choices'  => apply_filters(
302
						'foogallery_gallery_template_common_thumbnail_fields_hover_effect_scale_choices', array(
303
						''               => __( 'None', 'foogallery' ),
304
						'fg-hover-scale' => __( 'Scaled', 'foogallery' ),
305
					)
306
					),
307
					'desc'     => __( 'Apply a slight scaling effect when hovering over a thumbnail.', 'foogallery' ),
308
					'row_data' => array(
309
						'data-foogallery-change-selector'       => 'input:radio',
310
						'data-foogallery-hidden'                => true,
311
						'data-foogallery-show-when-field'       => 'hover_effect_preset',
312
						'data-foogallery-show-when-field-value' => 'fg-custom',
313
						'data-foogallery-preview'               => 'class'
314
					)
315
				);
316
317
				$fields[] = array(
318
					'id'       => 'hover_effect_caption_visibility',
319
					'title'    => __( 'Caption Visibility', 'foogallery' ),
320
					'section'  => __( 'Hover Effects', 'foogallery' ),
321
					'default'  => 'fg-caption-hover',
322
					'spacer'   => '<span class="spacer"></span>',
323
					'type'     => 'radio',
324
					'choices'  => apply_filters(
325
						'foogallery_gallery_template_common_thumbnail_fields_hover_effect_caption_visibility_choices', array(
326
						''                  => __( 'None', 'foogallery' ),
327
						'fg-caption-hover'  => __( 'On Hover', 'foogallery' ),
328
						'fg-caption-always' => __( 'Always Visible', 'foogallery' ),
329
					)
330
					),
331
					'desc'     => __( 'Choose how the captions will be displayed.', '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_preset',
336
						'data-foogallery-show-when-field-value' => 'fg-custom',
337
						'data-foogallery-preview'               => 'class'
338
					)
339
				);
340
341
				$fields[] = array(
342
					'id'       => 'hover_effect_transition',
343
					'title'    => __( 'Transition', 'foogallery' ),
344
					'section'  => __( 'Hover Effects', 'foogallery' ),
345
					'default'  => 'fg-hover-fade',
346
					'type'     => 'select',
347
					'choices'  => apply_filters( 'foogallery_gallery_template_common_thumbnail_fields_hover_effect_transition_choices', array(
348
						'fg-hover-instant'     => __( 'Instant', 'foogallery' ),
349
						'fg-hover-fade'        => __( 'Fade', 'foogallery' ),
350
						'fg-hover-slide-up'    => __( 'Slide Up', 'foogallery' ),
351
						'fg-hover-slide-down'  => __( 'Slide Down', 'foogallery' ),
352
						'fg-hover-slide-left'  => __( 'Slide Left', 'foogallery' ),
353
						'fg-hover-slide-right' => __( 'Slide Right', 'foogallery' ),
354
						'fg-hover-push'        => __( 'Push', 'foogallery' ) )
355
					),
356
					'desc'     => __( 'Choose what effect is used to show the caption when you hover over a thumbnail', 'foogallery' ),
357
					'row_data' => array(
358
						'data-foogallery-change-selector'       => 'select',
359
						'data-foogallery-hidden'                => true,
360
						'data-foogallery-show-when-field'       => 'hover_effect_preset',
361
						'data-foogallery-show-when-field-value' => 'fg-custom',
362
						'data-foogallery-preview'               => 'class'
363
					)
364
				);
365
366
				$fields[] = array(
367
					'id'       => 'hover_effect_icon',
368
					'title'    => __( 'Icon', 'foogallery' ),
369
					'desc'     => __( 'Choose which icon is shown with the caption when you hover over a thumbnail', 'foogallery' ),
370
					'section'  => __( 'Hover Effects', 'foogallery' ),
371
					'type'     => 'htmlicon',
372
					'default'  => 'fg-hover-zoom',
373
					'choices'  => apply_filters( 'foogallery_gallery_template_common_thumbnail_fields_hover_effect_icon_choices', array(
374
						''                     => array( 'label' => __( 'None', 'foogallery' ), 'html' => '<div class="foogallery-setting-caption_icon"></div>' ),
375
						'fg-hover-zoom'        => array( 'label' => __( 'Zoom', 'foogallery' ), 'html' => '<div class="foogallery-setting-caption_icon fg-hover-zoom"></div>' ),
376
						'fg-hover-zoom2'       => array( 'label' => __( 'Zoom 2', 'foogallery' ), 'html' => '<div class="foogallery-setting-caption_icon fg-hover-zoom2"></div>' ),
377
						'fg-hover-zoom3'       => array( 'label' => __( 'Zoom 3', 'foogallery' ), 'html' => '<div class="foogallery-setting-caption_icon fg-hover-zoom3"></div>' ),
378
						'fg-hover-plus'        => array( 'label' => __( 'Plus', 'foogallery' ), 'html' => '<div class="foogallery-setting-caption_icon fg-hover-plus"></div>' ),
379
						'fg-hover-circle-plus' => array( 'label' => __( 'Circle Plus', 'foogallery' ), 'html' => '<div class="foogallery-setting-caption_icon fg-hover-circle-plus"></div>' ),
380
						'fg-hover-eye'         => array( 'label' => __( 'Eye', 'foogallery' ), 'html' => '<div class="foogallery-setting-caption_icon fg-hover-eye"></div>' ),
381
						'fg-hover-external'    => array( 'label' => __( 'External', 'foogallery' ), 'html' => '<div class="foogallery-setting-caption_icon fg-hover-external"></div>' ), )
382
					),
383
					'row_data' => array(
384
						'data-foogallery-change-selector'       => 'input:radio',
385
						'data-foogallery-hidden'                => true,
386
						'data-foogallery-show-when-field'       => 'hover_effect_preset',
387
						'data-foogallery-show-when-field-value' => 'fg-custom',
388
						'data-foogallery-preview'               => 'class'
389
					)
390
				);
391
				//endregion Hover Effects Fields
392
393
				//region Caption Fields
394
				$fields[] = array(
395
					'id'      => 'captions_help',
396
					'title'   => __( 'Captions Help', 'foogallery' ),
397
					'desc'    => __( 'You can change when captions are shown using the "Hover Effects -> Caption Visibility" setting .', 'foogallery' ),
398
					'section' => __( 'Captions', 'foogallery' ),
399
					'type'    => 'help'
400
				);
401
402
				$settings_link = sprintf( '<a target="blank" href="%s">%s</a>', foogallery_admin_settings_url(), __( 'settings', 'foogallery' ) );
403
404
				$fields[] = array(
405
					'id'       => 'caption_title',
406
					'title'    => __( 'Title', 'foogallery' ),
407
					'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' ),
408
					'section'  => __( 'Captions', 'foogallery' ),
409
					'type'     => 'radio',
410
					'default'  => '',
411
					'choices'  => array(
412
						'none'    => __( 'None', 'foogallery' ),
413
						''        => sprintf( __( 'Default (as per %s)', 'foogallery' ), $settings_link ),
414
						'title'   => foogallery_get_attachment_field_friendly_name( 'title' ),
415
						'caption' => foogallery_get_attachment_field_friendly_name( 'caption' ),
416
						'alt'     => foogallery_get_attachment_field_friendly_name( 'alt' ),
417
						'desc'    => foogallery_get_attachment_field_friendly_name( 'desc' ),
418
					),
419
					'row_data' => array(
420
						'data-foogallery-change-selector'       => 'input:radio',
421
						'data-foogallery-preview'               => 'shortcode'
422
					)
423
				);
424
425
				$fields[] = array(
426
					'id'       => 'caption_desc',
427
					'title'    => __( 'Description', 'foogallery' ),
428
					'desc'     => __( 'Decide where captions descriptions are pulled from. By default, the general settings are used, but it can be overridden per gallery', 'foogallery' ),
429
					'section'  => __( 'Captions', 'foogallery' ),
430
					'type'     => 'radio',
431
					'default'  => '',
432
					'choices'  => array(
433
						'none'    => __( 'None', 'foogallery' ),
434
						''        => sprintf( __( 'Default (as per %s)', 'foogallery' ), $settings_link ),
435
						'title'   => foogallery_get_attachment_field_friendly_name( 'title' ),
436
						'caption' => foogallery_get_attachment_field_friendly_name( 'caption' ),
437
						'alt'     => foogallery_get_attachment_field_friendly_name( 'alt' ),
438
						'desc'    => foogallery_get_attachment_field_friendly_name( 'desc' ),
439
					),
440
					'row_data' => array(
441
						'data-foogallery-change-selector'       => 'input:radio',
442
						'data-foogallery-preview'               => 'shortcode'
443
					)
444
				);
445
446
				$fields[] = array(
447
					'id'      => 'captions_limit_length',
448
					'title'   => __( 'Limit Caption Length', 'foogallery' ),
449
					'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' ),
450
					'section' => __( 'Captions', 'foogallery' ),
451
					'default' => '',
452
					'type'    => 'radio',
453
					'spacer'  => '<span class="spacer"></span>',
454
					'choices' => array(
455
						'' => __( 'No', 'foogallery' ),
456
						'yes' => __( 'Yes', 'foogallery' ),
457
					),
458
					'row_data'=> array(
459
						'data-foogallery-change-selector' => 'input:radio',
460
						'data-foogallery-preview' => 'shortcode',
461
						'data-foogallery-value-selector'  => 'input:checked',
462
					)
463
				);
464
465
				$fields[] = array(
466
					'id'      => 'caption_title_length',
467
					'title'   => __( 'Max Title Length', 'foogallery' ),
468
					'desc'	  => __( 'A max length of zero will not apply a limit.', 'foogallery '),
469
					'section' => __( 'Captions', 'foogallery' ),
470
					'type'    => 'number',
471
					'class'   => 'small-text',
472
					'default' => 0,
473
					'step'    => '1',
474
					'min'     => '0',
475
					'row_data' => array(
476
						'data-foogallery-change-selector'       => 'input',
477
						'data-foogallery-hidden'                => true,
478
						'data-foogallery-show-when-field'       => 'captions_limit_length',
479
						'data-foogallery-show-when-field-value' => 'yes',
480
						'data-foogallery-preview'               => 'shortcode'
481
					)
482
				);
483
484
				$fields[] = array(
485
					'id'      => 'caption_desc_length',
486
					'title'   => __( 'Max Desc Length', 'foogallery' ),
487
					'desc'	  => __( 'A max length of zero will not apply a limit.', 'foogallery '),
488
					'section' => __( 'Captions', 'foogallery' ),
489
					'type'    => 'number',
490
					'class'   => 'small-text',
491
					'default' => 0,
492
					'step'    => '1',
493
					'min'     => '0',
494
					'row_data' => array(
495
						'data-foogallery-change-selector'       => 'input',
496
						'data-foogallery-hidden'                => true,
497
						'data-foogallery-show-when-field'       => 'captions_limit_length',
498
						'data-foogallery-show-when-field-value' => 'yes',
499
						'data-foogallery-preview'               => 'shortcode'
500
					)
501
				);
502
				//endregion
503
504
			}
505
			return $fields;
506
		}
507
508
		/**
509
		 * Build up the gallery class attribute for the common fields
510
		 *
511
		 * @param $classes array
512
		 * @param $gallery FooGallery
513
		 *
514
		 * @return array
515
		 */
516
		function add_common_fields_class_attributes( $classes, $gallery ) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
517
			$template_data = foogallery_get_gallery_template( $gallery->gallery_template );
518
519
			//check the template supports common fields
520
			if ( $template_data && array_key_exists( 'common_fields_support', $template_data ) && true === $template_data['common_fields_support'] ) {
521
522
				//add the gallery template core class
523
				$classes[] = 'fg-' . $gallery->gallery_template;
524
525
				//get some default classes from common gallery settings
526
				$classes[] = $gallery->get_setting( 'theme', 'fg-light' );
527
				$classes[] = $gallery->get_setting( 'border_size', 'fg-border-thin' );
528
				$classes[] = $gallery->get_setting( 'rounded_corners', '' );
529
				$classes[] = $gallery->get_setting( 'drop_shadow', 'fg-shadow-outline' );
530
				$classes[] = $gallery->get_setting( 'inner_shadow', '' );
531
				$classes[] = $gallery->get_setting( 'loading_icon', 'fg-loading-default' );
532
				$classes[] = $gallery->get_setting( 'loaded_effect', 'fg-loaded-fade-in' );
533
534
				$caption_preset = $gallery->get_setting( 'hover_effect_preset', 'fg-custom' );
535
536
				$classes[] = $caption_preset;
537
538
				if ( 'fg-custom' === $caption_preset ) {
539
					//only set these caption classes if custom preset is selected
540
					$classes[] = $gallery->get_setting( 'hover_effect_color', '' );
541
					$classes[] = $gallery->get_setting( 'hover_effect_scale', '' );
542
					$classes[] = $gallery->get_setting( 'hover_effect_caption_visibility', 'fg-caption-hover' );
543
					$classes[] = $gallery->get_setting( 'hover_effect_transition', 'fg-hover-fade' );
544
					$classes[] = $gallery->get_setting( 'hover_effect_icon', 'fg-hover-zoom' );
545
				} else if ( strpos( $caption_preset, 'fg-preset' ) !== false ) {
546
					//set a preset size
547
					$classes[] = $gallery->get_setting( 'hover_effect_preset_size', 'fg-preset-small' );
548
				}
549
			}
550
551
			return $classes;
552
		}
553
554
		/**
555
		 * Add the required data options for captions
556
		 *
557
		 * @param $options
558
		 * @param $gallery    FooGallery
559
		 *
560
		 * @param $attributes array
561
		 *
562
		 * @return array
563
		 */
564
		function add_caption_data_options($options, $gallery, $attributes) {
0 ignored issues
show
Unused Code introduced by
The parameter $attributes is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
565
			$template_data = foogallery_get_gallery_template( $gallery->gallery_template );
566
567
			//check the template supports common fields
568
			if ( $template_data && array_key_exists( 'common_fields_support', $template_data ) && true === $template_data['common_fields_support'] ) {
569
570
				$caption_title = foogallery_gallery_template_setting( 'caption_title', '' );
571
				$caption_desc  = foogallery_gallery_template_setting( 'caption_desc', '' );
572
573
				$options['item']['showCaptionTitle']       = $caption_title != 'none';
574
				$options['item']['showCaptionDescription'] = $caption_desc != 'none';
575
576
				$captions_limit_length = foogallery_gallery_template_setting( 'captions_limit_length', '' );
577
578
				if ( 'yes' === $captions_limit_length ) {
579
					$caption_title_length                    = foogallery_gallery_template_setting( 'caption_title_length', '0' );
580
					$caption_desc_length                     = foogallery_gallery_template_setting( 'caption_desc_length', '0' );
581
					$options['item']['maxCaptionLength']     = intval( $caption_title_length );
582
					$options['item']['maxDescriptionLength'] = intval( $caption_desc_length );
583
				}
584
			}
585
			return $options;
586
		}
587
588
		/**
589
		 * Build up a arguments used in the preview of the gallery
590
		 * @param $args
591
		 * @param $post_data
592
		 * @param $template
593
		 *
594
		 * @return mixed
595
		 */
596
		function preview_arguments( $args, $post_data, $template ) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
597
			$args['caption_title'] = $post_data[FOOGALLERY_META_SETTINGS][$template . '_caption_title'];
598
			$args['caption_desc'] = $post_data[FOOGALLERY_META_SETTINGS][$template . '_caption_desc'];
599
			$args['captions_limit_length'] = $post_data[FOOGALLERY_META_SETTINGS][$template . '_captions_limit_length'];
600
			$args['caption_title_length'] = $post_data[FOOGALLERY_META_SETTINGS][$template . '_caption_title_length'];
601
			$args['caption_desc_length'] = $post_data[FOOGALLERY_META_SETTINGS][$template . '_caption_desc_length'];
602
			return $args;
603
		}
604
	}
605
}