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.

Issues (1881)

Security Analysis    not enabled

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

includes/class-foogallery-common-fields.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

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

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
530
531
		    if ( isset( $current_foogallery ) && $current_foogallery === $gallery ) {
532
		        return foogallery_gallery_template_setting( $key, $default );
533
            }
534
535
		    return $gallery->get_setting( $key, $default );
536
        }
537
538
		/**
539
		 * Build up the gallery class attribute for the common fields
540
		 *
541
		 * @param $classes array
542
		 * @param $gallery FooGallery
543
		 *
544
		 * @return array
545
		 */
546
		function add_common_fields_class_attributes( $classes, $gallery ) {
547
			$template_data = foogallery_get_gallery_template( $gallery->gallery_template );
548
549
			//check the template supports common fields
550
			if ( $template_data && array_key_exists( 'common_fields_support', $template_data ) && true === $template_data['common_fields_support'] ) {
551
552
				//add the gallery template core class
553
				$classes[] = 'fg-' . $gallery->gallery_template;
554
555
				//get some default classes from common gallery settings
556
				$classes[] = $this->get_setting_from_gallery( $gallery, 'theme', 'fg-light' );
557
				$classes[] = $this->get_setting_from_gallery( $gallery, 'border_size', 'fg-border-thin' );
558
				$classes[] = $this->get_setting_from_gallery( $gallery, 'rounded_corners', '' );
559
				$classes[] = $this->get_setting_from_gallery( $gallery, 'drop_shadow', 'fg-shadow-outline' );
560
				$classes[] = $this->get_setting_from_gallery( $gallery, 'inner_shadow', '' );
561
				$classes[] = $this->get_setting_from_gallery( $gallery, 'loading_icon', 'fg-loading-default' );
562
				$classes[] = $this->get_setting_from_gallery( $gallery, 'loaded_effect', 'fg-loaded-fade-in' );
563
564
				$caption_preset = $this->get_setting_from_gallery( $gallery,'hover_effect_preset', 'fg-custom' );
565
566
				$classes[] = $caption_preset;
567
568
				if ( 'fg-custom' === $caption_preset ) {
569
					//only set these caption classes if custom preset is selected
570
					$classes[] = $this->get_setting_from_gallery( $gallery, 'hover_effect_color', '' );
571
					$classes[] = $this->get_setting_from_gallery( $gallery, 'hover_effect_scale', '' );
572
					$classes[] = $this->get_setting_from_gallery( $gallery, 'hover_effect_caption_visibility', 'fg-caption-hover' );
573
					$classes[] = $this->get_setting_from_gallery( $gallery, 'hover_effect_transition', 'fg-hover-fade' );
574
					$classes[] = $this->get_setting_from_gallery( $gallery, 'hover_effect_icon', 'fg-hover-zoom' );
575
				} else if ( strpos( $caption_preset, 'fg-preset' ) !== false ) {
576
					//set a preset size
577
					$classes[] = $this->get_setting_from_gallery( $gallery, 'hover_effect_preset_size', 'fg-preset-small' );
578
				}
579
580
				if ( foogallery_get_setting( 'enable_custom_ready' ) ) {
581
                    $classes[] = 'fg-ready';
582
                }
583
			}
584
585
			return $classes;
586
		}
587
588
		/**
589
		 * Add the required data options for captions
590
		 *
591
		 * @param $options
592
		 * @param $gallery    FooGallery
593
		 *
594
		 * @param $attributes array
595
		 *
596
		 * @return array
597
		 */
598
		function add_caption_data_options($options, $gallery, $attributes) {
599
			$template_data = foogallery_get_gallery_template( $gallery->gallery_template );
600
601
			//check the template supports common fields
602
			if ( $template_data && array_key_exists( 'common_fields_support', $template_data ) && true === $template_data['common_fields_support'] ) {
603
604
				$caption_title = foogallery_gallery_template_setting( 'caption_title_source', '' );
605
				$caption_desc  = foogallery_gallery_template_setting( 'caption_desc_source', '' );
606
607
				$options['item']['showCaptionTitle']       = $caption_title != 'none';
608
				$options['item']['showCaptionDescription'] = $caption_desc != 'none';
609
610
				$captions_limit_length = foogallery_gallery_template_setting( 'captions_limit_length', '' );
611
612
				if ( 'yes' === $captions_limit_length ) {
613
					$caption_title_length                    = foogallery_gallery_template_setting( 'caption_title_length', '0' );
614
					$caption_desc_length                     = foogallery_gallery_template_setting( 'caption_desc_length', '0' );
615
					$options['item']['maxCaptionLength']     = intval( $caption_title_length );
616
					$options['item']['maxDescriptionLength'] = intval( $caption_desc_length );
617
				}
618
			}
619
			return $options;
620
		}
621
622
		/**
623
		 * Build up a arguments used in the preview of the gallery
624
		 * @param $args
625
		 * @param $post_data
626
		 * @param $template
627
		 *
628
		 * @return mixed
629
		 */
630
		function preview_arguments( $args, $post_data, $template ) {
631
			$args['caption_title_source'] = $post_data[FOOGALLERY_META_SETTINGS][$template . '_caption_title_source'];
632
			$args['caption_desc_source'] = $post_data[FOOGALLERY_META_SETTINGS][$template . '_caption_desc_source'];
633
			$args['captions_limit_length'] = $post_data[FOOGALLERY_META_SETTINGS][$template . '_captions_limit_length'];
634
			$args['caption_title_length'] = $post_data[FOOGALLERY_META_SETTINGS][$template . '_caption_title_length'];
635
			$args['caption_desc_length'] = $post_data[FOOGALLERY_META_SETTINGS][$template . '_caption_desc_length'];
636
			return $args;
637
		}
638
639
		/**
640
		 * Build up the gallery data attributes for the common fields
641
		 *
642
		 * @param $attributes array
643
		 * @param $gallery FooGallery
644
		 *
645
		 * @return array
646
		 */
647
		function add_common_fields_data_attribute( $attributes, $gallery ) {
648
			$template_data = foogallery_get_gallery_template( $gallery->gallery_template );
649
650
			//check the template supports common fields
651
			if ( $template_data && array_key_exists( 'common_fields_support', $template_data ) && true === $template_data['common_fields_support'] ) {
652
				$attributes['data-fg-common-fields'] = true;
653
			}
654
655
			return $attributes;
656
		}
657
658
        /***
659
         * Check if we have a value from FooBox free and change it if foobox free is no longer active
660
         * @param $value
661
         * @param $field
662
         * @param $gallery
663
         * @param $template
664
         *
665
         * @return string
666
         */
667
        function check_downgrade_values($value, $field, $gallery, $template) {
668
669
            if ( isset( $field['type'] ) ) {
670
                if ( 'hover_effect_preset' === $field['id'] || 'loaded_effect' === $field['type'] ) {
671
                    if ( !array_key_exists( $value, $field['choices'] ) ) {
672
                        $value = $field['default'];
673
                    }
674
                }
675
            }
676
677
            return $value;
678
        }
679
	}
680
}