Passed
Push — master ( 30a2aa...91cade )
by Brian
17:46 queued 12:03
created

sd_get_float_group()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 17
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 10
nc 2
nop 2
dl 0
loc 17
rs 9.9332
c 0
b 0
f 0
1
<?php
2
/**
3
 * A file for common functions.
4
 */
5
6
/**
7
 * Return an array of global $pagenow page names that should be used to exclude register_widgets.
8
 *
9
 * Used to block the loading of widgets on certain wp-admin pages to save on memory.
10
 *
11
 * @return mixed|void
12
 */
13
function sd_pagenow_exclude() {
14
	return apply_filters(
15
		'sd_pagenow_exclude',
16
		array(
17
			'upload.php',
18
			'edit-comments.php',
19
			'edit-tags.php',
20
			'index.php',
21
			'media-new.php',
22
			'options-discussion.php',
23
			'options-writing.php',
24
			'edit.php',
25
			'themes.php',
26
			'users.php',
27
		)
28
	);
29
}
30
31
32
/**
33
 * Return an array of widget class names that should be excluded.
34
 *
35
 * Used to conditionally load widgets code.
36
 *
37
 * @return mixed|void
38
 */
39
function sd_widget_exclude() {
40
	return apply_filters( 'sd_widget_exclude', array() );
41
}
42
43
44
/**
45
 * A helper function for margin inputs.
46
 *
47
 * @param string $type
48
 * @param array $overwrite
49
 *
50
 * @return array
51
 */
52
function sd_get_margin_input( $type = 'mt', $overwrite = array(), $include_negatives = true ) {
53
	global $aui_bs5;
54
	$options = array(
55
		''     => __( 'None', 'super-duper' ),
56
		'auto' => __( 'auto', 'super-duper' ),
57
		'0'    => '0',
58
		'1'    => '1',
59
		'2'    => '2',
60
		'3'    => '3',
61
		'4'    => '4',
62
		'5'    => '5',
63
		'6'    => '6',
64
		'7'    => '7',
65
		'8'    => '8',
66
		'9'    => '9',
67
		'10'   => '10',
68
		'11'   => '11',
69
		'12'   => '12',
70
	);
71
72
	if ( $include_negatives ) {
73
		$options['n1']  = '-1';
74
		$options['n2']  = '-2';
75
		$options['n3']  = '-3';
76
		$options['n4']  = '-4';
77
		$options['n5']  = '-5';
78
		$options['n6']  = '-6';
79
		$options['n7']  = '-7';
80
		$options['n8']  = '-8';
81
		$options['n9']  = '-9';
82
		$options['n10'] = '-10';
83
		$options['n11'] = '-11';
84
		$options['n12'] = '-12';
85
	}
86
87
	$defaults = array(
88
		'type'     => 'select',
89
		'title'    => __( 'Margin top', 'super-duper' ),
90
		'options'  => $options,
91
		'default'  => '',
92
		'desc_tip' => true,
93
		'group'    => __( 'Wrapper Styles', 'super-duper' ),
94
	);
95
96
	// title
97
	if ( $type == 'mt' ) {
98
		$defaults['title'] = __( 'Margin top', 'super-duper' );
99
		$defaults['icon']  = 'box-top';
100
		$defaults['row']   = array(
101
			'title' => __( 'Margins', 'super-duper' ),
102
			'key'   => 'wrapper-margins',
103
			'open'  => true,
104
			'class' => 'text-center',
105
		);
106
	} elseif ( $type == 'mr' ) {
107
		$defaults['title'] = __( 'Margin right', 'super-duper' );
108
		$defaults['icon']  = 'box-right';
109
		$defaults['row']   = array(
110
			'key' => 'wrapper-margins',
111
		);
112
	} elseif ( $type == 'mb' ) {
113
		$defaults['title'] = __( 'Margin bottom', 'super-duper' );
114
		$defaults['icon']  = 'box-bottom';
115
		$defaults['row']   = array(
116
			'key' => 'wrapper-margins',
117
		);
118
	} elseif ( $type == 'ml' ) {
119
		$defaults['title'] = __( 'Margin left', 'super-duper' );
120
		$defaults['icon']  = 'box-left';
121
		$defaults['row']   = array(
122
			'key'   => 'wrapper-margins',
123
			'close' => true,
124
		);
125
	}
126
127
	$input = wp_parse_args( $overwrite, $defaults );
128
129
	return $input;
130
}
131
132
/**
133
 * A helper function for padding inputs.
134
 *
135
 * @param string $type
136
 * @param array $overwrite
137
 *
138
 * @return array
139
 */
140
function sd_get_padding_input( $type = 'pt', $overwrite = array() ) {
141
	$options = array(
142
		''   => __( 'None', 'super-duper' ),
143
		'0'  => '0',
144
		'1'  => '1',
145
		'2'  => '2',
146
		'3'  => '3',
147
		'4'  => '4',
148
		'5'  => '5',
149
		'6'  => '6',
150
		'7'  => '7',
151
		'8'  => '8',
152
		'9'  => '9',
153
		'10' => '10',
154
		'11' => '11',
155
		'12' => '12',
156
	);
157
158
	$defaults = array(
159
		'type'     => 'select',
160
		'title'    => __( 'Padding top', 'super-duper' ),
161
		'options'  => $options,
162
		'default'  => '',
163
		'desc_tip' => true,
164
		'group'    => __( 'Wrapper Styles', 'super-duper' ),
165
	);
166
167
	// title
168
	if ( $type == 'pt' ) {
169
		$defaults['title'] = __( 'Padding top', 'super-duper' );
170
		$defaults['icon']  = 'box-top';
171
		$defaults['row']   = array(
172
			'title' => __( 'Padding', 'super-duper' ),
173
			'key'   => 'wrapper-padding',
174
			'open'  => true,
175
			'class' => 'text-center',
176
		);
177
	} elseif ( $type == 'pr' ) {
178
		$defaults['title'] = __( 'Padding right', 'super-duper' );
179
		$defaults['icon']  = 'box-right';
180
		$defaults['row']   = array(
181
			'key' => 'wrapper-padding',
182
		);
183
	} elseif ( $type == 'pb' ) {
184
		$defaults['title'] = __( 'Padding bottom', 'super-duper' );
185
		$defaults['icon']  = 'box-bottom';
186
		$defaults['row']   = array(
187
			'key' => 'wrapper-padding',
188
		);
189
	} elseif ( $type == 'pl' ) {
190
		$defaults['title'] = __( 'Padding left', 'super-duper' );
191
		$defaults['icon']  = 'box-left';
192
		$defaults['row']   = array(
193
			'key'   => 'wrapper-padding',
194
			'close' => true,
195
196
		);
197
	}
198
199
	$input = wp_parse_args( $overwrite, $defaults );
200
201
	return $input;
202
}
203
204
/**
205
 * A helper function for border inputs.
206
 *
207
 * @param string $type
208
 * @param array $overwrite
209
 *
210
 * @return array
211
 */
212
function sd_get_border_input( $type = 'border', $overwrite = array() ) {
213
	global $aui_bs5;
214
215
	$defaults = array(
216
		'type'     => 'select',
217
		'title'    => __( 'Border' ),
218
		'options'  => array(),
219
		'default'  => '',
220
		'desc_tip' => true,
221
		'group'    => __( 'Wrapper Styles', 'geodirectory' ),
222
	);
223
224
	// title
225
	if ( 'rounded' === $type ) {
226
		$defaults['title']           = __( 'Border radius type', 'super-duper' );
227
		$defaults['options']         = array(
228
			''               => __( 'Default', 'super-duper' ),
229
			'rounded'        => 'rounded',
230
			'rounded-top'    => 'rounded-top',
231
			'rounded-right'  => 'rounded-right',
232
			'rounded-bottom' => 'rounded-bottom',
233
			'rounded-left'   => 'rounded-left',
234
		);
235
		$defaults['element_require'] = '[%border%]';
236
	} elseif ( 'rounded_size' === $type ) {
237
		$defaults['title'] = __( 'Border radius size', 'super-duper' );
238
239
		if ( $aui_bs5 ) {
240
			$defaults['options'] = array(
241
				''       => __( 'Default', 'super-duper' ),
242
				'0'      => '0',
243
				'1'      => '1',
244
				'2'      => '2',
245
				'3'      => '3',
246
				'4'      => '4',
247
				'circle' => 'circle',
248
				'pill'   => 'pill',
249
			);
250
		} else {
251
			$defaults['options'] = array(
252
				''   => __( 'Default', 'super-duper' ),
253
				'sm' => __( 'Small', 'super-duper' ),
254
				'lg' => __( 'Large', 'super-duper' ),
255
			);
256
		}
257
		$defaults['element_require'] = '[%border%]';
258
	} elseif ( 'width' === $type ) { // BS%
259
		$defaults['title']           = __( 'Border width', 'super-duper' );
260
		$defaults['options']         = array(
261
			''         => __( 'Default', 'super-duper' ),
262
			'border-2' => '2',
263
			'border-3' => '3',
264
			'border-4' => '4',
265
			'border-5' => '5',
266
		);
267
		$defaults['element_require'] = $aui_bs5 ? '[%border%]' : '1==2';
268
	} elseif ( 'opacity' === $type ) { // BS%
269
		$defaults['title']           = __( 'Border opacity', 'super-duper' );
270
		$defaults['options']         = array(
271
			''                  => __( 'Default', 'super-duper' ),
272
			'border-opacity-75' => '75%',
273
			'border-opacity-50' => '50%',
274
			'border-opacity-25' => '25%',
275
			'border-opacity-10' => '10%',
276
		);
277
		$defaults['element_require'] = $aui_bs5 ? '[%border%]' : '1==2';
278
	} elseif ( 'type' === $type ) {
279
		$defaults['title']           = __( 'Border show', 'super-duper' );
280
		$defaults['options']         = array(
281
			'border'          => __( 'Full (set color to show)', 'super-duper' ),
282
			'border-top'      => __( 'Top', 'super-duper' ),
283
			'border-bottom'   => __( 'Bottom', 'super-duper' ),
284
			'border-left'     => __( 'Left', 'super-duper' ),
285
			'border-right'    => __( 'Right', 'super-duper' ),
286
			'border-top-0'    => __( '-Top', 'super-duper' ),
287
			'border-bottom-0' => __( '-Bottom', 'super-duper' ),
288
			'border-left-0'   => __( '-Left', 'super-duper' ),
289
			'border-right-0'  => __( '-Right', 'super-duper' ),
290
		);
291
		$defaults['element_require'] = '[%border%]';
292
293
	} else {
294
		$defaults['title']   = __( 'Border color' );
295
		$defaults['options'] = array(
296
			                       ''  => __( 'Default', 'super-duper' ),
297
			                       '0' => __( 'None', 'super-duper' ),
298
		                       ) + sd_aui_colors();
299
	}
300
301
	$input = wp_parse_args( $overwrite, $defaults );
302
303
	return $input;
304
}
305
306
/**
307
 * A helper function for shadow inputs.
308
 *
309
 * @param string $type
310
 * @param array $overwrite
311
 *
312
 * @return array
313
 */
314
function sd_get_shadow_input( $type = 'shadow', $overwrite = array() ) {
0 ignored issues
show
Unused Code introduced by
The parameter $type is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

314
function sd_get_shadow_input( /** @scrutinizer ignore-unused */ $type = 'shadow', $overwrite = array() ) {

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

Loading history...
315
	$options = array(
316
		''          => __( 'None', 'super-duper' ),
317
		'shadow-sm' => __( 'Small', 'super-duper' ),
318
		'shadow'    => __( 'Regular', 'super-duper' ),
319
		'shadow-lg' => __( 'Large', 'super-duper' ),
320
	);
321
322
	$defaults = array(
323
		'type'     => 'select',
324
		'title'    => __( 'Shadow', 'super-duper' ),
325
		'options'  => $options,
326
		'default'  => '',
327
		'desc_tip' => true,
328
		'group'    => __( 'Wrapper Styles', 'super-duper' ),
329
	);
330
331
	$input = wp_parse_args( $overwrite, $defaults );
332
333
	return $input;
334
}
335
336
/**
337
 * A helper function for background inputs.
338
 *
339
 * @param string $type
340
 * @param array $overwrite
341
 *
342
 * @return array
343
 */
344
function sd_get_background_input( $type = 'bg', $overwrite = array() ) {
0 ignored issues
show
Unused Code introduced by
The parameter $type is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

344
function sd_get_background_input( /** @scrutinizer ignore-unused */ $type = 'bg', $overwrite = array() ) {

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

Loading history...
345
	$options = array(
346
		           ''            => __( 'None', 'super-duper' ),
347
		           'transparent' => __( 'Transparent', 'super-duper' ),
348
	           ) + sd_aui_colors();
349
350
	$defaults = array(
351
		'type'     => 'select',
352
		'title'    => __( 'Background color', 'super-duper' ),
353
		'options'  => $options,
354
		'default'  => '',
355
		'desc_tip' => true,
356
		'group'    => __( 'Wrapper Styles', 'super-duper' ),
357
	);
358
359
	$input = wp_parse_args( $overwrite, $defaults );
360
361
	return $input;
362
}
363
364
/**
365
 * A function to get th opacity options.
366
 *
367
 * @param $type
368
 * @param $overwrite
369
 *
370
 * @return array
371
 */
372
function sd_get_opacity_input( $type = 'opacity', $overwrite = array() ) {
0 ignored issues
show
Unused Code introduced by
The parameter $type is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

372
function sd_get_opacity_input( /** @scrutinizer ignore-unused */ $type = 'opacity', $overwrite = array() ) {

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

Loading history...
373
	$options = array(
374
		''            => __( 'Default', 'super-duper' ),
375
		'opacity-10'  => '10%',
376
		'opacity-15'  => '15%',
377
		'opacity-25'  => '25%',
378
		'opacity-35'  => '35%',
379
		'opacity-40'  => '40%',
380
		'opacity-50'  => '50%',
381
		'opacity-60'  => '60%',
382
		'opacity-65'  => '65%',
383
		'opacity-70'  => '70%',
384
		'opacity-75'  => '75%',
385
		'opacity-80'  => '80%',
386
		'opacity-90'  => '90%',
387
		'opacity-100' => '100%',
388
	);
389
390
	$defaults = array(
391
		'type'     => 'select',
392
		'title'    => __( 'Opacity', 'super-duper' ),
393
		'options'  => $options,
394
		'default'  => '',
395
		'desc_tip' => true,
396
		'group'    => __( 'Wrapper Styles', 'super-duper' ),
397
	);
398
399
	$input = wp_parse_args( $overwrite, $defaults );
400
401
	return $input;
402
}
403
404
/**
405
 * A helper function for a set of background inputs.
406
 *
407
 * @param string $type
408
 * @param array $overwrite
409
 *
410
 * @return array
411
 */
412
function sd_get_background_inputs( $type = 'bg', $overwrite = array(), $overwrite_color = array(), $overwrite_gradient = array(), $overwrite_image = array(), $include_button_colors = false ) {
413
414
	$color_options = $include_button_colors ? sd_aui_colors( false, true, true, true ) : sd_aui_colors();
415
416
	$options = array(
417
		           ''            => __( 'None', 'super-duper' ),
418
		           'transparent' => __( 'Transparent', 'super-duper' ),
419
	           ) + $color_options;
420
421
	if ( false !== $overwrite_color ) {
422
		$options['custom-color'] = __( 'Custom Color', 'super-duper' );
423
	}
424
425
	if ( false !== $overwrite_gradient ) {
426
		$options['custom-gradient'] = __( 'Custom Gradient', 'super-duper' );
427
	}
428
429
	$defaults = array(
430
		'type'     => 'select',
431
		'title'    => __( 'Background Color', 'super-duper' ),
432
		'options'  => $options,
433
		'default'  => '',
434
		'desc_tip' => true,
435
		'group'    => __( 'Background', 'super-duper' ),
436
	);
437
438
	if ( $overwrite !== false ) {
0 ignored issues
show
introduced by
The condition $overwrite !== false is always true.
Loading history...
439
		$input[ $type ] = wp_parse_args( $overwrite, $defaults );
0 ignored issues
show
Comprehensibility Best Practice introduced by
$input was never initialized. Although not strictly required by PHP, it is generally a good practice to add $input = array(); before regardless.
Loading history...
440
	}
441
442
	if ( $overwrite_color !== false ) {
443
		$input[ $type . '_color' ] = wp_parse_args(
444
			$overwrite_color,
445
			array(
446
				'type'            => 'color',
447
				'title'           => __( 'Custom color', 'super-duper' ),
448
				'placeholder'     => '',
449
				'default'         => '#0073aa',
450
				'desc_tip'        => true,
451
				'group'           => __( 'Background', 'super-duper' ),
452
				'element_require' => '[%' . $type . '%]=="custom-color"',
453
			)
454
		);
455
	}
456
457
	if ( $overwrite_gradient !== false ) {
458
		$input[ $type . '_gradient' ] = wp_parse_args(
459
			$overwrite_gradient,
460
			array(
461
				'type'            => 'gradient',
462
				'title'           => __( 'Custom gradient', 'super-duper' ),
463
				'placeholder'     => '',
464
				'default'         => 'linear-gradient(135deg,rgba(6,147,227,1) 0%,rgb(155,81,224) 100%)',
465
				'desc_tip'        => true,
466
				'group'           => __( 'Background', 'super-duper' ),
467
				'element_require' => '[%' . $type . '%]=="custom-gradient"',
468
			)
469
		);
470
	}
471
472
	if ( $overwrite_image !== false ) {
473
474
		$input[ $type . '_image_fixed' ] = array(
475
			'type'            => 'checkbox',
476
			'title'           => __( 'Fixed background', 'super-duper' ),
477
			'default'         => '',
478
			'desc_tip'        => true,
479
			'group'           => ! empty( $overwrite_image['group'] ) ? $overwrite_image['group'] : __( 'Background' ),
480
			'element_require' => '( [%' . $type . '%]=="" || [%' . $type . '%]=="custom-color" || [%' . $type . '%]=="custom-gradient" || [%' . $type . '%]=="transparent" )',
481
482
		);
483
484
		$input[ $type . '_image_use_featured' ] = array(
485
			'type'            => 'checkbox',
486
			'title'           => __( 'Use featured image', 'super-duper' ),
487
			'default'         => '',
488
			'desc_tip'        => true,
489
			'group'           => ! empty( $overwrite_image['group'] ) ? $overwrite_image['group'] : __( 'Background', 'super-duper' ),
490
			'element_require' => '( [%' . $type . '%]=="" || [%' . $type . '%]=="custom-color" || [%' . $type . '%]=="custom-gradient" || [%' . $type . '%]=="transparent" )',
491
492
		);
493
494
		$input[ $type . '_image' ] = wp_parse_args(
495
			$overwrite_image,
496
			array(
497
				'type'        => 'image',
498
				'title'       => __( 'Custom image', 'super-duper' ),
499
				'placeholder' => '',
500
				'default'     => '',
501
				'desc_tip'    => true,
502
				'group'       => __( 'Background', 'super-duper' ),
503
				//          'element_require' => ' ![%' . $type . '_image_use_featured%] '
504
			)
505
		);
506
507
		$input[ $type . '_image_id' ] = wp_parse_args(
508
			$overwrite_image,
509
			array(
510
				'type'        => 'hidden',
511
				'hidden_type' => 'number',
512
				'title'       => '',
513
				'placeholder' => '',
514
				'default'     => '',
515
				'group'       => __( 'Background', 'super-duper' ),
516
			)
517
		);
518
519
		$input[ $type . '_image_xy' ] = wp_parse_args(
520
			$overwrite_image,
521
			array(
522
				'type'        => 'image_xy',
523
				'title'       => '',
524
				'placeholder' => '',
525
				'default'     => '',
526
				'group'       => __( 'Background', 'super-duper' ),
527
			)
528
		);
529
	}
530
531
	return $input;
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $input does not seem to be defined for all execution paths leading up to this point.
Loading history...
532
}
533
534
/**
535
 * A helper function for a set of inputs for the shape divider.
536
 *
537
 * @param string $type
538
 * @param array $overwrite
539
 *
540
 * @return array
541
 */
542
function sd_get_shape_divider_inputs( $type = 'sd', $overwrite = array(), $overwrite_color = array(), $overwrite_gradient = array(), $overwrite_image = array() ) {
0 ignored issues
show
Unused Code introduced by
The parameter $overwrite_image is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

542
function sd_get_shape_divider_inputs( $type = 'sd', $overwrite = array(), $overwrite_color = array(), $overwrite_gradient = array(), /** @scrutinizer ignore-unused */ $overwrite_image = array() ) {

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

Loading history...
543
544
	$options = array(
545
		''                      => __( 'None', 'super-duper' ),
546
		'mountains'             => __( 'Mountains', 'super-duper' ),
547
		'drops'                 => __( 'Drops', 'super-duper' ),
548
		'clouds'                => __( 'Clouds', 'super-duper' ),
549
		'zigzag'                => __( 'Zigzag', 'super-duper' ),
550
		'pyramids'              => __( 'Pyramids', 'super-duper' ),
551
		'triangle'              => __( 'Triangle', 'super-duper' ),
552
		'triangle-asymmetrical' => __( 'Triangle Asymmetrical', 'super-duper' ),
553
		'tilt'                  => __( 'Tilt', 'super-duper' ),
554
		'opacity-tilt'          => __( 'Opacity Tilt', 'super-duper' ),
555
		'opacity-fan'           => __( 'Opacity Fan', 'super-duper' ),
556
		'curve'                 => __( 'Curve', 'super-duper' ),
557
		'curve-asymmetrical'    => __( 'Curve Asymmetrical', 'super-duper' ),
558
		'waves'                 => __( 'Waves', 'super-duper' ),
559
		'wave-brush'            => __( 'Wave Brush', 'super-duper' ),
560
		'waves-pattern'         => __( 'Waves Pattern', 'super-duper' ),
561
		'arrow'                 => __( 'Arrow', 'super-duper' ),
562
		'split'                 => __( 'Split', 'super-duper' ),
563
		'book'                  => __( 'Book', 'super-duper' ),
564
	);
565
566
	$defaults = array(
567
		'type'     => 'select',
568
		'title'    => __( 'Type', 'super-duper' ),
569
		'options'  => $options,
570
		'default'  => '',
571
		'desc_tip' => true,
572
		'group'    => __( 'Shape Divider', 'super-duper' ),
573
	);
574
575
	$input[ $type ] = wp_parse_args( $overwrite, $defaults );
0 ignored issues
show
Comprehensibility Best Practice introduced by
$input was never initialized. Although not strictly required by PHP, it is generally a good practice to add $input = array(); before regardless.
Loading history...
576
577
	$input[ $type . '_notice' ] = array(
578
		'type'            => 'notice',
579
		'desc'            => __( 'Parent element must be position `relative`', 'super-duper' ),
580
		'status'          => 'warning',
581
		'group'           => __( 'Shape Divider', 'super-duper' ),
582
		'element_require' => '[%' . $type . '%]!=""',
583
	);
584
585
	$input[ $type . '_position' ] = wp_parse_args(
586
		$overwrite_color,
587
		array(
588
			'type'            => 'select',
589
			'title'           => __( 'Position', 'super-duper' ),
590
			'options'         => array(
591
				'top'    => __( 'Top', 'super-duper' ),
592
				'bottom' => __( 'Bottom', 'super-duper' ),
593
			),
594
			'desc_tip'        => true,
595
			'group'           => __( 'Shape Divider', 'super-duper' ),
596
			'element_require' => '[%' . $type . '%]!=""',
597
		)
598
	);
599
600
	$options = array(
601
		           ''            => __( 'None', 'super-duper' ),
602
		           'transparent' => __( 'Transparent', 'super-duper' ),
603
	           ) + sd_aui_colors()
604
	           + array(
605
		           'custom-color' => __( 'Custom Color', 'super-duper' ),
606
	           );
607
608
	$input[ $type . '_color' ] = wp_parse_args(
609
		$overwrite_color,
610
		array(
611
			'type'            => 'select',
612
			'title'           => __( 'Color', 'super-duper' ),
613
			'options'         => $options,
614
			'desc_tip'        => true,
615
			'group'           => __( 'Shape Divider', 'super-duper' ),
616
			'element_require' => '[%' . $type . '%]!=""',
617
		)
618
	);
619
620
	$input[ $type . '_custom_color' ] = wp_parse_args(
621
		$overwrite_color,
622
		array(
623
			'type'            => 'color',
624
			'title'           => __( 'Custom color', 'super-duper' ),
625
			'placeholder'     => '',
626
			'default'         => '#0073aa',
627
			'desc_tip'        => true,
628
			'group'           => __( 'Shape Divider', 'super-duper' ),
629
			'element_require' => '[%' . $type . '_color%]=="custom-color" && [%' . $type . '%]!=""',
630
		)
631
	);
632
633
	$input[ $type . '_width' ] = wp_parse_args(
634
		$overwrite_gradient,
635
		array(
636
			'type'              => 'range',
637
			'title'             => __( 'Width', 'super-duper' ),
638
			'placeholder'       => '',
639
			'default'           => '200',
640
			'desc_tip'          => true,
641
			'custom_attributes' => array(
642
				'min' => 100,
643
				'max' => 300,
644
			),
645
			'group'             => __( 'Shape Divider', 'super-duper' ),
646
			'element_require'   => '[%' . $type . '%]!=""',
647
		)
648
	);
649
650
	$input[ $type . '_height' ] = array(
651
		'type'              => 'range',
652
		'title'             => __( 'Height', 'super-duper' ),
653
		'default'           => '100',
654
		'desc_tip'          => true,
655
		'custom_attributes' => array(
656
			'min' => 0,
657
			'max' => 500,
658
		),
659
		'group'             => __( 'Shape Divider', 'super-duper' ),
660
		'element_require'   => '[%' . $type . '%]!=""',
661
	);
662
663
	$requires = array(
664
		'mountains'             => array( 'flip' ),
665
		'drops'                 => array( 'flip', 'invert' ),
666
		'clouds'                => array( 'flip', 'invert' ),
667
		'zigzag'                => array(),
668
		'pyramids'              => array( 'flip', 'invert' ),
669
		'triangle'              => array( 'invert' ),
670
		'triangle-asymmetrical' => array( 'flip', 'invert' ),
671
		'tilt'                  => array( 'flip' ),
672
		'opacity-tilt'          => array( 'flip' ),
673
		'opacity-fan'           => array(),
674
		'curve'                 => array( 'invert' ),
675
		'curve-asymmetrical'    => array( 'flip', 'invert' ),
676
		'waves'                 => array( 'flip', 'invert' ),
677
		'wave-brush'            => array( 'flip' ),
678
		'waves-pattern'         => array( 'flip' ),
679
		'arrow'                 => array( 'invert' ),
680
		'split'                 => array( 'invert' ),
681
		'book'                  => array( 'invert' ),
682
	);
683
684
	$input[ $type . '_flip' ] = array(
685
		'type'            => 'checkbox',
686
		'title'           => __( 'Flip', 'super-duper' ),
687
		'default'         => '',
688
		'desc_tip'        => true,
689
		'group'           => __( 'Shape Divider', 'super-duper' ),
690
		'element_require' => sd_get_element_require_string( $requires, 'flip', 'sd' ),
691
	);
692
693
	$input[ $type . '_invert' ] = array(
694
		'type'            => 'checkbox',
695
		'title'           => __( 'Invert', 'super-duper' ),
696
		'default'         => '',
697
		'desc_tip'        => true,
698
		'group'           => __( 'Shape Divider', 'super-duper' ),
699
		'element_require' => sd_get_element_require_string( $requires, 'invert', 'sd' ),
700
	);
701
702
	$input[ $type . '_btf' ] = array(
703
		'type'            => 'checkbox',
704
		'title'           => __( 'Bring to front', 'super-duper' ),
705
		'default'         => '',
706
		'desc_tip'        => true,
707
		'group'           => __( 'Shape Divider', 'super-duper' ),
708
		'element_require' => '[%' . $type . '%]!=""',
709
710
	);
711
712
	return $input;
713
}
714
715
/**
716
 * Get the element require sting.
717
 *
718
 * @param $args
719
 * @param $key
720
 * @param $type
721
 *
722
 * @return string
723
 */
724
function sd_get_element_require_string( $args, $key, $type ) {
725
	$output   = '';
726
	$requires = array();
727
728
	if ( ! empty( $args ) ) {
729
		foreach ( $args as $t => $k ) {
730
			if ( in_array( $key, $k ) ) {
731
				$requires[] = '[%' . $type . '%]=="' . $t . '"';
732
			}
733
		}
734
735
		if ( ! empty( $requires ) ) {
736
			$output = '(' . implode( ' || ', $requires ) . ')';
737
		}
738
	}
739
740
	return $output;
741
}
742
743
/**
744
 * A helper function for text color inputs.
745
 *
746
 * @param string $type
747
 * @param array $overwrite
748
 *
749
 * @return array
750
 */
751
function sd_get_text_color_input( $type = 'text_color', $overwrite = array(), $has_custom = false ) {
0 ignored issues
show
Unused Code introduced by
The parameter $type is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

751
function sd_get_text_color_input( /** @scrutinizer ignore-unused */ $type = 'text_color', $overwrite = array(), $has_custom = false ) {

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

Loading history...
752
	$options = array(
753
		           '' => __( 'None', 'super-duper' ),
754
	           ) + sd_aui_colors();
755
756
	if ( $has_custom ) {
757
		$options['custom'] = __( 'Custom color', 'super-duper' );
758
	}
759
760
	$defaults = array(
761
		'type'     => 'select',
762
		'title'    => __( 'Text color', 'super-duper' ),
763
		'options'  => $options,
764
		'default'  => '',
765
		'desc_tip' => true,
766
		'group'    => __( 'Typography', 'super-duper' ),
767
	);
768
769
	$input = wp_parse_args( $overwrite, $defaults );
770
771
	return $input;
772
}
773
774
function sd_get_text_color_input_group( $type = 'text_color', $overwrite = array(), $overwrite_custom = array() ) {
775
	$inputs = array();
776
777
	if ( $overwrite !== false ) {
778
		$inputs[ $type ] = sd_get_text_color_input( $type, $overwrite, true );
779
	}
780
781
	if ( $overwrite_custom !== false ) {
782
		$custom            = $type . '_custom';
783
		$inputs[ $custom ] = sd_get_custom_color_input( $custom, $overwrite_custom, $type );
784
	}
785
786
	return $inputs;
787
}
788
789
/**
790
 * A helper function for custom color.
791
 *
792
 * @param string $type
793
 * @param array $overwrite
794
 *
795
 * @return array
796
 */
797
function sd_get_custom_color_input( $type = 'color_custom', $overwrite = array(), $parent_type = '' ) {
0 ignored issues
show
Unused Code introduced by
The parameter $type is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

797
function sd_get_custom_color_input( /** @scrutinizer ignore-unused */ $type = 'color_custom', $overwrite = array(), $parent_type = '' ) {

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

Loading history...
798
799
	$defaults = array(
800
		'type'        => 'color',
801
		'title'       => __( 'Custom color', 'super-duper' ),
802
		'default'     => '',
803
		'placeholder' => '',
804
		'desc_tip'    => true,
805
		'group'       => __( 'Typography', 'super-duper' ),
806
	);
807
808
	if ( $parent_type ) {
809
		$defaults['element_require'] = '[%' . $parent_type . '%]=="custom"';
810
	}
811
812
	$input = wp_parse_args( $overwrite, $defaults );
813
814
	return $input;
815
}
816
817
/**
818
 * A helper function for column inputs.
819
 *
820
 * @param string $type
821
 * @param array $overwrite
822
 *
823
 * @return array
824
 */
825
function sd_get_col_input( $type = 'col', $overwrite = array() ) {
0 ignored issues
show
Unused Code introduced by
The parameter $type is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

825
function sd_get_col_input( /** @scrutinizer ignore-unused */ $type = 'col', $overwrite = array() ) {

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

Loading history...
826
827
	$device_size = '';
828
	if ( ! empty( $overwrite['device_type'] ) ) {
829
		if ( $overwrite['device_type'] == 'Tablet' ) {
830
			$device_size = '-md';
0 ignored issues
show
Unused Code introduced by
The assignment to $device_size is dead and can be removed.
Loading history...
831
		} elseif ( $overwrite['device_type'] == 'Desktop' ) {
832
			$device_size = '-lg';
833
		}
834
	}
835
	$options = array(
836
		''     => __( 'Default', 'super-duper' ),
837
		'auto' => __( 'auto', 'super-duper' ),
838
		'1'    => '1/12',
839
		'2'    => '2/12',
840
		'3'    => '3/12',
841
		'4'    => '4/12',
842
		'5'    => '5/12',
843
		'6'    => '6/12',
844
		'7'    => '7/12',
845
		'8'    => '8/12',
846
		'9'    => '9/12',
847
		'10'   => '10/12',
848
		'11'   => '11/12',
849
		'12'   => '12/12',
850
	);
851
852
	$defaults = array(
853
		'type'            => 'select',
854
		'title'           => __( 'Column width', 'super-duper' ),
855
		'options'         => $options,
856
		'default'         => '',
857
		'desc_tip'        => true,
858
		'group'           => __( 'Container', 'super-duper' ),
859
		'element_require' => '[%container%]=="col"',
860
	);
861
862
	$input = wp_parse_args( $overwrite, $defaults );
863
864
	return $input;
865
}
866
867
/**
868
 * A helper function for row columns inputs.
869
 *
870
 * @param string $type
871
 * @param array $overwrite
872
 *
873
 * @return array
874
 */
875
function sd_get_row_cols_input( $type = 'row_cols', $overwrite = array() ) {
0 ignored issues
show
Unused Code introduced by
The parameter $type is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

875
function sd_get_row_cols_input( /** @scrutinizer ignore-unused */ $type = 'row_cols', $overwrite = array() ) {

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

Loading history...
876
877
	$device_size = '';
878
	if ( ! empty( $overwrite['device_type'] ) ) {
879
		if ( $overwrite['device_type'] == 'Tablet' ) {
880
			$device_size = '-md';
0 ignored issues
show
Unused Code introduced by
The assignment to $device_size is dead and can be removed.
Loading history...
881
		} elseif ( $overwrite['device_type'] == 'Desktop' ) {
882
			$device_size = '-lg';
883
		}
884
	}
885
	$options = array(
886
		''  => __( 'auto', 'super-duper' ),
887
		'1' => '1',
888
		'2' => '2',
889
		'3' => '3',
890
		'4' => '4',
891
		'5' => '5',
892
		'6' => '6',
893
	);
894
895
	$defaults = array(
896
		'type'            => 'select',
897
		'title'           => __( 'Row columns', 'super-duper' ),
898
		'options'         => $options,
899
		'default'         => '',
900
		'desc_tip'        => true,
901
		'group'           => __( 'Container', 'super-duper' ),
902
		'element_require' => '[%container%]=="row"',
903
	);
904
905
	$input = wp_parse_args( $overwrite, $defaults );
906
907
	return $input;
908
}
909
910
/**
911
 * A helper function for text align inputs.
912
 *
913
 * @param string $type
914
 * @param array $overwrite
915
 *
916
 * @return array
917
 */
918
function sd_get_text_align_input( $type = 'text_align', $overwrite = array() ) {
0 ignored issues
show
Unused Code introduced by
The parameter $type is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

918
function sd_get_text_align_input( /** @scrutinizer ignore-unused */ $type = 'text_align', $overwrite = array() ) {

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

Loading history...
919
920
	$device_size = '';
921
	if ( ! empty( $overwrite['device_type'] ) ) {
922
		if ( $overwrite['device_type'] == 'Tablet' ) {
923
			$device_size = '-md';
924
		} elseif ( $overwrite['device_type'] == 'Desktop' ) {
925
			$device_size = '-lg';
926
		}
927
	}
928
	$options = array(
929
		''                                => __( 'Default', 'super-duper' ),
930
		'text' . $device_size . '-left'   => __( 'Left', 'super-duper' ),
931
		'text' . $device_size . '-right'  => __( 'Right', 'super-duper' ),
932
		'text' . $device_size . '-center' => __( 'Center', 'super-duper' ),
933
	);
934
935
	$defaults = array(
936
		'type'     => 'select',
937
		'title'    => __( 'Text align', 'super-duper' ),
938
		'options'  => $options,
939
		'default'  => '',
940
		'desc_tip' => true,
941
		'group'    => __( 'Typography', 'super-duper' ),
942
	);
943
944
	$input = wp_parse_args( $overwrite, $defaults );
945
946
	return $input;
947
}
948
949
/**
950
 * A helper function for display inputs.
951
 *
952
 * @param string $type
953
 * @param array $overwrite
954
 *
955
 * @return array
956
 */
957
function sd_get_display_input( $type = 'display', $overwrite = array() ) {
0 ignored issues
show
Unused Code introduced by
The parameter $type is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

957
function sd_get_display_input( /** @scrutinizer ignore-unused */ $type = 'display', $overwrite = array() ) {

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

Loading history...
958
959
	$device_size = '';
960
	if ( ! empty( $overwrite['device_type'] ) ) {
961
		if ( $overwrite['device_type'] == 'Tablet' ) {
962
			$device_size = '-md';
963
		} elseif ( $overwrite['device_type'] == 'Desktop' ) {
964
			$device_size = '-lg';
965
		}
966
	}
967
	$options = array(
968
		''                                   => __( 'Default', 'super-duper' ),
969
		'd' . $device_size . '-none'         => 'none',
970
		'd' . $device_size . '-inline'       => 'inline',
971
		'd' . $device_size . '-inline-block' => 'inline-block',
972
		'd' . $device_size . '-block'        => 'block',
973
		'd' . $device_size . '-table'        => 'table',
974
		'd' . $device_size . '-table-cell'   => 'table-cell',
975
		'd' . $device_size . '-table-row'    => 'table-row',
976
		'd' . $device_size . '-flex'         => 'flex',
977
		'd' . $device_size . '-inline-flex'  => 'inline-flex',
978
	);
979
980
	$defaults = array(
981
		'type'     => 'select',
982
		'title'    => __( 'Display', 'super-duper' ),
983
		'options'  => $options,
984
		'default'  => '',
985
		'desc_tip' => true,
986
		'group'    => __( 'Wrapper Styles', 'super-duper' ),
987
	);
988
989
	$input = wp_parse_args( $overwrite, $defaults );
990
991
	return $input;
992
}
993
994
/**
995
 * A helper function for text justify inputs.
996
 *
997
 * @param string $type
998
 * @param array $overwrite
999
 *
1000
 * @return array
1001
 */
1002
function sd_get_text_justify_input( $type = 'text_justify', $overwrite = array() ) {
0 ignored issues
show
Unused Code introduced by
The parameter $type is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

1002
function sd_get_text_justify_input( /** @scrutinizer ignore-unused */ $type = 'text_justify', $overwrite = array() ) {

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

Loading history...
1003
1004
	$defaults = array(
1005
		'type'     => 'checkbox',
1006
		'title'    => __( 'Text justify', 'super-duper' ),
1007
		'default'  => '',
1008
		'desc_tip' => true,
1009
		'group'    => __( 'Typography', 'super-duper' ),
1010
	);
1011
1012
	$input = wp_parse_args( $overwrite, $defaults );
1013
1014
	return $input;
1015
}
1016
1017
/**
1018
 * Get the AUI colors.
1019
 *
1020
 * @param $include_branding
1021
 * @param $include_outlines
1022
 * @param $outline_button_only_text
1023
 *
1024
 * @return array
1025
 */
1026
function sd_aui_colors( $include_branding = false, $include_outlines = false, $outline_button_only_text = false, $include_translucent = false ) {
1027
	$theme_colors = array();
1028
1029
	$theme_colors['primary']   = __( 'Primary', 'super-duper' );
1030
	$theme_colors['secondary'] = __( 'Secondary', 'super-duper' );
1031
	$theme_colors['success']   = __( 'Success', 'super-duper' );
1032
	$theme_colors['danger']    = __( 'Danger', 'super-duper' );
1033
	$theme_colors['warning']   = __( 'Warning', 'super-duper' );
1034
	$theme_colors['info']      = __( 'Info', 'super-duper' );
1035
	$theme_colors['light']     = __( 'Light', 'super-duper' );
1036
	$theme_colors['dark']      = __( 'Dark', 'super-duper' );
1037
	$theme_colors['white']     = __( 'White', 'super-duper' );
1038
	$theme_colors['purple']    = __( 'Purple', 'super-duper' );
1039
	$theme_colors['salmon']    = __( 'Salmon', 'super-duper' );
1040
	$theme_colors['cyan']      = __( 'Cyan', 'super-duper' );
1041
	$theme_colors['gray']      = __( 'Gray', 'super-duper' );
1042
	$theme_colors['muted']     = __( 'Muted', 'super-duper' );
1043
	$theme_colors['gray-dark'] = __( 'Gray dark', 'super-duper' );
1044
	$theme_colors['indigo']    = __( 'Indigo', 'super-duper' );
1045
	$theme_colors['orange']    = __( 'Orange', 'super-duper' );
1046
1047
	if ( $include_outlines ) {
1048
		$button_only                       = $outline_button_only_text ? ' ' . __( '(button only)', 'super-duper' ) : '';
1049
		$theme_colors['outline-primary']   = __( 'Primary outline', 'super-duper' ) . $button_only;
1050
		$theme_colors['outline-secondary'] = __( 'Secondary outline', 'super-duper' ) . $button_only;
1051
		$theme_colors['outline-success']   = __( 'Success outline', 'super-duper' ) . $button_only;
1052
		$theme_colors['outline-danger']    = __( 'Danger outline', 'super-duper' ) . $button_only;
1053
		$theme_colors['outline-warning']   = __( 'Warning outline', 'super-duper' ) . $button_only;
1054
		$theme_colors['outline-info']      = __( 'Info outline', 'super-duper' ) . $button_only;
1055
		$theme_colors['outline-light']     = __( 'Light outline', 'super-duper' ) . $button_only;
1056
		$theme_colors['outline-dark']      = __( 'Dark outline', 'super-duper' ) . $button_only;
1057
		$theme_colors['outline-white']     = __( 'White outline', 'super-duper' ) . $button_only;
1058
		$theme_colors['outline-purple']    = __( 'Purple outline', 'super-duper' ) . $button_only;
1059
		$theme_colors['outline-salmon']    = __( 'Salmon outline', 'super-duper' ) . $button_only;
1060
		$theme_colors['outline-cyan']      = __( 'Cyan outline', 'super-duper' ) . $button_only;
1061
		$theme_colors['outline-gray']      = __( 'Gray outline', 'super-duper' ) . $button_only;
1062
		$theme_colors['outline-gray-dark'] = __( 'Gray dark outline', 'super-duper' ) . $button_only;
1063
		$theme_colors['outline-indigo']    = __( 'Indigo outline', 'super-duper' ) . $button_only;
1064
		$theme_colors['outline-orange']    = __( 'Orange outline', 'super-duper' ) . $button_only;
1065
	}
1066
1067
	if ( $include_branding ) {
1068
		$theme_colors = $theme_colors + sd_aui_branding_colors();
1069
	}
1070
1071
	if ( $include_translucent ) {
1072
		$button_only                           = $outline_button_only_text ? ' ' . __( '(button only)', 'super-duper' ) : '';
1073
		$theme_colors['translucent-primary']   = __( 'Primary translucent', 'super-duper' ) . $button_only;
1074
		$theme_colors['translucent-secondary'] = __( 'Secondary translucent', 'super-duper' ) . $button_only;
1075
		$theme_colors['translucent-success']   = __( 'Success translucent', 'super-duper' ) . $button_only;
1076
		$theme_colors['translucent-danger']    = __( 'Danger translucent', 'super-duper' ) . $button_only;
1077
		$theme_colors['translucent-warning']   = __( 'Warning translucent', 'super-duper' ) . $button_only;
1078
		$theme_colors['translucent-info']      = __( 'Info translucent', 'super-duper' ) . $button_only;
1079
		$theme_colors['translucent-light']     = __( 'Light translucent', 'super-duper' ) . $button_only;
1080
		$theme_colors['translucent-dark']      = __( 'Dark translucent', 'super-duper' ) . $button_only;
1081
		$theme_colors['translucent-white']     = __( 'White translucent', 'super-duper' ) . $button_only;
1082
		$theme_colors['translucent-purple']    = __( 'Purple translucent', 'super-duper' ) . $button_only;
1083
		$theme_colors['translucent-salmon']    = __( 'Salmon translucent', 'super-duper' ) . $button_only;
1084
		$theme_colors['translucent-cyan']      = __( 'Cyan translucent', 'super-duper' ) . $button_only;
1085
		$theme_colors['translucent-gray']      = __( 'Gray translucent', 'super-duper' ) . $button_only;
1086
		$theme_colors['translucent-gray-dark'] = __( 'Gray dark translucent', 'super-duper' ) . $button_only;
1087
		$theme_colors['translucent-indigo']    = __( 'Indigo translucent', 'super-duper' ) . $button_only;
1088
		$theme_colors['translucent-orange']    = __( 'Orange translucent', 'super-duper' ) . $button_only;
1089
	}
1090
1091
	return apply_filters( 'sd_aui_colors', $theme_colors, $include_outlines, $include_branding );
1092
}
1093
1094
/**
1095
 * Get the AUI brangin colors.
1096
 *
1097
 * @return array
1098
 */
1099
function sd_aui_branding_colors() {
1100
	return array(
1101
		'facebook'  => __( 'Facebook', 'super-duper' ),
1102
		'twitter'   => __( 'Twitter', 'super-duper' ),
1103
		'instagram' => __( 'Instagram', 'super-duper' ),
1104
		'linkedin'  => __( 'Linkedin', 'super-duper' ),
1105
		'flickr'    => __( 'Flickr', 'super-duper' ),
1106
		'github'    => __( 'GitHub', 'super-duper' ),
1107
		'youtube'   => __( 'YouTube', 'super-duper' ),
1108
		'wordpress' => __( 'WordPress', 'super-duper' ),
1109
		'google'    => __( 'Google', 'super-duper' ),
1110
		'yahoo'     => __( 'Yahoo', 'super-duper' ),
1111
		'vkontakte' => __( 'Vkontakte', 'super-duper' ),
1112
	);
1113
}
1114
1115
1116
/**
1117
 * A helper function for container class.
1118
 *
1119
 * @param string $type
1120
 * @param array $overwrite
1121
 *
1122
 * @return array
1123
 */
1124
function sd_get_container_class_input( $type = 'container', $overwrite = array() ) {
0 ignored issues
show
Unused Code introduced by
The parameter $type is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

1124
function sd_get_container_class_input( /** @scrutinizer ignore-unused */ $type = 'container', $overwrite = array() ) {

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

Loading history...
1125
1126
	$options = array(
1127
		'container'       => __( 'container (default)', 'super-duper' ),
1128
		'container-sm'    => 'container-sm',
1129
		'container-md'    => 'container-md',
1130
		'container-lg'    => 'container-lg',
1131
		'container-xl'    => 'container-xl',
1132
		'container-xxl'   => 'container-xxl',
1133
		'container-fluid' => 'container-fluid',
1134
		'row'             => 'row',
1135
		'col'             => 'col',
1136
		'card'            => 'card',
1137
		'card-header'     => 'card-header',
1138
		'card-img-top'    => 'card-img-top',
1139
		'card-body'       => 'card-body',
1140
		'card-footer'     => 'card-footer',
1141
		'list-group'      => 'list-group',
1142
		'list-group-item' => 'list-group-item',
1143
		''                => __( 'no container class', 'super-duper' ),
1144
	);
1145
1146
	$defaults = array(
1147
		'type'     => 'select',
1148
		'title'    => __( 'Type', 'super-duper' ),
1149
		'options'  => $options,
1150
		'default'  => '',
1151
		'desc_tip' => true,
1152
		'group'    => __( 'Container', 'super-duper' ),
1153
	);
1154
1155
	$input = wp_parse_args( $overwrite, $defaults );
1156
1157
	return $input;
1158
}
1159
1160
/**
1161
 * A helper function for position class.
1162
 *
1163
 * @param string $type
1164
 * @param array $overwrite
1165
 *
1166
 * @return array
1167
 */
1168
function sd_get_position_class_input( $type = 'position', $overwrite = array() ) {
0 ignored issues
show
Unused Code introduced by
The parameter $type is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

1168
function sd_get_position_class_input( /** @scrutinizer ignore-unused */ $type = 'position', $overwrite = array() ) {

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

Loading history...
1169
1170
	$options = array(
1171
		''                  => __( 'Default', 'super-duper' ),
1172
		'position-static'   => 'static',
1173
		'position-relative' => 'relative',
1174
		'position-absolute' => 'absolute',
1175
		'position-fixed'    => 'fixed',
1176
		'position-sticky'   => 'sticky',
1177
		'fixed-top'         => 'fixed-top',
1178
		'fixed-bottom'      => 'fixed-bottom',
1179
		'sticky-top'        => 'sticky-top',
1180
	);
1181
1182
	$defaults = array(
1183
		'type'     => 'select',
1184
		'title'    => __( 'Position', 'super-duper' ),
1185
		'options'  => $options,
1186
		'default'  => '',
1187
		'desc_tip' => true,
1188
		'group'    => __( 'Wrapper Styles', 'super-duper' ),
1189
	);
1190
1191
	$input = wp_parse_args( $overwrite, $defaults );
1192
1193
	return $input;
1194
}
1195
1196
/**
1197
 * @param $type
1198
 * @param $overwrite
1199
 *
1200
 * @return array
1201
 */
1202
function sd_get_absolute_position_input( $type = 'absolute_position', $overwrite = array() ) {
0 ignored issues
show
Unused Code introduced by
The parameter $type is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

1202
function sd_get_absolute_position_input( /** @scrutinizer ignore-unused */ $type = 'absolute_position', $overwrite = array() ) {

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

Loading history...
1203
1204
	$options = array(
1205
		''              => __( 'Default', 'super-duper' ),
1206
		'top-left'      => 'top-left',
1207
		'top-center'    => 'top-center',
1208
		'top-right'     => 'top-right',
1209
		'center-left'   => 'middle-left',
1210
		'center'        => 'center',
1211
		'center-right'  => 'middle-right',
1212
		'bottom-left'   => 'bottom-left',
1213
		'bottom-center' => 'bottom-center',
1214
		'bottom-right'  => 'bottom-right',
1215
	);
1216
1217
	$defaults = array(
1218
		'type'            => 'select',
1219
		'title'           => __( 'Absolute Position', 'super-duper' ),
1220
		'options'         => $options,
1221
		'default'         => '',
1222
		'desc_tip'        => true,
1223
		'group'           => __( 'Wrapper Styles', 'super-duper' ),
1224
		'element_require' => '[%position%]=="position-absolute"',
1225
	);
1226
1227
	$input = wp_parse_args( $overwrite, $defaults );
1228
1229
	return $input;
1230
}
1231
1232
/**
1233
 * A helper function for sticky offset input.
1234
 *
1235
 * @param string $type
1236
 * @param array $overwrite
1237
 *
1238
 * @return array
1239
 */
1240
function sd_get_sticky_offset_input( $type = 'top', $overwrite = array() ) {
1241
1242
	$defaults = array(
1243
		'type'            => 'number',
1244
		'title'           => __( 'Sticky offset', 'super-duper' ),
1245
		//'desc' =>  __('Sticky offset'),
1246
		'default'         => '',
1247
		'desc_tip'        => true,
1248
		'group'           => __( 'Wrapper Styles', 'super-duper' ),
1249
		'element_require' => '[%position%]=="sticky" || [%position%]=="sticky-top"',
1250
	);
1251
1252
	// title
1253
	if ( $type == 'top' ) {
1254
		$defaults['title'] = __( 'Top offset', 'super-duper' );
1255
		$defaults['icon']  = 'box-top';
1256
		$defaults['row']   = array(
1257
			'title' => __( 'Sticky offset', 'super-duper' ),
1258
			'key'   => 'sticky-offset',
1259
			'open'  => true,
1260
			'class' => 'text-center',
1261
		);
1262
	} elseif ( $type == 'bottom' ) {
1263
		$defaults['title'] = __( 'Bottom offset', 'super-duper' );
1264
		$defaults['icon']  = 'box-bottom';
1265
		$defaults['row']   = array(
1266
			'key'   => 'sticky-offset',
1267
			'close' => true,
1268
		);
1269
	}
1270
1271
	$input = wp_parse_args( $overwrite, $defaults );
1272
1273
	return $input;
1274
}
1275
1276
/**
1277
 * A helper function for font size
1278
 *
1279
 * @param string $type
1280
 * @param array $overwrite
1281
 *
1282
 * @return array
1283
 */
1284
function sd_get_font_size_input( $type = 'font_size', $overwrite = array(), $has_custom = false ) {
0 ignored issues
show
Unused Code introduced by
The parameter $type is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

1284
function sd_get_font_size_input( /** @scrutinizer ignore-unused */ $type = 'font_size', $overwrite = array(), $has_custom = false ) {

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

Loading history...
1285
	global $aui_bs5;
1286
1287
	$options[] = __( 'Inherit from parent', 'super-duper' );
0 ignored issues
show
Comprehensibility Best Practice introduced by
$options was never initialized. Although not strictly required by PHP, it is generally a good practice to add $options = array(); before regardless.
Loading history...
1288
	if ( $aui_bs5 ) {
1289
		// responsive font sizes
1290
		$options['fs-base'] = 'fs-base (body default)';
1291
		$options['fs-6']    = 'fs-6';
1292
		$options['fs-5']    = 'fs-5';
1293
		$options['fs-4']    = 'fs-4';
1294
		$options['fs-3']    = 'fs-3';
1295
		$options['fs-2']    = 'fs-2';
1296
		$options['fs-1']    = 'fs-1';
1297
1298
		// custom
1299
		$options['fs-lg']  = 'fs-lg';
1300
		$options['fs-sm']  = 'fs-sm';
1301
		$options['fs-xs']  = 'fs-xs';
1302
		$options['fs-xxs'] = 'fs-xxs';
1303
1304
	}
1305
1306
	$options = $options + array(
1307
			'h6'        => 'h6',
1308
			'h5'        => 'h5',
1309
			'h4'        => 'h4',
1310
			'h3'        => 'h3',
1311
			'h2'        => 'h2',
1312
			'h1'        => 'h1',
1313
			'display-1' => 'display-1',
1314
			'display-2' => 'display-2',
1315
			'display-3' => 'display-3',
1316
			'display-4' => 'display-4',
1317
		);
1318
1319
	if ( $aui_bs5 ) {
1320
		$options['display-5'] = 'display-5';
1321
		$options['display-6'] = 'display-6';
1322
	}
1323
1324
	if ( $has_custom ) {
1325
		$options['custom'] = __( 'Custom size', 'super-duper' );
1326
	}
1327
1328
	$defaults = array(
1329
		'type'     => 'select',
1330
		'title'    => __( 'Font size', 'super-duper' ),
1331
		'options'  => $options,
1332
		'default'  => '',
1333
		'desc_tip' => true,
1334
		'group'    => __( 'Typography', 'super-duper' ),
1335
	);
1336
1337
	$input = wp_parse_args( $overwrite, $defaults );
1338
1339
	return $input;
1340
}
1341
1342
/**
1343
 * A helper function for custom font size.
1344
 *
1345
 * @param string $type
1346
 * @param array $overwrite
1347
 *
1348
 * @return array
1349
 */
1350
function sd_get_font_custom_size_input( $type = 'font_size_custom', $overwrite = array(), $parent_type = '' ) {
0 ignored issues
show
Unused Code introduced by
The parameter $type is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

1350
function sd_get_font_custom_size_input( /** @scrutinizer ignore-unused */ $type = 'font_size_custom', $overwrite = array(), $parent_type = '' ) {

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

Loading history...
1351
1352
	$defaults = array(
1353
		'type'              => 'number',
1354
		'title'             => __( 'Font size (rem)', 'super-duper' ),
1355
		'default'           => '',
1356
		'placeholder'       => '1.25',
1357
		'custom_attributes' => array(
1358
			'step' => '0.1',
1359
			'min'  => '0',
1360
			'max'  => '100',
1361
		),
1362
		'desc_tip'          => true,
1363
		'group'             => __( 'Typography', 'super-duper' ),
1364
	);
1365
1366
	if ( $parent_type ) {
1367
		$defaults['element_require'] = '[%' . $parent_type . '%]=="custom"';
1368
	}
1369
1370
	$input = wp_parse_args( $overwrite, $defaults );
1371
1372
	return $input;
1373
}
1374
1375
/**
1376
 * A helper function for custom font size.
1377
 *
1378
 * @param string $type
1379
 * @param array $overwrite
1380
 *
1381
 * @return array
1382
 */
1383
function sd_get_font_line_height_input( $type = 'font_line_height', $overwrite = array() ) {
0 ignored issues
show
Unused Code introduced by
The parameter $type is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

1383
function sd_get_font_line_height_input( /** @scrutinizer ignore-unused */ $type = 'font_line_height', $overwrite = array() ) {

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

Loading history...
1384
1385
	$defaults = array(
1386
		'type'              => 'number',
1387
		'title'             => __( 'Font Line Height', 'super-duper' ),
1388
		'default'           => '',
1389
		'placeholder'       => '1.75',
1390
		'custom_attributes' => array(
1391
			'step' => '0.1',
1392
			'min'  => '0',
1393
			'max'  => '100',
1394
		),
1395
		'desc_tip'          => true,
1396
		'group'             => __( 'Typography', 'super-duper' ),
1397
	);
1398
1399
	$input = wp_parse_args( $overwrite, $defaults );
1400
1401
	return $input;
1402
}
1403
1404
/**
1405
 * A helper function for font size inputs.
1406
 *
1407
 * @param string $type
1408
 * @param array $overwrite
1409
 *
1410
 * @return array
1411
 */
1412
function sd_get_font_size_input_group( $type = 'font_size', $overwrite = array(), $overwrite_custom = array() ) {
1413
1414
	$inputs = array();
1415
1416
	if ( $overwrite !== false ) {
0 ignored issues
show
introduced by
The condition $overwrite !== false is always true.
Loading history...
1417
		$inputs[ $type ] = sd_get_font_size_input( $type, $overwrite, true );
1418
	}
1419
1420
	if ( $overwrite_custom !== false ) {
1421
		$custom            = $type . '_custom';
1422
		$inputs[ $custom ] = sd_get_font_custom_size_input( $custom, $overwrite_custom, $type );
1423
	}
1424
1425
	return $inputs;
1426
}
1427
1428
/**
1429
 * A helper function for font weight.
1430
 *
1431
 * @param string $type
1432
 * @param array $overwrite
1433
 *
1434
 * @return array
1435
 */
1436
function sd_get_font_weight_input( $type = 'font_weight', $overwrite = array() ) {
0 ignored issues
show
Unused Code introduced by
The parameter $type is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

1436
function sd_get_font_weight_input( /** @scrutinizer ignore-unused */ $type = 'font_weight', $overwrite = array() ) {

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

Loading history...
1437
1438
	$options = array(
1439
		''                                => __( 'Inherit', 'super-duper' ),
1440
		'font-weight-bold'                => 'bold',
1441
		'font-weight-bolder'              => 'bolder',
1442
		'font-weight-normal'              => 'normal',
1443
		'font-weight-light'               => 'light',
1444
		'font-weight-lighter'             => 'lighter',
1445
		'font-italic'                     => 'italic',
1446
		'font-weight-bold font-italic'    => 'bold italic',
1447
		'font-weight-bolder font-italic'  => 'bolder italic',
1448
		'font-weight-normal font-italic'  => 'normal italic',
1449
		'font-weight-light font-italic'   => 'light italic',
1450
		'font-weight-lighter font-italic' => 'lighter italic',
1451
	);
1452
1453
	$defaults = array(
1454
		'type'     => 'select',
1455
		'title'    => __( 'Appearance', 'super-duper' ),
1456
		'options'  => $options,
1457
		'default'  => '',
1458
		'desc_tip' => true,
1459
		'group'    => __( 'Typography', 'super-duper' ),
1460
	);
1461
1462
	$input = wp_parse_args( $overwrite, $defaults );
1463
1464
	return $input;
1465
}
1466
1467
/**
1468
 * A helper function for font case class.
1469
 *
1470
 * @param $type
1471
 * @param $overwrite
1472
 *
1473
 * @return array
1474
 */
1475
function sd_get_font_case_input( $type = 'font_weight', $overwrite = array() ) {
0 ignored issues
show
Unused Code introduced by
The parameter $type is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

1475
function sd_get_font_case_input( /** @scrutinizer ignore-unused */ $type = 'font_weight', $overwrite = array() ) {

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

Loading history...
1476
1477
	$options = array(
1478
		''                => __( 'Default', 'super-duper' ),
1479
		'text-lowercase'  => __( 'lowercase', 'super-duper' ),
1480
		'text-uppercase'  => __( 'UPPERCASE', 'super-duper' ),
1481
		'text-capitalize' => __( 'Capitalize', 'super-duper' ),
1482
	);
1483
1484
	$defaults = array(
1485
		'type'     => 'select',
1486
		'title'    => __( 'Letter case', 'super-duper' ),
1487
		'options'  => $options,
1488
		'default'  => '',
1489
		'desc_tip' => true,
1490
		'group'    => __( 'Typography', 'super-duper' ),
1491
	);
1492
1493
	$input = wp_parse_args( $overwrite, $defaults );
1494
1495
	return $input;
1496
}
1497
1498
/**
1499
 * @param string $type
1500
 * @param array $overwrite
1501
 *
1502
 * @return array
1503
 * @todo remove this as now included above.
1504
 * A helper function for font size
1505
 *
1506
 */
1507
function sd_get_font_italic_input( $type = 'font_italic', $overwrite = array() ) {
0 ignored issues
show
Unused Code introduced by
The parameter $type is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

1507
function sd_get_font_italic_input( /** @scrutinizer ignore-unused */ $type = 'font_italic', $overwrite = array() ) {

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

Loading history...
1508
1509
	$options = array(
1510
		''            => __( 'No', 'super-duper' ),
1511
		'font-italic' => __( 'Yes', 'super-duper' ),
1512
	);
1513
1514
	$defaults = array(
1515
		'type'     => 'select',
1516
		'title'    => __( 'Font italic', 'super-duper' ),
1517
		'options'  => $options,
1518
		'default'  => '',
1519
		'desc_tip' => true,
1520
		'group'    => __( 'Typography', 'super-duper' ),
1521
	);
1522
1523
	$input = wp_parse_args( $overwrite, $defaults );
1524
1525
	return $input;
1526
}
1527
1528
/**
1529
 * A helper function for the anchor input.
1530
 *
1531
 * @param $type
1532
 * @param $overwrite
1533
 *
1534
 * @return array
1535
 */
1536
function sd_get_anchor_input( $type = 'anchor', $overwrite = array() ) {
0 ignored issues
show
Unused Code introduced by
The parameter $type is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

1536
function sd_get_anchor_input( /** @scrutinizer ignore-unused */ $type = 'anchor', $overwrite = array() ) {

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

Loading history...
1537
1538
	$defaults = array(
1539
		'type'     => 'text',
1540
		'title'    => __( 'HTML anchor', 'super-duper' ),
1541
		'desc'     => __( 'Enter a word or two — without spaces — to make a unique web address just for this block, called an “anchor.” Then, you’ll be able to link directly to this section of your page.' ),
1542
		'default'  => '',
1543
		'desc_tip' => true,
1544
		'group'    => __( 'Advanced', 'super-duper' ),
1545
	);
1546
1547
	$input = wp_parse_args( $overwrite, $defaults );
1548
1549
	return $input;
1550
}
1551
1552
/**
1553
 * A helper function for the class input.
1554
 *
1555
 * @param $type
1556
 * @param $overwrite
1557
 *
1558
 * @return array
1559
 */
1560
function sd_get_class_input( $type = 'css_class', $overwrite = array() ) {
0 ignored issues
show
Unused Code introduced by
The parameter $type is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

1560
function sd_get_class_input( /** @scrutinizer ignore-unused */ $type = 'css_class', $overwrite = array() ) {

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

Loading history...
1561
1562
	$defaults = array(
1563
		'type'     => 'text',
1564
		'title'    => __( 'Additional CSS class(es)', 'super-duper' ),
1565
		'desc'     => __( 'Separate multiple classes with spaces.', 'super-duper' ),
1566
		'default'  => '',
1567
		'desc_tip' => true,
1568
		'group'    => __( 'Advanced', 'super-duper' ),
1569
	);
1570
1571
	$input = wp_parse_args( $overwrite, $defaults );
1572
1573
	return $input;
1574
}
1575
1576
/**
1577
 * A helper function for font size inputs.
1578
 *
1579
 * @param string $type
1580
 * @param array $overwrite
1581
 *
1582
 * @return array
1583
 */
1584
function sd_get_hover_animations_input( $type = 'hover_animations', $overwrite = array() ) {
0 ignored issues
show
Unused Code introduced by
The parameter $type is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

1584
function sd_get_hover_animations_input( /** @scrutinizer ignore-unused */ $type = 'hover_animations', $overwrite = array() ) {

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

Loading history...
1585
1586
	$options = array(
1587
		''                 => __( 'none', 'super-duper' ),
1588
		'hover-zoom'       => __( 'Zoom', 'super-duper' ),
1589
		'hover-shadow'     => __( 'Shadow', 'super-duper' ),
1590
		'hover-move-up'    => __( 'Move up', 'super-duper' ),
1591
		'hover-move-down'  => __( 'Move down', 'super-duper' ),
1592
		'hover-move-left'  => __( 'Move left', 'super-duper' ),
1593
		'hover-move-right' => __( 'Move right', 'super-duper' ),
1594
	);
1595
1596
	$defaults = array(
1597
		'type'     => 'select',
1598
		'multiple' => true,
1599
		'title'    => __( 'Hover Animations', 'super-duper' ),
1600
		'options'  => $options,
1601
		'default'  => '',
1602
		'desc_tip' => true,
1603
		'group'    => __( 'Hover Animations', 'super-duper' ),
1604
	);
1605
1606
	$input = wp_parse_args( $overwrite, $defaults );
1607
1608
	return $input;
1609
}
1610
1611
1612
function sd_get_flex_align_items_input( $type = 'align-items', $overwrite = array() ) {
0 ignored issues
show
Unused Code introduced by
The parameter $type is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

1612
function sd_get_flex_align_items_input( /** @scrutinizer ignore-unused */ $type = 'align-items', $overwrite = array() ) {

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

Loading history...
1613
	$device_size = '';
1614
	if ( ! empty( $overwrite['device_type'] ) ) {
1615
		if ( $overwrite['device_type'] == 'Tablet' ) {
1616
			$device_size = '-md';
1617
		} elseif ( $overwrite['device_type'] == 'Desktop' ) {
1618
			$device_size = '-lg';
1619
		}
1620
	}
1621
	$options = array(
1622
		''                                         => __( 'Default', 'super-duper' ),
1623
		'align-items' . $device_size . '-start'    => 'align-items-start',
1624
		'align-items' . $device_size . '-end'      => 'align-items-end',
1625
		'align-items' . $device_size . '-center'   => 'align-items-center',
1626
		'align-items' . $device_size . '-baseline' => 'align-items-baseline',
1627
		'align-items' . $device_size . '-stretch'  => 'align-items-stretch',
1628
	);
1629
1630
	$defaults = array(
1631
		'type'            => 'select',
1632
		'title'           => __( 'Vertical Align Items', 'super-duper' ),
1633
		'options'         => $options,
1634
		'default'         => '',
1635
		'desc_tip'        => true,
1636
		'group'           => __( 'Wrapper Styles', 'super-duper' ),
1637
		'element_require' => ' ( ( [%container%]=="row" ) || ( [%display%]=="d-flex" || [%display_md%]=="d-md-flex" || [%display_lg%]=="d-lg-flex" ) ) ',
1638
1639
	);
1640
1641
	$input = wp_parse_args( $overwrite, $defaults );
1642
1643
	return $input;
1644
}
1645
1646
function sd_get_flex_align_items_input_group( $type = 'flex_align_items', $overwrite = array() ) {
1647
	$inputs = array();
1648
	$sizes  = array(
1649
		''    => 'Mobile',
1650
		'_md' => 'Tablet',
1651
		'_lg' => 'Desktop',
1652
	);
1653
1654
	if ( $overwrite !== false ) {
1655
1656
		foreach ( $sizes as $ds => $dt ) {
1657
			$overwrite['device_type'] = $dt;
1658
			$inputs[ $type . $ds ]    = sd_get_flex_align_items_input( $type, $overwrite );
1659
		}
1660
	}
1661
1662
	return $inputs;
1663
}
1664
1665
function sd_get_flex_justify_content_input( $type = 'flex_justify_content', $overwrite = array() ) {
0 ignored issues
show
Unused Code introduced by
The parameter $type is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

1665
function sd_get_flex_justify_content_input( /** @scrutinizer ignore-unused */ $type = 'flex_justify_content', $overwrite = array() ) {

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

Loading history...
1666
	$device_size = '';
1667
	if ( ! empty( $overwrite['device_type'] ) ) {
1668
		if ( $overwrite['device_type'] == 'Tablet' ) {
1669
			$device_size = '-md';
1670
		} elseif ( $overwrite['device_type'] == 'Desktop' ) {
1671
			$device_size = '-lg';
1672
		}
1673
	}
1674
	$options = array(
1675
		''                                            => __( 'Default', 'super-duper' ),
1676
		'justify-content' . $device_size . '-start'   => 'justify-content-start',
1677
		'justify-content' . $device_size . '-end'     => 'justify-content-end',
1678
		'justify-content' . $device_size . '-center'  => 'justify-content-center',
1679
		'justify-content' . $device_size . '-between' => 'justify-content-between',
1680
		'justify-content' . $device_size . '-stretch' => 'justify-content-around',
1681
	);
1682
1683
	$defaults = array(
1684
		'type'            => 'select',
1685
		'title'           => __( 'Justify content' ),
1686
		'options'         => $options,
1687
		'default'         => '',
1688
		'desc_tip'        => true,
1689
		'group'           => __( 'Wrapper Styles', 'super-duper' ),
1690
		'element_require' => '( ( [%container%]=="row" ) || ( [%display%]=="d-flex" || [%display_md%]=="d-md-flex" || [%display_lg%]=="d-lg-flex" ) ) ',
1691
1692
	);
1693
1694
	$input = wp_parse_args( $overwrite, $defaults );
1695
1696
	return $input;
1697
}
1698
1699
function sd_get_flex_justify_content_input_group( $type = 'flex_justify_content', $overwrite = array() ) {
1700
	$inputs = array();
1701
	$sizes  = array(
1702
		''    => 'Mobile',
1703
		'_md' => 'Tablet',
1704
		'_lg' => 'Desktop',
1705
	);
1706
1707
	if ( $overwrite !== false ) {
1708
1709
		foreach ( $sizes as $ds => $dt ) {
1710
			$overwrite['device_type'] = $dt;
1711
			$inputs[ $type . $ds ]    = sd_get_flex_justify_content_input( $type, $overwrite );
1712
		}
1713
	}
1714
1715
	return $inputs;
1716
}
1717
1718
1719
function sd_get_flex_align_self_input( $type = 'flex_align_self', $overwrite = array() ) {
0 ignored issues
show
Unused Code introduced by
The parameter $type is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

1719
function sd_get_flex_align_self_input( /** @scrutinizer ignore-unused */ $type = 'flex_align_self', $overwrite = array() ) {

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

Loading history...
1720
	$device_size = '';
1721
	if ( ! empty( $overwrite['device_type'] ) ) {
1722
		if ( $overwrite['device_type'] == 'Tablet' ) {
1723
			$device_size = '-md';
1724
		} elseif ( $overwrite['device_type'] == 'Desktop' ) {
1725
			$device_size = '-lg';
1726
		}
1727
	}
1728
	$options = array(
1729
		''                                         => __( 'Default', 'super-duper' ),
1730
		'align-items' . $device_size . '-start'    => 'align-items-start',
1731
		'align-items' . $device_size . '-end'      => 'align-items-end',
1732
		'align-items' . $device_size . '-center'   => 'align-items-center',
1733
		'align-items' . $device_size . '-baseline' => 'align-items-baseline',
1734
		'align-items' . $device_size . '-stretch'  => 'align-items-stretch',
1735
	);
1736
1737
	$defaults = array(
1738
		'type'            => 'select',
1739
		'title'           => __( 'Align Self', 'super-duper' ),
1740
		'options'         => $options,
1741
		'default'         => '',
1742
		'desc_tip'        => true,
1743
		'group'           => __( 'Wrapper Styles', 'super-duper' ),
1744
		'element_require' => ' [%container%]=="col" ',
1745
1746
	);
1747
1748
	$input = wp_parse_args( $overwrite, $defaults );
1749
1750
	return $input;
1751
}
1752
1753
function sd_get_flex_align_self_input_group( $type = 'flex_align_self', $overwrite = array() ) {
1754
	$inputs = array();
1755
	$sizes  = array(
1756
		''    => 'Mobile',
1757
		'_md' => 'Tablet',
1758
		'_lg' => 'Desktop',
1759
	);
1760
1761
	if ( $overwrite !== false ) {
1762
1763
		foreach ( $sizes as $ds => $dt ) {
1764
			$overwrite['device_type'] = $dt;
1765
			$inputs[ $type . $ds ]    = sd_get_flex_align_self_input( $type, $overwrite );
1766
		}
1767
	}
1768
1769
	return $inputs;
1770
}
1771
1772
function sd_get_flex_order_input( $type = 'flex_order', $overwrite = array() ) {
0 ignored issues
show
Unused Code introduced by
The parameter $type is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

1772
function sd_get_flex_order_input( /** @scrutinizer ignore-unused */ $type = 'flex_order', $overwrite = array() ) {

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

Loading history...
1773
	$device_size = '';
1774
	if ( ! empty( $overwrite['device_type'] ) ) {
1775
		if ( $overwrite['device_type'] == 'Tablet' ) {
1776
			$device_size = '-md';
1777
		} elseif ( $overwrite['device_type'] == 'Desktop' ) {
1778
			$device_size = '-lg';
1779
		}
1780
	}
1781
	$options = array(
1782
		'' => __( 'Default', 'super-duper' ),
1783
	);
1784
1785
	$i = 0;
1786
	while ( $i <= 5 ) {
1787
		$options[ 'order' . $device_size . '-' . $i ] = $i;
1788
		$i++;
1789
	}
1790
1791
	$defaults = array(
1792
		'type'            => 'select',
1793
		'title'           => __( 'Flex Order', 'super-duper' ),
1794
		'options'         => $options,
1795
		'default'         => '',
1796
		'desc_tip'        => true,
1797
		'group'           => __( 'Wrapper Styles', 'super-duper' ),
1798
		'element_require' => ' [%container%]=="col" ',
1799
1800
	);
1801
1802
	$input = wp_parse_args( $overwrite, $defaults );
1803
1804
	return $input;
1805
}
1806
1807
function sd_get_flex_order_input_group( $type = 'flex_order', $overwrite = array() ) {
1808
	$inputs = array();
1809
	$sizes  = array(
1810
		''    => 'Mobile',
1811
		'_md' => 'Tablet',
1812
		'_lg' => 'Desktop',
1813
	);
1814
1815
	if ( $overwrite !== false ) {
1816
1817
		foreach ( $sizes as $ds => $dt ) {
1818
			$overwrite['device_type'] = $dt;
1819
			$inputs[ $type . $ds ]    = sd_get_flex_order_input( $type, $overwrite );
1820
		}
1821
	}
1822
1823
	return $inputs;
1824
}
1825
1826
function sd_get_flex_wrap_group( $type = 'flex_wrap', $overwrite = array() ) {
1827
	$inputs = array();
1828
	$sizes  = array(
1829
		''    => 'Mobile',
1830
		'_md' => 'Tablet',
1831
		'_lg' => 'Desktop',
1832
	);
1833
1834
	if ( $overwrite !== false ) {
1835
1836
		foreach ( $sizes as $ds => $dt ) {
1837
			$overwrite['device_type'] = $dt;
1838
			$inputs[ $type . $ds ]    = sd_get_flex_wrap_input( $type, $overwrite );
1839
		}
1840
	}
1841
1842
	return $inputs;
1843
}
1844
1845
function sd_get_flex_wrap_input( $type = 'flex_wrap', $overwrite = array() ) {
0 ignored issues
show
Unused Code introduced by
The parameter $type is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

1845
function sd_get_flex_wrap_input( /** @scrutinizer ignore-unused */ $type = 'flex_wrap', $overwrite = array() ) {

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

Loading history...
1846
	$device_size = '';
1847
	if ( ! empty( $overwrite['device_type'] ) ) {
1848
		if ( $overwrite['device_type'] == 'Tablet' ) {
1849
			$device_size = '-md';
1850
		} elseif ( $overwrite['device_type'] == 'Desktop' ) {
1851
			$device_size = '-lg';
1852
		}
1853
	}
1854
	$options = array(
1855
		''                                      => __( 'Default', 'super-duper' ),
1856
		'flex' . $device_size . '-nowrap'       => 'nowrap',
1857
		'flex' . $device_size . '-wrap'         => 'wrap',
1858
		'flex' . $device_size . '-wrap-reverse' => 'wrap-reverse',
1859
	);
1860
1861
	$defaults = array(
1862
		'type'     => 'select',
1863
		'title'    => __( 'Flex wrap', 'super-duper' ),
1864
		'options'  => $options,
1865
		'default'  => '',
1866
		'desc_tip' => true,
1867
		'group'    => __( 'Wrapper Styles', 'super-duper' ),
1868
	);
1869
1870
	$input = wp_parse_args( $overwrite, $defaults );
1871
1872
	return $input;
1873
}
1874
1875
function sd_get_float_group( $type = 'float', $overwrite = array() ) {
1876
	$inputs = array();
1877
	$sizes  = array(
1878
		''    => 'Mobile',
1879
		'_md' => 'Tablet',
1880
		'_lg' => 'Desktop',
1881
	);
1882
1883
	if ( $overwrite !== false ) {
1884
1885
		foreach ( $sizes as $ds => $dt ) {
1886
			$overwrite['device_type'] = $dt;
1887
			$inputs[ $type . $ds ]    = sd_get_float_input( $type, $overwrite );
1888
		}
1889
	}
1890
1891
	return $inputs;
1892
}
1893
function sd_get_float_input( $type = 'float', $overwrite = array() ) {
0 ignored issues
show
Unused Code introduced by
The parameter $type is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

1893
function sd_get_float_input( /** @scrutinizer ignore-unused */ $type = 'float', $overwrite = array() ) {

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

Loading history...
1894
	$device_size = '';
1895
	if ( ! empty( $overwrite['device_type'] ) ) {
1896
		if ( $overwrite['device_type'] == 'Tablet' ) {
1897
			$device_size = '-md';
1898
		} elseif ( $overwrite['device_type'] == 'Desktop' ) {
1899
			$device_size = '-lg';
1900
		}
1901
	}
1902
	$options = array(
1903
		''                                      => __( 'Default', 'super-duper' ),
1904
		'float' . $device_size . '-start'       => 'left',
1905
		'float' . $device_size . '-end'         => 'right',
1906
		'float' . $device_size . '-none' => 'none',
1907
	);
1908
1909
	$defaults = array(
1910
		'type'     => 'select',
1911
		'title'    => __( 'Float', 'super-duper' ),
1912
		'options'  => $options,
1913
		'default'  => '',
1914
		'desc_tip' => true,
1915
		'group'    => __( 'Wrapper Styles', 'super-duper' ),
1916
	);
1917
1918
	$input = wp_parse_args( $overwrite, $defaults );
1919
1920
	return $input;
1921
}
1922
1923
/**
1924
 * @param $type
1925
 * @param $overwrite
1926
 *
1927
 * @return array
1928
 */
1929
function sd_get_zindex_input( $type = 'zindex', $overwrite = array() ) {
0 ignored issues
show
Unused Code introduced by
The parameter $type is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

1929
function sd_get_zindex_input( /** @scrutinizer ignore-unused */ $type = 'zindex', $overwrite = array() ) {

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

Loading history...
1930
1931
	$options = array(
1932
		''          => __( 'Default', 'super-duper' ),
1933
		'zindex-0'  => '0',
1934
		'zindex-1'  => '1',
1935
		'zindex-5'  => '5',
1936
		'zindex-10' => '10',
1937
	);
1938
1939
	$defaults = array(
1940
		'type'     => 'select',
1941
		'title'    => __( 'Z-index', 'super-duper' ),
1942
		'options'  => $options,
1943
		'default'  => '',
1944
		'desc_tip' => true,
1945
		'group'    => __( 'Wrapper Styles', 'super-duper' ),
1946
	);
1947
1948
	$input = wp_parse_args( $overwrite, $defaults );
1949
1950
	return $input;
1951
}
1952
1953
/**
1954
 * @param $type
1955
 * @param $overwrite
1956
 *
1957
 * @return array
1958
 */
1959
function sd_get_overflow_input( $type = 'overflow', $overwrite = array() ) {
0 ignored issues
show
Unused Code introduced by
The parameter $type is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

1959
function sd_get_overflow_input( /** @scrutinizer ignore-unused */ $type = 'overflow', $overwrite = array() ) {

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

Loading history...
1960
1961
	$options = array(
1962
		''                 => __( 'Default', 'super-duper' ),
1963
		'overflow-auto'    => __( 'Auto', 'super-duper' ),
1964
		'overflow-hidden'  => __( 'Hidden', 'super-duper' ),
1965
		'overflow-visible' => __( 'Visible', 'super-duper' ),
1966
		'overflow-scroll'  => __( 'Scroll', 'super-duper' ),
1967
	);
1968
1969
	$defaults = array(
1970
		'type'     => 'select',
1971
		'title'    => __( 'Overflow', 'super-duper' ),
1972
		'options'  => $options,
1973
		'default'  => '',
1974
		'desc_tip' => true,
1975
		'group'    => __( 'Wrapper Styles', 'super-duper' ),
1976
	);
1977
1978
	$input = wp_parse_args( $overwrite, $defaults );
1979
1980
	return $input;
1981
}
1982
1983
/**
1984
 * @param $type
1985
 * @param $overwrite
1986
 *
1987
 * @return array
1988
 */
1989
function sd_get_max_height_input( $type = 'max_height', $overwrite = array() ) {
0 ignored issues
show
Unused Code introduced by
The parameter $type is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

1989
function sd_get_max_height_input( /** @scrutinizer ignore-unused */ $type = 'max_height', $overwrite = array() ) {

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

Loading history...
1990
1991
	$defaults = array(
1992
		'type'        => 'text',
1993
		'title'       => __( 'Max height', 'super-duper' ),
1994
		'value'       => '',
1995
		'default'     => '',
1996
		'placeholder' => '',
1997
		'desc_tip'    => true,
1998
		'group'       => __( 'Wrapper Styles', 'super-duper' ),
1999
	);
2000
2001
	$input = wp_parse_args( $overwrite, $defaults );
2002
2003
	return $input;
2004
}
2005
2006
/**
2007
 * @param $type
2008
 * @param $overwrite
2009
 *
2010
 * @return array
2011
 */
2012
function sd_get_scrollbars_input( $type = 'scrollbars', $overwrite = array() ) {
0 ignored issues
show
Unused Code introduced by
The parameter $type is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

2012
function sd_get_scrollbars_input( /** @scrutinizer ignore-unused */ $type = 'scrollbars', $overwrite = array() ) {

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

Loading history...
2013
2014
	$options = array(
2015
		''               => __( 'Default', 'super-duper' ),
2016
		'scrollbars-ios' => __( 'IOS Style', 'super-duper' ),
2017
	);
2018
2019
	$defaults = array(
2020
		'type'     => 'select',
2021
		'title'    => __( 'Scrollbars', 'super-duper' ),
2022
		'options'  => $options,
2023
		'default'  => '',
2024
		'desc_tip' => true,
2025
		'group'    => __( 'Wrapper Styles', 'super-duper' ),
2026
	);
2027
2028
	$input = wp_parse_args( $overwrite, $defaults );
2029
2030
	return $input;
2031
}
2032
2033
/**
2034
 * This is a placeholder function for the visibility conditions input.
2035
 *
2036
 * @param $type
2037
 * @param $overwrite
2038
 *
2039
 * @return array
2040
 */
2041
function sd_get_visibility_conditions_input( $type = 'visibility_conditions', $overwrite = array() ) {
0 ignored issues
show
Unused Code introduced by
The parameter $type is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

2041
function sd_get_visibility_conditions_input( /** @scrutinizer ignore-unused */ $type = 'visibility_conditions', $overwrite = array() ) {

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

Loading history...
2042
2043
	$defaults = array(
2044
		'type'     => 'hidden',
2045
		'title'    => __( '', 'super-duper' ),
2046
		'default'  => '',
2047
		'desc_tip' => true,
2048
		'group'    => __( '', 'super-duper' ),
2049
	);
2050
2051
	$input = wp_parse_args( $overwrite, $defaults );
2052
2053
	return $input;
2054
}
2055
2056
/**
2057
 * Build AUI classes from settings.
2058
 *
2059
 * @param $args
2060
 *
2061
 * @return string
2062
 * @todo find best way to use px- py- or general p-
2063
 */
2064
function sd_build_aui_class( $args ) {
2065
	global $aui_bs5;
2066
2067
	$classes = array();
2068
2069
	if ( $aui_bs5 ) {
2070
		$p_ml = 'ms-';
2071
		$p_mr = 'me-';
2072
2073
		$p_pl = 'ps-';
2074
		$p_pr = 'pe-';
2075
	} else {
2076
		$p_ml = 'ml-';
2077
		$p_mr = 'mr-';
2078
2079
		$p_pl = 'pl-';
2080
		$p_pr = 'pr-';
2081
	}
2082
2083
	// margins.
2084
	if ( isset( $args['mt'] ) && $args['mt'] !== '' ) {
2085
		$classes[] = 'mt-' . sanitize_html_class( $args['mt'] );
2086
		$mt        = $args['mt'];
2087
	} else {
2088
		$mt = null;
2089
	}
2090
	if ( isset( $args['mr'] ) && $args['mr'] !== '' ) {
2091
		$classes[] = $p_mr . sanitize_html_class( $args['mr'] );
2092
		$mr        = $args['mr'];
2093
	} else {
2094
		$mr = null;
2095
	}
2096
	if ( isset( $args['mb'] ) && $args['mb'] !== '' ) {
2097
		$classes[] = 'mb-' . sanitize_html_class( $args['mb'] );
2098
		$mb        = $args['mb'];
2099
	} else {
2100
		$mb = null;
2101
	}
2102
	if ( isset( $args['ml'] ) && $args['ml'] !== '' ) {
2103
		$classes[] = $p_ml . sanitize_html_class( $args['ml'] );
2104
		$ml        = $args['ml'];
2105
	} else {
2106
		$ml = null;
2107
	}
2108
2109
	// margins tablet.
2110
	if ( isset( $args['mt_md'] ) && $args['mt_md'] !== '' ) {
2111
		$classes[] = 'mt-md-' . sanitize_html_class( $args['mt_md'] );
2112
		$mt_md     = $args['mt_md'];
2113
	} else {
2114
		$mt_md = null;
2115
	}
2116
	if ( isset( $args['mr_md'] ) && $args['mr_md'] !== '' ) {
2117
		$classes[] = $p_mr . 'md-' . sanitize_html_class( $args['mr_md'] );
2118
		$mt_md     = $args['mr_md'];
2119
	} else {
2120
		$mr_md = null;
2121
	}
2122
	if ( isset( $args['mb_md'] ) && $args['mb_md'] !== '' ) {
2123
		$classes[] = 'mb-md-' . sanitize_html_class( $args['mb_md'] );
2124
		$mt_md     = $args['mb_md'];
2125
	} else {
2126
		$mb_md = null;
2127
	}
2128
	if ( isset( $args['ml_md'] ) && $args['ml_md'] !== '' ) {
2129
		$classes[] = $p_ml . 'md-' . sanitize_html_class( $args['ml_md'] );
2130
		$mt_md     = $args['ml_md'];
2131
	} else {
2132
		$ml_md = null;
2133
	}
2134
2135
	// margins desktop.
2136
	if ( isset( $args['mt_lg'] ) && $args['mt_lg'] !== '' ) {
2137
		if ( $mt == null && $mt_md == null ) {
2138
			$classes[] = 'mt-' . sanitize_html_class( $args['mt_lg'] );
2139
		} else {
2140
			$classes[] = 'mt-lg-' . sanitize_html_class( $args['mt_lg'] );
2141
		}
2142
	}
2143
	if ( isset( $args['mr_lg'] ) && $args['mr_lg'] !== '' ) {
2144
		if ( $mr == null && $mr_md == null ) {
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $mr_md does not seem to be defined for all execution paths leading up to this point.
Loading history...
2145
			$classes[] = $p_mr . sanitize_html_class( $args['mr_lg'] );
2146
		} else {
2147
			$classes[] = $p_mr . 'lg-' . sanitize_html_class( $args['mr_lg'] );
2148
		}
2149
	}
2150
	if ( isset( $args['mb_lg'] ) && $args['mb_lg'] !== '' ) {
2151
		if ( $mb == null && $mb_md == null ) {
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $mb_md does not seem to be defined for all execution paths leading up to this point.
Loading history...
2152
			$classes[] = 'mb-' . sanitize_html_class( $args['mb_lg'] );
2153
		} else {
2154
			$classes[] = 'mb-lg-' . sanitize_html_class( $args['mb_lg'] );
2155
		}
2156
	}
2157
	if ( isset( $args['ml_lg'] ) && $args['ml_lg'] !== '' ) {
2158
		if ( $ml == null && $ml_md == null ) {
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $ml_md does not seem to be defined for all execution paths leading up to this point.
Loading history...
2159
			$classes[] = $p_ml . sanitize_html_class( $args['ml_lg'] );
2160
		} else {
2161
			$classes[] = $p_ml . 'lg-' . sanitize_html_class( $args['ml_lg'] );
2162
		}
2163
	}
2164
2165
	// padding.
2166
	if ( isset( $args['pt'] ) && $args['pt'] !== '' ) {
2167
		$classes[] = 'pt-' . sanitize_html_class( $args['pt'] );
2168
		$pt        = $args['pt'];
2169
	} else {
2170
		$pt = null;
2171
	}
2172
	if ( isset( $args['pr'] ) && $args['pr'] !== '' ) {
2173
		$classes[] = $p_pr . sanitize_html_class( $args['pr'] );
2174
		$pr        = $args['pr'];
2175
	} else {
2176
		$pr = null;
2177
	}
2178
	if ( isset( $args['pb'] ) && $args['pb'] !== '' ) {
2179
		$classes[] = 'pb-' . sanitize_html_class( $args['pb'] );
2180
		$pb        = $args['pb'];
2181
	} else {
2182
		$pb = null;
2183
	}
2184
	if ( isset( $args['pl'] ) && $args['pl'] !== '' ) {
2185
		$classes[] = $p_pl . sanitize_html_class( $args['pl'] );
2186
		$pl        = $args['pl'];
2187
	} else {
2188
		$pl = null;
2189
	}
2190
2191
	// padding tablet.
2192
	if ( isset( $args['pt_md'] ) && $args['pt_md'] !== '' ) {
2193
		$classes[] = 'pt-md-' . sanitize_html_class( $args['pt_md'] );
2194
		$pt_md     = $args['pt_md'];
2195
	} else {
2196
		$pt_md = null;
2197
	}
2198
	if ( isset( $args['pr_md'] ) && $args['pr_md'] !== '' ) {
2199
		$classes[] = $p_pr . 'md-' . sanitize_html_class( $args['pr_md'] );
2200
		$pt_md     = $args['pr_md'];
2201
	} else {
2202
		$pr_md = null;
2203
	}
2204
	if ( isset( $args['pb_md'] ) && $args['pb_md'] !== '' ) {
2205
		$classes[] = 'pb-md-' . sanitize_html_class( $args['pb_md'] );
2206
		$pt_md     = $args['pb_md'];
2207
	} else {
2208
		$pb_md = null;
2209
	}
2210
	if ( isset( $args['pl_md'] ) && $args['pl_md'] !== '' ) {
2211
		$classes[] = $p_pl . 'md-' . sanitize_html_class( $args['pl_md'] );
2212
		$pt_md     = $args['pl_md'];
2213
	} else {
2214
		$pl_md = null;
2215
	}
2216
2217
	// padding desktop.
2218
	if ( isset( $args['pt_lg'] ) && $args['pt_lg'] !== '' ) {
2219
		if ( $pt == null && $pt_md == null ) {
2220
			$classes[] = 'pt-' . sanitize_html_class( $args['pt_lg'] );
2221
		} else {
2222
			$classes[] = 'pt-lg-' . sanitize_html_class( $args['pt_lg'] );
2223
		}
2224
	}
2225
	if ( isset( $args['pr_lg'] ) && $args['pr_lg'] !== '' ) {
2226
		if ( $pr == null && $pr_md == null ) {
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $pr_md does not seem to be defined for all execution paths leading up to this point.
Loading history...
2227
			$classes[] = $p_pr . sanitize_html_class( $args['pr_lg'] );
2228
		} else {
2229
			$classes[] = $p_pr . 'lg-' . sanitize_html_class( $args['pr_lg'] );
2230
		}
2231
	}
2232
	if ( isset( $args['pb_lg'] ) && $args['pb_lg'] !== '' ) {
2233
		if ( $pb == null && $pb_md == null ) {
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $pb_md does not seem to be defined for all execution paths leading up to this point.
Loading history...
2234
			$classes[] = 'pb-' . sanitize_html_class( $args['pb_lg'] );
2235
		} else {
2236
			$classes[] = 'pb-lg-' . sanitize_html_class( $args['pb_lg'] );
2237
		}
2238
	}
2239
	if ( isset( $args['pl_lg'] ) && $args['pl_lg'] !== '' ) {
2240
		if ( $pl == null && $pl_md == null ) {
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $pl_md does not seem to be defined for all execution paths leading up to this point.
Loading history...
2241
			$classes[] = $p_pl . sanitize_html_class( $args['pl_lg'] );
2242
		} else {
2243
			$classes[] = $p_pl . 'lg-' . sanitize_html_class( $args['pl_lg'] );
2244
		}
2245
	}
2246
2247
	// row cols, mobile, tablet, desktop
2248
	if ( ! empty( $args['row_cols'] ) && $args['row_cols'] !== '' ) {
2249
		$classes[] = sanitize_html_class( 'row-cols-' . $args['row_cols'] );
2250
		$row_cols  = $args['row_cols'];
2251
	} else {
2252
		$row_cols = null;
2253
	}
2254
	if ( ! empty( $args['row_cols_md'] ) && $args['row_cols_md'] !== '' ) {
2255
		$classes[]   = sanitize_html_class( 'row-cols-md-' . $args['row_cols_md'] );
2256
		$row_cols_md = $args['row_cols_md'];
2257
	} else {
2258
		$row_cols_md = null;
2259
	}
2260
	if ( ! empty( $args['row_cols_lg'] ) && $args['row_cols_lg'] !== '' ) {
2261
		if ( $row_cols == null && $row_cols_md == null ) {
2262
			$classes[] = sanitize_html_class( 'row-cols-' . $args['row_cols_lg'] );
2263
		} else {
2264
			$classes[] = sanitize_html_class( 'row-cols-lg-' . $args['row_cols_lg'] );
2265
		}
2266
	}
2267
2268
	// columns , mobile, tablet, desktop
2269
	if ( ! empty( $args['col'] ) && $args['col'] !== '' ) {
2270
		$classes[] = sanitize_html_class( 'col-' . $args['col'] );
2271
		$col       = $args['col'];
2272
	} else {
2273
		$col = null;
2274
	}
2275
	if ( ! empty( $args['col_md'] ) && $args['col_md'] !== '' ) {
2276
		$classes[] = sanitize_html_class( 'col-md-' . $args['col_md'] );
2277
		$col_md    = $args['col_md'];
2278
	} else {
2279
		$col_md = null;
2280
	}
2281
	if ( ! empty( $args['col_lg'] ) && $args['col_lg'] !== '' ) {
2282
		if ( $col == null && $col_md == null ) {
2283
			$classes[] = sanitize_html_class( 'col-' . $args['col_lg'] );
2284
		} else {
2285
			$classes[] = sanitize_html_class( 'col-lg-' . $args['col_lg'] );
2286
		}
2287
	}
2288
2289
	// border
2290
	if ( isset( $args['border'] ) && ( $args['border'] == 'none' || $args['border'] === '0' || $args['border'] === 0 ) ) {
2291
		$classes[] = 'border-0';
2292
	} elseif ( ! empty( $args['border'] ) ) {
2293
		$border_class = 'border';
2294
		if ( ! empty( $args['border_type'] ) && strpos( $args['border_type'], '-0' ) === false ) {
2295
			$border_class = '';
2296
		}
2297
		$classes[] = $border_class . ' border-' . sanitize_html_class( $args['border'] );
2298
	}
2299
2300
	// border radius type
2301
	if ( ! empty( $args['rounded'] ) ) {
2302
		$classes[] = sanitize_html_class( $args['rounded'] );
2303
	}
2304
2305
	// border radius size BS4
2306
	if ( isset( $args['rounded_size'] ) && in_array( $args['rounded_size'], array( 'sm', 'lg' ) ) ) {
2307
		$classes[] = 'rounded-' . sanitize_html_class( $args['rounded_size'] );
2308
		// if we set a size then we need to remove "rounded" if set
2309
		if ( ( $key = array_search( 'rounded', $classes ) ) !== false ) {
2310
			unset( $classes[ $key ] );
2311
		}
2312
	} else {
2313
2314
		// border radius size , mobile, tablet, desktop
2315
		if ( isset( $args['rounded_size'] ) && $args['rounded_size'] !== '' ) {
2316
			$classes[]    = sanitize_html_class( 'rounded-' . $args['rounded_size'] );
2317
			$rounded_size = $args['rounded_size'];
2318
		} else {
2319
			$rounded_size = null;
2320
		}
2321
		if ( isset( $args['rounded_size_md'] ) && $args['rounded_size_md'] !== '' ) {
2322
			$classes[]       = sanitize_html_class( 'rounded-md-' . $args['rounded_size_md'] );
2323
			$rounded_size_md = $args['rounded_size_md'];
2324
		} else {
2325
			$rounded_size_md = null;
2326
		}
2327
		if ( isset( $args['rounded_size_lg'] ) && $args['rounded_size_lg'] !== '' ) {
2328
			if ( $rounded_size == null && $rounded_size_md == null ) {
2329
				$classes[] = sanitize_html_class( 'rounded-' . $args['rounded_size_lg'] );
2330
			} else {
2331
				$classes[] = sanitize_html_class( 'rounded-lg-' . $args['rounded_size_lg'] );
2332
			}
2333
		}
2334
	}
2335
2336
	// shadow
2337
	//if ( !empty( $args['shadow'] ) ) { $classes[] = sanitize_html_class($args['shadow']); }
2338
2339
	// background
2340
	if ( ! empty( $args['bg'] ) ) {
2341
		$classes[] = 'bg-' . sanitize_html_class( $args['bg'] );
2342
	}
2343
2344
	// text_color
2345
	if ( ! empty( $args['text_color'] ) ) {
2346
		$classes[] = 'text-' . sanitize_html_class( $args['text_color'] );
2347
	}
2348
2349
	// text_align
2350
	if ( ! empty( $args['text_justify'] ) ) {
2351
		$classes[] = 'text-justify';
2352
	} else {
2353
		if ( ! empty( $args['text_align'] ) ) {
2354
			$classes[]  = sanitize_html_class( $args['text_align'] );
2355
			$text_align = $args['text_align'];
2356
		} else {
2357
			$text_align = null;
2358
		}
2359
		if ( ! empty( $args['text_align_md'] ) && $args['text_align_md'] !== '' ) {
2360
			$classes[]     = sanitize_html_class( $args['text_align_md'] );
2361
			$text_align_md = $args['text_align_md'];
2362
		} else {
2363
			$text_align_md = null;
2364
		}
2365
		if ( ! empty( $args['text_align_lg'] ) && $args['text_align_lg'] !== '' ) {
2366
			if ( $text_align == null && $text_align_md == null ) {
2367
				$classes[] = sanitize_html_class( str_replace( '-lg', '', $args['text_align_lg'] ) );
2368
			} else {
2369
				$classes[] = sanitize_html_class( $args['text_align_lg'] );
2370
			}
2371
		}
2372
	}
2373
2374
	// display
2375
	if ( ! empty( $args['display'] ) ) {
2376
		$classes[] = sanitize_html_class( $args['display'] );
2377
		$display   = $args['display'];
2378
	} else {
2379
		$display = null;
2380
	}
2381
	if ( ! empty( $args['display_md'] ) && $args['display_md'] !== '' ) {
2382
		$classes[]  = sanitize_html_class( $args['display_md'] );
2383
		$display_md = $args['display_md'];
2384
	} else {
2385
		$display_md = null;
2386
	}
2387
	if ( ! empty( $args['display_lg'] ) && $args['display_lg'] !== '' ) {
2388
		if ( $display == null && $display_md == null ) {
2389
			$classes[] = sanitize_html_class( str_replace( '-lg', '', $args['display_lg'] ) );
2390
		} else {
2391
			$classes[] = sanitize_html_class( $args['display_lg'] );
2392
		}
2393
	}
2394
2395
	// bgtus - background transparent until scroll
2396
	if ( ! empty( $args['bgtus'] ) ) {
2397
		$classes[] = sanitize_html_class( 'bg-transparent-until-scroll' );
2398
	}
2399
2400
	// cscos - change color scheme on scroll
2401
	if ( ! empty( $args['bgtus'] ) && ! empty( $args['cscos'] ) ) {
2402
		$classes[] = sanitize_html_class( 'color-scheme-flip-on-scroll' );
2403
	}
2404
2405
	// hover animations
2406
	if ( ! empty( $args['hover_animations'] ) ) {
2407
		$classes[] = sd_sanitize_html_classes( str_replace( ',', ' ', $args['hover_animations'] ) );
2408
	}
2409
2410
	// absolute_position
2411
	if ( ! empty( $args['absolute_position'] ) ) {
2412
		if ( 'top-left' === $args['absolute_position'] ) {
2413
			$classes[] = 'start-0 top-0';
2414
		} elseif ( 'top-center' === $args['absolute_position'] ) {
2415
			$classes[] = 'start-50 top-0 translate-middle';
2416
		} elseif ( 'top-right' === $args['absolute_position'] ) {
2417
			$classes[] = 'end-0 top-0';
2418
		} elseif ( 'center-left' === $args['absolute_position'] ) {
2419
			$classes[] = 'start-0 top-50';
2420
		} elseif ( 'center' === $args['absolute_position'] ) {
2421
			$classes[] = 'start-50 top-50 translate-middle';
2422
		} elseif ( 'center-right' === $args['absolute_position'] ) {
2423
			$classes[] = 'end-0 top-50';
2424
		} elseif ( 'bottom-left' === $args['absolute_position'] ) {
2425
			$classes[] = 'start-0 bottom-0';
2426
		} elseif ( 'bottom-center' === $args['absolute_position'] ) {
2427
			$classes[] = 'start-50 bottom-0 translate-middle';
2428
		} elseif ( 'bottom-right' === $args['absolute_position'] ) {
2429
			$classes[] = 'end-0 bottom-0';
2430
		}
2431
	}
2432
2433
	// build classes from build keys
2434
	$build_keys = sd_get_class_build_keys();
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $build_keys is correct as sd_get_class_build_keys() seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
2435
	if ( ! empty( $build_keys ) ) {
2436
		foreach ( $build_keys as $key ) {
0 ignored issues
show
Bug introduced by
The expression $build_keys of type void is not traversable.
Loading history...
2437
2438
			if ( substr( $key, -4 ) == '-MTD' ) {
2439
2440
				$k = str_replace( '-MTD', '', $key );
2441
2442
				// Mobile, Tablet, Desktop
2443
				if ( ! empty( $args[ $k ] ) && $args[ $k ] !== '' ) {
2444
					$classes[] = sanitize_html_class( $args[ $k ] );
2445
					$v         = $args[ $k ];
2446
				} else {
2447
					$v = null;
2448
				}
2449
				if ( ! empty( $args[ $k . '_md' ] ) && $args[ $k . '_md' ] !== '' ) {
2450
					$classes[] = sanitize_html_class( $args[ $k . '_md' ] );
2451
					$v_md      = $args[ $k . '_md' ];
2452
				} else {
2453
					$v_md = null;
2454
				}
2455
				if ( ! empty( $args[ $k . '_lg' ] ) && $args[ $k . '_lg' ] !== '' ) {
2456
					if ( $v == null && $v_md == null ) {
2457
						$classes[] = sanitize_html_class( str_replace( '-lg', '', $args[ $k . '_lg' ] ) );
2458
					} else {
2459
						$classes[] = sanitize_html_class( $args[ $k . '_lg' ] );
2460
					}
2461
				}
2462
			} else {
2463
				if ( $key == 'font_size' && ! empty( $args[ $key ] ) && $args[ $key ] == 'custom' ) {
2464
					continue;
2465
				}
2466
				if ( ! empty( $args[ $key ] ) ) {
2467
					$classes[] = sd_sanitize_html_classes( $args[ $key ] );
2468
				}
2469
			}
2470
		}
2471
	}
2472
2473
	return implode( ' ', $classes );
2474
}
2475
2476
/**
2477
 * Build Style output from arguments.
2478
 *
2479
 * @param $args
2480
 *
2481
 * @return array
2482
 */
2483
function sd_build_aui_styles( $args ) {
2484
2485
	$styles = array();
2486
2487
	// background color
2488
	if ( ! empty( $args['bg'] ) && $args['bg'] !== '' ) {
2489
		if ( $args['bg'] == 'custom-color' ) {
2490
			$styles['background-color'] = $args['bg_color'];
2491
		} elseif ( $args['bg'] == 'custom-gradient' ) {
2492
			$styles['background-image'] = $args['bg_gradient'];
2493
2494
			// use background on text.
2495
			if ( ! empty( $args['bg_on_text'] ) && $args['bg_on_text'] ) {
2496
				$styles['background-clip']         = 'text';
2497
				$styles['-webkit-background-clip'] = 'text';
2498
				$styles['text-fill-color']         = 'transparent';
2499
				$styles['-webkit-text-fill-color'] = 'transparent';
2500
			}
2501
		}
2502
	}
2503
2504
	if ( ! empty( $args['bg_image'] ) && $args['bg_image'] !== '' ) {
2505
		$hasImage = true;
2506
		if ( ! empty( $styles['background-color'] ) && $args['bg'] == 'custom-color' ) {
2507
			$styles['background-image']      = 'url(' . $args['bg_image'] . ')';
2508
			$styles['background-blend-mode'] = 'overlay';
2509
		} elseif ( ! empty( $styles['background-image'] ) && $args['bg'] == 'custom-gradient' ) {
2510
			$styles['background-image'] .= ',url(' . $args['bg_image'] . ')';
2511
		} elseif ( ! empty( $args['bg'] ) && $args['bg'] != '' && $args['bg'] != 'transparent' ) {
2512
			// do nothing as we alreay have a preset
2513
			$hasImage = false;
2514
		} else {
2515
			$styles['background-image'] = 'url(' . $args['bg_image'] . ')';
2516
		}
2517
2518
		if ( $hasImage ) {
2519
			$styles['background-size'] = 'cover';
2520
2521
			if ( ! empty( $args['bg_image_fixed'] ) && $args['bg_image_fixed'] ) {
2522
				$styles['background-attachment'] = 'fixed';
2523
			}
2524
		}
2525
2526
		if ( $hasImage && ! empty( $args['bg_image_xy'] ) && ! empty( $args['bg_image_xy']['x'] ) ) {
2527
			$styles['background-position'] = ( $args['bg_image_xy']['x'] * 100 ) . '% ' . ( $args['bg_image_xy']['y'] * 100 ) . '%';
2528
		}
2529
	}
2530
2531
	// sticky offset top
2532
	if ( ! empty( $args['sticky_offset_top'] ) && $args['sticky_offset_top'] !== '' ) {
2533
		$styles['top'] = absint( $args['sticky_offset_top'] );
2534
	}
2535
2536
	// sticky offset bottom
2537
	if ( ! empty( $args['sticky_offset_bottom'] ) && $args['sticky_offset_bottom'] !== '' ) {
2538
		$styles['bottom'] = absint( $args['sticky_offset_bottom'] );
2539
	}
2540
2541
	// font size
2542
	if ( ! empty( $args['font_size_custom'] ) && $args['font_size_custom'] !== '' ) {
2543
		$styles['font-size'] = (float) $args['font_size_custom'] . 'rem';
2544
	}
2545
2546
	// font color
2547
	if ( ! empty( $args['text_color_custom'] ) && $args['text_color_custom'] !== '' ) {
2548
		$styles['color'] = esc_attr( $args['text_color_custom'] );
2549
	}
2550
2551
	// font line height
2552
	if ( ! empty( $args['font_line_height'] ) && $args['font_line_height'] !== '' ) {
2553
		$styles['line-height'] = esc_attr( $args['font_line_height'] );
2554
	}
2555
2556
	// max height
2557
	if ( ! empty( $args['max_height'] ) && $args['max_height'] !== '' ) {
2558
		$styles['max-height'] = esc_attr( $args['max_height'] );
2559
	}
2560
2561
	$style_string = '';
2562
	if ( ! empty( $styles ) ) {
2563
		foreach ( $styles as $key => $val ) {
2564
			$style_string .= esc_attr( $key ) . ':' . esc_attr( $val ) . ';';
2565
		}
2566
	}
2567
2568
	return $style_string;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $style_string returns the type string which is incompatible with the documented return type array.
Loading history...
2569
2570
}
2571
2572
/**
2573
 * Build the hover styles from args.
2574
 *
2575
 * @param $args
2576
 * @param $is_preview
2577
 *
2578
 * @return string
2579
 */
2580
function sd_build_hover_styles( $args, $is_preview = false ) {
2581
	$rules = '';
2582
	// text color
2583
	if ( ! empty( $args['styleid'] ) ) {
2584
		$styleid = $is_preview ? 'html .editor-styles-wrapper .' . esc_attr( $args['styleid'] ) : 'html .' . esc_attr( $args['styleid'] );
2585
2586
		// text
2587
		if ( ! empty( $args['text_color_hover'] ) ) {
2588
			$key    = 'custom' === $args['text_color_hover'] && ! empty( $args['text_color_hover_custom'] ) ? 'text_color_hover_custom' : 'text_color_hover';
2589
			$color  = sd_get_color_from_var( $args[ $key ] );
2590
			$rules .= $styleid . ':hover {color: ' . $color . ' !important;} ';
2591
		}
2592
2593
		// bg
2594
		if ( ! empty( $args['bg_hover'] ) ) {
2595
			if ( 'custom-gradient' === $args['bg_hover'] ) {
2596
				$color  = $args['bg_hover_gradient'];
2597
				$rules .= $styleid . ':hover {background-image: ' . $color . ' !important;} ';
2598
				$rules .= $styleid . '.btn:hover {border-color: transparent !important;} ';
2599
			} else {
2600
				$key    = 'custom-color' === $args['bg_hover'] ? 'bg_hover_color' : 'bg_hover';
2601
				$color  = sd_get_color_from_var( $args[ $key ] );
2602
				$rules .= $styleid . ':hover {background: ' . $color . ' !important;} ';
2603
				$rules .= $styleid . '.btn:hover {border-color: ' . $color . ' !important;} ';
2604
			}
2605
		}
2606
	}
2607
2608
	return $rules ? '<style>' . $rules . '</style>' : '';
2609
}
2610
2611
/**
2612
 * Try to get a CSS color varibale for a given value.
2613
 *
2614
 * @param $var
2615
 *
2616
 * @return mixed|string
2617
 */
2618
function sd_get_color_from_var( $var ) {
2619
2620
	//sanitize_hex_color() @todo this does not cover transparency
2621
	if ( strpos( $var, '#' ) === false ) {
2622
		$var = defined( 'BLOCKSTRAP_BLOCKS_VERSION' ) ? 'var(--wp--preset--color--' . esc_attr( $var ) . ')' : 'var(--' . esc_attr( $var ) . ')';
2623
	}
2624
2625
	return $var;
2626
}
2627
2628
/**
2629
 * Sanitize single or multiple HTML classes.
2630
 *
2631
 * @param $classes
2632
 * @param $sep
2633
 *
2634
 * @return string
2635
 */
2636
function sd_sanitize_html_classes( $classes, $sep = ' ' ) {
2637
	$return = '';
2638
2639
	if ( ! is_array( $classes ) ) {
2640
		$classes = explode( $sep, $classes );
2641
	}
2642
2643
	if ( ! empty( $classes ) ) {
2644
		foreach ( $classes as $class ) {
2645
			$return .= sanitize_html_class( $class ) . ' ';
2646
		}
2647
	}
2648
2649
	return $return;
2650
}
2651
2652
2653
/**
2654
 * Keys that are used for the class builder.
2655
 *
2656
 * @return void
2657
 */
2658
function sd_get_class_build_keys() {
2659
	$keys = array(
2660
		'container',
2661
		'position',
2662
		'flex_direction',
2663
		'shadow',
2664
		'rounded',
2665
		'nav_style',
2666
		'horizontal_alignment',
2667
		'nav_fill',
2668
		'width',
2669
		'font_weight',
2670
		'font_size',
2671
		'font_case',
2672
		'css_class',
2673
		'flex_align_items-MTD',
2674
		'flex_justify_content-MTD',
2675
		'flex_align_self-MTD',
2676
		'flex_order-MTD',
2677
		'styleid',
2678
		'border_opacity',
2679
		'border_width',
2680
		'border_type',
2681
		'opacity',
2682
		'zindex',
2683
		'flex_wrap-MTD',
2684
		'h100',
2685
		'overflow',
2686
		'scrollbars',
2687
		'float-MTD',
2688
	);
2689
2690
	return apply_filters( 'sd_class_build_keys', $keys );
0 ignored issues
show
Bug Best Practice introduced by
The expression return apply_filters('sd...ass_build_keys', $keys) also could return the type array<integer,string> which is incompatible with the documented return type void.
Loading history...
2691
}
2692