Passed
Push — master ( 0a2366...999d0e )
by Stiofan
16:14
created

sd_visibility_gd_standard_field_options()   A

Complexity

Conditions 3

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 6
nop 1
dl 0
loc 12
rs 10
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', 'ayecode-connect' ),
56
		'auto' => __( 'auto', 'ayecode-connect' ),
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', 'ayecode-connect' ),
90
		'options'  => $options,
91
		'default'  => '',
92
		'desc_tip' => true,
93
		'group'    => __( 'Wrapper Styles', 'ayecode-connect' ),
94
	);
95
96
	// title
97
	if ( $type == 'mt' ) {
98
		$defaults['title'] = __( 'Margin top', 'ayecode-connect' );
99
		$defaults['icon']  = 'box-top';
100
		$defaults['row']   = array(
101
			'title' => __( 'Margins', 'ayecode-connect' ),
102
			'key'   => 'wrapper-margins',
103
			'open'  => true,
104
			'class' => 'text-center',
105
		);
106
	} elseif ( $type == 'mr' ) {
107
		$defaults['title'] = __( 'Margin right', 'ayecode-connect' );
108
		$defaults['icon']  = 'box-right';
109
		$defaults['row']   = array(
110
			'key' => 'wrapper-margins',
111
		);
112
	} elseif ( $type == 'mb' ) {
113
		$defaults['title'] = __( 'Margin bottom', 'ayecode-connect' );
114
		$defaults['icon']  = 'box-bottom';
115
		$defaults['row']   = array(
116
			'key' => 'wrapper-margins',
117
		);
118
	} elseif ( $type == 'ml' ) {
119
		$defaults['title'] = __( 'Margin left', 'ayecode-connect' );
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', 'ayecode-connect' ),
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', 'ayecode-connect' ),
161
		'options'  => $options,
162
		'default'  => '',
163
		'desc_tip' => true,
164
		'group'    => __( 'Wrapper Styles', 'ayecode-connect' ),
165
	);
166
167
	// title
168
	if ( $type == 'pt' ) {
169
		$defaults['title'] = __( 'Padding top', 'ayecode-connect' );
170
		$defaults['icon']  = 'box-top';
171
		$defaults['row']   = array(
172
			'title' => __( 'Padding', 'ayecode-connect' ),
173
			'key'   => 'wrapper-padding',
174
			'open'  => true,
175
			'class' => 'text-center',
176
		);
177
	} elseif ( $type == 'pr' ) {
178
		$defaults['title'] = __( 'Padding right', 'ayecode-connect' );
179
		$defaults['icon']  = 'box-right';
180
		$defaults['row']   = array(
181
			'key' => 'wrapper-padding',
182
		);
183
	} elseif ( $type == 'pb' ) {
184
		$defaults['title'] = __( 'Padding bottom', 'ayecode-connect' );
185
		$defaults['icon']  = 'box-bottom';
186
		$defaults['row']   = array(
187
			'key' => 'wrapper-padding',
188
		);
189
	} elseif ( $type == 'pl' ) {
190
		$defaults['title'] = __( 'Padding left', 'ayecode-connect' );
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', 'ayecode-connect' ),
218
		'options'  => array(),
219
		'default'  => '',
220
		'desc_tip' => true,
221
		'group'    => __( 'Wrapper Styles', 'ayecode-connect' ),
222
	);
223
224
	// title
225
	if ( 'rounded' === $type ) {
226
		$defaults['title']           = __( 'Border radius type', 'ayecode-connect' );
227
		$defaults['options']         = array(
228
			''               => __( 'Default', 'ayecode-connect' ),
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', 'ayecode-connect' );
238
239
		if ( $aui_bs5 ) {
240
			$defaults['options'] = array(
241
				''       => __( 'Default', 'ayecode-connect' ),
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', 'ayecode-connect' ),
253
				'sm' => __( 'Small', 'ayecode-connect' ),
254
				'lg' => __( 'Large', 'ayecode-connect' ),
255
			);
256
		}
257
		$defaults['element_require'] = '[%border%]';
258
	} elseif ( 'width' === $type ) { // BS%
259
		$defaults['title']           = __( 'Border width', 'ayecode-connect' );
260
		$defaults['options']         = array(
261
			''         => __( 'Default', 'ayecode-connect' ),
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', 'ayecode-connect' );
270
		$defaults['options']         = array(
271
			''                  => __( 'Default', 'ayecode-connect' ),
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', 'ayecode-connect' );
280
		$defaults['options']         = array(
281
			'border'          => __( 'Full (set color to show)', 'ayecode-connect' ),
282
			'border-top'      => __( 'Top', 'ayecode-connect' ),
283
			'border-bottom'   => __( 'Bottom', 'ayecode-connect' ),
284
			'border-left'     => __( 'Left', 'ayecode-connect' ),
285
			'border-right'    => __( 'Right', 'ayecode-connect' ),
286
			'border-top-0'    => __( '-Top', 'ayecode-connect' ),
287
			'border-bottom-0' => __( '-Bottom', 'ayecode-connect' ),
288
			'border-left-0'   => __( '-Left', 'ayecode-connect' ),
289
			'border-right-0'  => __( '-Right', 'ayecode-connect' ),
290
		);
291
		$defaults['element_require'] = '[%border%]';
292
293
	} else {
294
		$defaults['title']   = __( 'Border color', 'ayecode-connect' );
295
		$defaults['options'] = array(
296
			                       ''  => __( 'Default', 'ayecode-connect' ),
297
			                       '0' => __( 'None', 'ayecode-connect' ),
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', 'ayecode-connect' ),
317
		'shadow-sm' => __( 'Small', 'ayecode-connect' ),
318
		'shadow'    => __( 'Regular', 'ayecode-connect' ),
319
		'shadow-lg' => __( 'Large', 'ayecode-connect' ),
320
	);
321
322
	$defaults = array(
323
		'type'     => 'select',
324
		'title'    => __( 'Shadow', 'ayecode-connect' ),
325
		'options'  => $options,
326
		'default'  => '',
327
		'desc_tip' => true,
328
		'group'    => __( 'Wrapper Styles', 'ayecode-connect' ),
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', 'ayecode-connect' ),
347
		           'transparent' => __( 'Transparent', 'ayecode-connect' ),
348
	           ) + sd_aui_colors();
349
350
	$defaults = array(
351
		'type'     => 'select',
352
		'title'    => __( 'Background color', 'ayecode-connect' ),
353
		'options'  => $options,
354
		'default'  => '',
355
		'desc_tip' => true,
356
		'group'    => __( 'Wrapper Styles', 'ayecode-connect' ),
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', 'ayecode-connect' ),
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', 'ayecode-connect' ),
393
		'options'  => $options,
394
		'default'  => '',
395
		'desc_tip' => true,
396
		'group'    => __( 'Wrapper Styles', 'ayecode-connect' ),
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', 'ayecode-connect' ),
418
		           'transparent' => __( 'Transparent', 'ayecode-connect' ),
419
	           ) + $color_options;
420
421
	if ( false !== $overwrite_color ) {
422
		$options['custom-color'] = __( 'Custom Color', 'ayecode-connect' );
423
	}
424
425
	if ( false !== $overwrite_gradient ) {
426
		$options['custom-gradient'] = __( 'Custom Gradient', 'ayecode-connect' );
427
	}
428
429
	$defaults = array(
430
		'type'     => 'select',
431
		'title'    => __( 'Background Color', 'ayecode-connect' ),
432
		'options'  => $options,
433
		'default'  => '',
434
		'desc_tip' => true,
435
		'group'    => __( 'Background', 'ayecode-connect' ),
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', 'ayecode-connect' ),
448
				'placeholder'     => '',
449
				'default'         => '#0073aa',
450
				'desc_tip'        => true,
451
				'group'           => __( 'Background', 'ayecode-connect' ),
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', 'ayecode-connect' ),
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', 'ayecode-connect' ),
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', 'ayecode-connect' ),
477
			'default'         => '',
478
			'desc_tip'        => true,
479
			'group'           => ! empty( $overwrite_image['group'] ) ? $overwrite_image['group'] : __( 'Background', 'ayecode-connect' ),
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', 'ayecode-connect' ),
487
			'default'         => '',
488
			'desc_tip'        => true,
489
			'group'           => ! empty( $overwrite_image['group'] ) ? $overwrite_image['group'] : __( 'Background', 'ayecode-connect' ),
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', 'ayecode-connect' ),
499
				'placeholder' => '',
500
				'default'     => '',
501
				'desc_tip'    => true,
502
				'group'       => __( 'Background', 'ayecode-connect' ),
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', 'ayecode-connect' ),
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', 'ayecode-connect' ),
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', 'ayecode-connect' ),
546
		'mountains'             => __( 'Mountains', 'ayecode-connect' ),
547
		'drops'                 => __( 'Drops', 'ayecode-connect' ),
548
		'clouds'                => __( 'Clouds', 'ayecode-connect' ),
549
		'zigzag'                => __( 'Zigzag', 'ayecode-connect' ),
550
		'pyramids'              => __( 'Pyramids', 'ayecode-connect' ),
551
		'triangle'              => __( 'Triangle', 'ayecode-connect' ),
552
		'triangle-asymmetrical' => __( 'Triangle Asymmetrical', 'ayecode-connect' ),
553
		'tilt'                  => __( 'Tilt', 'ayecode-connect' ),
554
		'opacity-tilt'          => __( 'Opacity Tilt', 'ayecode-connect' ),
555
		'opacity-fan'           => __( 'Opacity Fan', 'ayecode-connect' ),
556
		'curve'                 => __( 'Curve', 'ayecode-connect' ),
557
		'curve-asymmetrical'    => __( 'Curve Asymmetrical', 'ayecode-connect' ),
558
		'waves'                 => __( 'Waves', 'ayecode-connect' ),
559
		'wave-brush'            => __( 'Wave Brush', 'ayecode-connect' ),
560
		'waves-pattern'         => __( 'Waves Pattern', 'ayecode-connect' ),
561
		'arrow'                 => __( 'Arrow', 'ayecode-connect' ),
562
		'split'                 => __( 'Split', 'ayecode-connect' ),
563
		'book'                  => __( 'Book', 'ayecode-connect' ),
564
	);
565
566
	$defaults = array(
567
		'type'     => 'select',
568
		'title'    => __( 'Type', 'ayecode-connect' ),
569
		'options'  => $options,
570
		'default'  => '',
571
		'desc_tip' => true,
572
		'group'    => __( 'Shape Divider', 'ayecode-connect' ),
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`', 'ayecode-connect' ),
580
		'status'          => 'warning',
581
		'group'           => __( 'Shape Divider', 'ayecode-connect' ),
582
		'element_require' => '[%' . $type . '%]!=""',
583
	);
584
585
	$input[ $type . '_position' ] = wp_parse_args(
586
		$overwrite_color,
587
		array(
588
			'type'            => 'select',
589
			'title'           => __( 'Position', 'ayecode-connect' ),
590
			'options'         => array(
591
				'top'    => __( 'Top', 'ayecode-connect' ),
592
				'bottom' => __( 'Bottom', 'ayecode-connect' ),
593
			),
594
			'desc_tip'        => true,
595
			'group'           => __( 'Shape Divider', 'ayecode-connect' ),
596
			'element_require' => '[%' . $type . '%]!=""',
597
		)
598
	);
599
600
	$options = array(
601
		           ''            => __( 'None', 'ayecode-connect' ),
602
		           'transparent' => __( 'Transparent', 'ayecode-connect' ),
603
	           ) + sd_aui_colors()
604
	           + array(
605
		           'custom-color' => __( 'Custom Color', 'ayecode-connect' ),
606
	           );
607
608
	$input[ $type . '_color' ] = wp_parse_args(
609
		$overwrite_color,
610
		array(
611
			'type'            => 'select',
612
			'title'           => __( 'Color', 'ayecode-connect' ),
613
			'options'         => $options,
614
			'desc_tip'        => true,
615
			'group'           => __( 'Shape Divider', 'ayecode-connect' ),
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', 'ayecode-connect' ),
625
			'placeholder'     => '',
626
			'default'         => '#0073aa',
627
			'desc_tip'        => true,
628
			'group'           => __( 'Shape Divider', 'ayecode-connect' ),
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', 'ayecode-connect' ),
638
			'placeholder'       => '',
639
			'default'           => '200',
640
			'desc_tip'          => true,
641
			'custom_attributes' => array(
642
				'min' => 100,
643
				'max' => 300,
644
			),
645
			'group'             => __( 'Shape Divider', 'ayecode-connect' ),
646
			'element_require'   => '[%' . $type . '%]!=""',
647
		)
648
	);
649
650
	$input[ $type . '_height' ] = array(
651
		'type'              => 'range',
652
		'title'             => __( 'Height', 'ayecode-connect' ),
653
		'default'           => '100',
654
		'desc_tip'          => true,
655
		'custom_attributes' => array(
656
			'min' => 0,
657
			'max' => 500,
658
		),
659
		'group'             => __( 'Shape Divider', 'ayecode-connect' ),
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', 'ayecode-connect' ),
687
		'default'         => '',
688
		'desc_tip'        => true,
689
		'group'           => __( 'Shape Divider', 'ayecode-connect' ),
690
		'element_require' => sd_get_element_require_string( $requires, 'flip', 'sd' ),
691
	);
692
693
	$input[ $type . '_invert' ] = array(
694
		'type'            => 'checkbox',
695
		'title'           => __( 'Invert', 'ayecode-connect' ),
696
		'default'         => '',
697
		'desc_tip'        => true,
698
		'group'           => __( 'Shape Divider', 'ayecode-connect' ),
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', 'ayecode-connect' ),
705
		'default'         => '',
706
		'desc_tip'        => true,
707
		'group'           => __( 'Shape Divider', 'ayecode-connect' ),
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', 'ayecode-connect' ),
754
	           ) + sd_aui_colors();
755
756
	if ( $has_custom ) {
757
		$options['custom'] = __( 'Custom color', 'ayecode-connect' );
758
	}
759
760
	$defaults = array(
761
		'type'     => 'select',
762
		'title'    => __( 'Text color', 'ayecode-connect' ),
763
		'options'  => $options,
764
		'default'  => '',
765
		'desc_tip' => true,
766
		'group'    => __( 'Typography', 'ayecode-connect' ),
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', 'ayecode-connect' ),
802
		'default'     => '',
803
		'placeholder' => '',
804
		'desc_tip'    => true,
805
		'group'       => __( 'Typography', 'ayecode-connect' ),
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', 'ayecode-connect' ),
837
		'auto' => __( 'auto', 'ayecode-connect' ),
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', 'ayecode-connect' ),
855
		'options'         => $options,
856
		'default'         => '',
857
		'desc_tip'        => true,
858
		'group'           => __( 'Container', 'ayecode-connect' ),
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', 'ayecode-connect' ),
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', 'ayecode-connect' ),
898
		'options'         => $options,
899
		'default'         => '',
900
		'desc_tip'        => true,
901
		'group'           => __( 'Container', 'ayecode-connect' ),
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', 'ayecode-connect' ),
930
		'text' . $device_size . '-left'   => __( 'Left', 'ayecode-connect' ),
931
		'text' . $device_size . '-right'  => __( 'Right', 'ayecode-connect' ),
932
		'text' . $device_size . '-center' => __( 'Center', 'ayecode-connect' ),
933
	);
934
935
	$defaults = array(
936
		'type'     => 'select',
937
		'title'    => __( 'Text align', 'ayecode-connect' ),
938
		'options'  => $options,
939
		'default'  => '',
940
		'desc_tip' => true,
941
		'group'    => __( 'Typography', 'ayecode-connect' ),
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', 'ayecode-connect' ),
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', 'ayecode-connect' ),
983
		'options'  => $options,
984
		'default'  => '',
985
		'desc_tip' => true,
986
		'group'    => __( 'Wrapper Styles', 'ayecode-connect' ),
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', 'ayecode-connect' ),
1007
		'default'  => '',
1008
		'desc_tip' => true,
1009
		'group'    => __( 'Typography', 'ayecode-connect' ),
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', 'ayecode-connect' );
1030
	$theme_colors['secondary'] = __( 'Secondary', 'ayecode-connect' );
1031
	$theme_colors['success']   = __( 'Success', 'ayecode-connect' );
1032
	$theme_colors['danger']    = __( 'Danger', 'ayecode-connect' );
1033
	$theme_colors['warning']   = __( 'Warning', 'ayecode-connect' );
1034
	$theme_colors['info']      = __( 'Info', 'ayecode-connect' );
1035
	$theme_colors['light']     = __( 'Light', 'ayecode-connect' );
1036
	$theme_colors['dark']      = __( 'Dark', 'ayecode-connect' );
1037
	$theme_colors['black']     = __( 'Black', 'ayecode-connect' );
1038
	$theme_colors['white']     = __( 'White', 'ayecode-connect' );
1039
	$theme_colors['purple']    = __( 'Purple', 'ayecode-connect' );
1040
	$theme_colors['salmon']    = __( 'Salmon', 'ayecode-connect' );
1041
	$theme_colors['cyan']      = __( 'Cyan', 'ayecode-connect' );
1042
	$theme_colors['gray']      = __( 'Gray', 'ayecode-connect' );
1043
	$theme_colors['muted']     = __( 'Muted', 'ayecode-connect' );
1044
	$theme_colors['gray-dark'] = __( 'Gray dark', 'ayecode-connect' );
1045
	$theme_colors['indigo']    = __( 'Indigo', 'ayecode-connect' );
1046
	$theme_colors['orange']    = __( 'Orange', 'ayecode-connect' );
1047
1048
	if ( $include_outlines ) {
1049
		$button_only                       = $outline_button_only_text ? ' ' . __( '(button only)', 'ayecode-connect' ) : '';
1050
		$theme_colors['outline-primary']   = __( 'Primary outline', 'ayecode-connect' ) . $button_only;
1051
		$theme_colors['outline-secondary'] = __( 'Secondary outline', 'ayecode-connect' ) . $button_only;
1052
		$theme_colors['outline-success']   = __( 'Success outline', 'ayecode-connect' ) . $button_only;
1053
		$theme_colors['outline-danger']    = __( 'Danger outline', 'ayecode-connect' ) . $button_only;
1054
		$theme_colors['outline-warning']   = __( 'Warning outline', 'ayecode-connect' ) . $button_only;
1055
		$theme_colors['outline-info']      = __( 'Info outline', 'ayecode-connect' ) . $button_only;
1056
		$theme_colors['outline-light']     = __( 'Light outline', 'ayecode-connect' ) . $button_only;
1057
		$theme_colors['outline-dark']      = __( 'Dark outline', 'ayecode-connect' ) . $button_only;
1058
		$theme_colors['outline-white']     = __( 'White outline', 'ayecode-connect' ) . $button_only;
1059
		$theme_colors['outline-purple']    = __( 'Purple outline', 'ayecode-connect' ) . $button_only;
1060
		$theme_colors['outline-salmon']    = __( 'Salmon outline', 'ayecode-connect' ) . $button_only;
1061
		$theme_colors['outline-cyan']      = __( 'Cyan outline', 'ayecode-connect' ) . $button_only;
1062
		$theme_colors['outline-gray']      = __( 'Gray outline', 'ayecode-connect' ) . $button_only;
1063
		$theme_colors['outline-gray-dark'] = __( 'Gray dark outline', 'ayecode-connect' ) . $button_only;
1064
		$theme_colors['outline-indigo']    = __( 'Indigo outline', 'ayecode-connect' ) . $button_only;
1065
		$theme_colors['outline-orange']    = __( 'Orange outline', 'ayecode-connect' ) . $button_only;
1066
	}
1067
1068
	if ( $include_branding ) {
1069
		$theme_colors = $theme_colors + sd_aui_branding_colors();
1070
	}
1071
1072
	if ( $include_translucent ) {
1073
		$button_only                           = $outline_button_only_text ? ' ' . __( '(button only)', 'ayecode-connect' ) : '';
1074
		$theme_colors['translucent-primary']   = __( 'Primary translucent', 'ayecode-connect' ) . $button_only;
1075
		$theme_colors['translucent-secondary'] = __( 'Secondary translucent', 'ayecode-connect' ) . $button_only;
1076
		$theme_colors['translucent-success']   = __( 'Success translucent', 'ayecode-connect' ) . $button_only;
1077
		$theme_colors['translucent-danger']    = __( 'Danger translucent', 'ayecode-connect' ) . $button_only;
1078
		$theme_colors['translucent-warning']   = __( 'Warning translucent', 'ayecode-connect' ) . $button_only;
1079
		$theme_colors['translucent-info']      = __( 'Info translucent', 'ayecode-connect' ) . $button_only;
1080
		$theme_colors['translucent-light']     = __( 'Light translucent', 'ayecode-connect' ) . $button_only;
1081
		$theme_colors['translucent-dark']      = __( 'Dark translucent', 'ayecode-connect' ) . $button_only;
1082
		$theme_colors['translucent-white']     = __( 'White translucent', 'ayecode-connect' ) . $button_only;
1083
		$theme_colors['translucent-purple']    = __( 'Purple translucent', 'ayecode-connect' ) . $button_only;
1084
		$theme_colors['translucent-salmon']    = __( 'Salmon translucent', 'ayecode-connect' ) . $button_only;
1085
		$theme_colors['translucent-cyan']      = __( 'Cyan translucent', 'ayecode-connect' ) . $button_only;
1086
		$theme_colors['translucent-gray']      = __( 'Gray translucent', 'ayecode-connect' ) . $button_only;
1087
		$theme_colors['translucent-gray-dark'] = __( 'Gray dark translucent', 'ayecode-connect' ) . $button_only;
1088
		$theme_colors['translucent-indigo']    = __( 'Indigo translucent', 'ayecode-connect' ) . $button_only;
1089
		$theme_colors['translucent-orange']    = __( 'Orange translucent', 'ayecode-connect' ) . $button_only;
1090
	}
1091
1092
	return apply_filters( 'sd_aui_colors', $theme_colors, $include_outlines, $include_branding );
1093
}
1094
1095
/**
1096
 * Get the AUI branding colors.
1097
 *
1098
 * @return array
1099
 */
1100
function sd_aui_branding_colors() {
1101
	return array(
1102
		'facebook'  => __( 'Facebook', 'ayecode-connect' ),
1103
		'twitter'   => __( 'Twitter', 'ayecode-connect' ),
1104
		'instagram' => __( 'Instagram', 'ayecode-connect' ),
1105
		'linkedin'  => __( 'Linkedin', 'ayecode-connect' ),
1106
		'flickr'    => __( 'Flickr', 'ayecode-connect' ),
1107
		'github'    => __( 'GitHub', 'ayecode-connect' ),
1108
		'youtube'   => __( 'YouTube', 'ayecode-connect' ),
1109
		'wordpress' => __( 'WordPress', 'ayecode-connect' ),
1110
		'google'    => __( 'Google', 'ayecode-connect' ),
1111
		'yahoo'     => __( 'Yahoo', 'ayecode-connect' ),
1112
		'vkontakte' => __( 'Vkontakte', 'ayecode-connect' ),
1113
	);
1114
}
1115
1116
1117
/**
1118
 * A helper function for container class.
1119
 *
1120
 * @param string $type
1121
 * @param array $overwrite
1122
 *
1123
 * @return array
1124
 */
1125
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

1125
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...
1126
1127
	$options = array(
1128
		'container'       => __( 'container (default)', 'ayecode-connect' ),
1129
		'container-sm'    => 'container-sm',
1130
		'container-md'    => 'container-md',
1131
		'container-lg'    => 'container-lg',
1132
		'container-xl'    => 'container-xl',
1133
		'container-xxl'   => 'container-xxl',
1134
		'container-fluid' => 'container-fluid',
1135
		'row'             => 'row',
1136
		'col'             => 'col',
1137
		'card'            => 'card',
1138
		'card-header'     => 'card-header',
1139
		'card-img-top'    => 'card-img-top',
1140
		'card-body'       => 'card-body',
1141
		'card-footer'     => 'card-footer',
1142
		'list-group'      => 'list-group',
1143
		'list-group-item' => 'list-group-item',
1144
		''                => __( 'no container class', 'ayecode-connect' ),
1145
	);
1146
1147
	$defaults = array(
1148
		'type'     => 'select',
1149
		'title'    => __( 'Type', 'ayecode-connect' ),
1150
		'options'  => $options,
1151
		'default'  => '',
1152
		'desc_tip' => true,
1153
		'group'    => __( 'Container', 'ayecode-connect' ),
1154
	);
1155
1156
	$input = wp_parse_args( $overwrite, $defaults );
1157
1158
	return $input;
1159
}
1160
1161
/**
1162
 * A helper function for position class.
1163
 *
1164
 * @param string $type
1165
 * @param array $overwrite
1166
 *
1167
 * @return array
1168
 */
1169
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

1169
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...
1170
1171
	$options = array(
1172
		''                  => __( 'Default', 'ayecode-connect' ),
1173
		'position-static'   => 'static',
1174
		'position-relative' => 'relative',
1175
		'position-absolute' => 'absolute',
1176
		'position-fixed'    => 'fixed',
1177
		'position-sticky'   => 'sticky',
1178
		'fixed-top'         => 'fixed-top',
1179
		'fixed-bottom'      => 'fixed-bottom',
1180
		'sticky-top'        => 'sticky-top',
1181
	);
1182
1183
	$defaults = array(
1184
		'type'     => 'select',
1185
		'title'    => __( 'Position', 'ayecode-connect' ),
1186
		'options'  => $options,
1187
		'default'  => '',
1188
		'desc_tip' => true,
1189
		'group'    => __( 'Wrapper Styles', 'ayecode-connect' ),
1190
	);
1191
1192
	$input = wp_parse_args( $overwrite, $defaults );
1193
1194
	return $input;
1195
}
1196
1197
/**
1198
 * @param $type
1199
 * @param $overwrite
1200
 *
1201
 * @return array
1202
 */
1203
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

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

1285
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...
1286
	global $aui_bs5;
1287
1288
	$options[] = __( 'Inherit from parent', 'ayecode-connect' );
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...
1289
	if ( $aui_bs5 ) {
1290
		// responsive font sizes
1291
		$options['fs-base'] = 'fs-base (body default)';
1292
		$options['fs-6']    = 'fs-6';
1293
		$options['fs-5']    = 'fs-5';
1294
		$options['fs-4']    = 'fs-4';
1295
		$options['fs-3']    = 'fs-3';
1296
		$options['fs-2']    = 'fs-2';
1297
		$options['fs-1']    = 'fs-1';
1298
1299
		// custom
1300
		$options['fs-lg']  = 'fs-lg';
1301
		$options['fs-sm']  = 'fs-sm';
1302
		$options['fs-xs']  = 'fs-xs';
1303
		$options['fs-xxs'] = 'fs-xxs';
1304
1305
	}
1306
1307
	$options = $options + array(
1308
			'h6'        => 'h6',
1309
			'h5'        => 'h5',
1310
			'h4'        => 'h4',
1311
			'h3'        => 'h3',
1312
			'h2'        => 'h2',
1313
			'h1'        => 'h1',
1314
			'display-1' => 'display-1',
1315
			'display-2' => 'display-2',
1316
			'display-3' => 'display-3',
1317
			'display-4' => 'display-4',
1318
		);
1319
1320
	if ( $aui_bs5 ) {
1321
		$options['display-5'] = 'display-5';
1322
		$options['display-6'] = 'display-6';
1323
	}
1324
1325
	if ( $has_custom ) {
1326
		$options['custom'] = __( 'Custom size', 'ayecode-connect' );
1327
	}
1328
1329
	$defaults = array(
1330
		'type'     => 'select',
1331
		'title'    => __( 'Font size', 'ayecode-connect' ),
1332
		'options'  => $options,
1333
		'default'  => '',
1334
		'desc_tip' => true,
1335
		'group'    => __( 'Typography', 'ayecode-connect' ),
1336
	);
1337
1338
	$input = wp_parse_args( $overwrite, $defaults );
1339
1340
	return $input;
1341
}
1342
1343
/**
1344
 * A helper function for custom font size.
1345
 *
1346
 * @param string $type
1347
 * @param array $overwrite
1348
 *
1349
 * @return array
1350
 */
1351
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

1351
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...
1352
1353
	$defaults = array(
1354
		'type'              => 'number',
1355
		'title'             => __( 'Font size (rem)', 'ayecode-connect' ),
1356
		'default'           => '',
1357
		'placeholder'       => '1.25',
1358
		'custom_attributes' => array(
1359
			'step' => '0.1',
1360
			'min'  => '0',
1361
			'max'  => '100',
1362
		),
1363
		'desc_tip'          => true,
1364
		'group'             => __( 'Typography', 'ayecode-connect' ),
1365
	);
1366
1367
	if ( $parent_type ) {
1368
		$defaults['element_require'] = '[%' . $parent_type . '%]=="custom"';
1369
	}
1370
1371
	$input = wp_parse_args( $overwrite, $defaults );
1372
1373
	return $input;
1374
}
1375
1376
/**
1377
 * A helper function for custom font size.
1378
 *
1379
 * @param string $type
1380
 * @param array $overwrite
1381
 *
1382
 * @return array
1383
 */
1384
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

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

1437
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...
1438
1439
	$options = array(
1440
		''                                => __( 'Inherit', 'ayecode-connect' ),
1441
		'font-weight-bold'                => 'bold',
1442
		'font-weight-bolder'              => 'bolder',
1443
		'font-weight-normal'              => 'normal',
1444
		'font-weight-light'               => 'light',
1445
		'font-weight-lighter'             => 'lighter',
1446
		'font-italic'                     => 'italic',
1447
		'font-weight-bold font-italic'    => 'bold italic',
1448
		'font-weight-bolder font-italic'  => 'bolder italic',
1449
		'font-weight-normal font-italic'  => 'normal italic',
1450
		'font-weight-light font-italic'   => 'light italic',
1451
		'font-weight-lighter font-italic' => 'lighter italic',
1452
	);
1453
1454
	$defaults = array(
1455
		'type'     => 'select',
1456
		'title'    => __( 'Appearance', 'ayecode-connect' ),
1457
		'options'  => $options,
1458
		'default'  => '',
1459
		'desc_tip' => true,
1460
		'group'    => __( 'Typography', 'ayecode-connect' ),
1461
	);
1462
1463
	$input = wp_parse_args( $overwrite, $defaults );
1464
1465
	return $input;
1466
}
1467
1468
/**
1469
 * A helper function for font case class.
1470
 *
1471
 * @param $type
1472
 * @param $overwrite
1473
 *
1474
 * @return array
1475
 */
1476
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

1476
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...
1477
1478
	$options = array(
1479
		''                => __( 'Default', 'ayecode-connect' ),
1480
		'text-lowercase'  => __( 'lowercase', 'ayecode-connect' ),
1481
		'text-uppercase'  => __( 'UPPERCASE', 'ayecode-connect' ),
1482
		'text-capitalize' => __( 'Capitalize', 'ayecode-connect' ),
1483
	);
1484
1485
	$defaults = array(
1486
		'type'     => 'select',
1487
		'title'    => __( 'Letter case', 'ayecode-connect' ),
1488
		'options'  => $options,
1489
		'default'  => '',
1490
		'desc_tip' => true,
1491
		'group'    => __( 'Typography', 'ayecode-connect' ),
1492
	);
1493
1494
	$input = wp_parse_args( $overwrite, $defaults );
1495
1496
	return $input;
1497
}
1498
1499
/**
1500
 * @param string $type
1501
 * @param array $overwrite
1502
 *
1503
 * @return array
1504
 * @todo remove this as now included above.
1505
 * A helper function for font size
1506
 *
1507
 */
1508
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

1508
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...
1509
1510
	$options = array(
1511
		''            => __( 'No', 'ayecode-connect' ),
1512
		'font-italic' => __( 'Yes', 'ayecode-connect' ),
1513
	);
1514
1515
	$defaults = array(
1516
		'type'     => 'select',
1517
		'title'    => __( 'Font italic', 'ayecode-connect' ),
1518
		'options'  => $options,
1519
		'default'  => '',
1520
		'desc_tip' => true,
1521
		'group'    => __( 'Typography', 'ayecode-connect' ),
1522
	);
1523
1524
	$input = wp_parse_args( $overwrite, $defaults );
1525
1526
	return $input;
1527
}
1528
1529
/**
1530
 * A helper function for the anchor input.
1531
 *
1532
 * @param $type
1533
 * @param $overwrite
1534
 *
1535
 * @return array
1536
 */
1537
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

1537
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...
1538
1539
	$defaults = array(
1540
		'type'     => 'text',
1541
		'title'    => __( 'HTML anchor', 'ayecode-connect' ),
1542
		'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.', 'ayecode-connect' ),
1543
		'default'  => '',
1544
		'desc_tip' => true,
1545
		'group'    => __( 'Advanced', 'ayecode-connect' ),
1546
	);
1547
1548
	$input = wp_parse_args( $overwrite, $defaults );
1549
1550
	return $input;
1551
}
1552
1553
/**
1554
 * A helper function for the class input.
1555
 *
1556
 * @param $type
1557
 * @param $overwrite
1558
 *
1559
 * @return array
1560
 */
1561
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

1561
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...
1562
1563
	$defaults = array(
1564
		'type'     => 'text',
1565
		'title'    => __( 'Additional CSS class(es)', 'ayecode-connect' ),
1566
		'desc'     => __( 'Separate multiple classes with spaces.', 'ayecode-connect' ),
1567
		'default'  => '',
1568
		'desc_tip' => true,
1569
		'group'    => __( 'Advanced', 'ayecode-connect' ),
1570
	);
1571
1572
	$input = wp_parse_args( $overwrite, $defaults );
1573
1574
	return $input;
1575
}
1576
1577
/**
1578
 * A helper function for font size inputs.
1579
 *
1580
 * @param string $type
1581
 * @param array $overwrite
1582
 *
1583
 * @return array
1584
 */
1585
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

1585
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...
1586
1587
	$options = array(
1588
		''                 => __( 'none', 'ayecode-connect' ),
1589
		'hover-zoom'       => __( 'Zoom', 'ayecode-connect' ),
1590
		'hover-shadow'     => __( 'Shadow', 'ayecode-connect' ),
1591
		'hover-move-up'    => __( 'Move up', 'ayecode-connect' ),
1592
		'hover-move-down'  => __( 'Move down', 'ayecode-connect' ),
1593
		'hover-move-left'  => __( 'Move left', 'ayecode-connect' ),
1594
		'hover-move-right' => __( 'Move right', 'ayecode-connect' ),
1595
	);
1596
1597
	$defaults = array(
1598
		'type'     => 'select',
1599
		'multiple' => true,
1600
		'title'    => __( 'Hover Animations', 'ayecode-connect' ),
1601
		'options'  => $options,
1602
		'default'  => '',
1603
		'desc_tip' => true,
1604
		'group'    => __( 'Hover Animations', 'ayecode-connect' ),
1605
	);
1606
1607
	$input = wp_parse_args( $overwrite, $defaults );
1608
1609
	return $input;
1610
}
1611
1612
1613
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

1613
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...
1614
	$device_size = '';
1615
	if ( ! empty( $overwrite['device_type'] ) ) {
1616
		if ( $overwrite['device_type'] == 'Tablet' ) {
1617
			$device_size = '-md';
1618
		} elseif ( $overwrite['device_type'] == 'Desktop' ) {
1619
			$device_size = '-lg';
1620
		}
1621
	}
1622
	$options = array(
1623
		''                                         => __( 'Default', 'ayecode-connect' ),
1624
		'align-items' . $device_size . '-start'    => 'align-items-start',
1625
		'align-items' . $device_size . '-end'      => 'align-items-end',
1626
		'align-items' . $device_size . '-center'   => 'align-items-center',
1627
		'align-items' . $device_size . '-baseline' => 'align-items-baseline',
1628
		'align-items' . $device_size . '-stretch'  => 'align-items-stretch',
1629
	);
1630
1631
	$defaults = array(
1632
		'type'            => 'select',
1633
		'title'           => __( 'Vertical Align Items', 'ayecode-connect' ),
1634
		'options'         => $options,
1635
		'default'         => '',
1636
		'desc_tip'        => true,
1637
		'group'           => __( 'Wrapper Styles', 'ayecode-connect' ),
1638
		'element_require' => ' ( ( [%container%]=="row" ) || ( [%display%]=="d-flex" || [%display_md%]=="d-md-flex" || [%display_lg%]=="d-lg-flex" ) ) ',
1639
1640
	);
1641
1642
	$input = wp_parse_args( $overwrite, $defaults );
1643
1644
	return $input;
1645
}
1646
1647
function sd_get_flex_align_items_input_group( $type = 'flex_align_items', $overwrite = array() ) {
1648
	$inputs = array();
1649
	$sizes  = array(
1650
		''    => 'Mobile',
1651
		'_md' => 'Tablet',
1652
		'_lg' => 'Desktop',
1653
	);
1654
1655
	if ( $overwrite !== false ) {
1656
1657
		foreach ( $sizes as $ds => $dt ) {
1658
			$overwrite['device_type'] = $dt;
1659
			$inputs[ $type . $ds ]    = sd_get_flex_align_items_input( $type, $overwrite );
1660
		}
1661
	}
1662
1663
	return $inputs;
1664
}
1665
1666
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

1666
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...
1667
	$device_size = '';
1668
	if ( ! empty( $overwrite['device_type'] ) ) {
1669
		if ( $overwrite['device_type'] == 'Tablet' ) {
1670
			$device_size = '-md';
1671
		} elseif ( $overwrite['device_type'] == 'Desktop' ) {
1672
			$device_size = '-lg';
1673
		}
1674
	}
1675
	$options = array(
1676
		''                                            => __( 'Default', 'ayecode-connect' ),
1677
		'justify-content' . $device_size . '-start'   => 'justify-content-start',
1678
		'justify-content' . $device_size . '-end'     => 'justify-content-end',
1679
		'justify-content' . $device_size . '-center'  => 'justify-content-center',
1680
		'justify-content' . $device_size . '-between' => 'justify-content-between',
1681
		'justify-content' . $device_size . '-stretch' => 'justify-content-around',
1682
	);
1683
1684
	$defaults = array(
1685
		'type'            => 'select',
1686
		'title'           => __( 'Justify content', 'ayecode-connect' ),
1687
		'options'         => $options,
1688
		'default'         => '',
1689
		'desc_tip'        => true,
1690
		'group'           => __( 'Wrapper Styles', 'ayecode-connect' ),
1691
		'element_require' => '( ( [%container%]=="row" ) || ( [%display%]=="d-flex" || [%display_md%]=="d-md-flex" || [%display_lg%]=="d-lg-flex" ) ) ',
1692
1693
	);
1694
1695
	$input = wp_parse_args( $overwrite, $defaults );
1696
1697
	return $input;
1698
}
1699
1700
function sd_get_flex_justify_content_input_group( $type = 'flex_justify_content', $overwrite = array() ) {
1701
	$inputs = array();
1702
	$sizes  = array(
1703
		''    => 'Mobile',
1704
		'_md' => 'Tablet',
1705
		'_lg' => 'Desktop',
1706
	);
1707
1708
	if ( $overwrite !== false ) {
1709
1710
		foreach ( $sizes as $ds => $dt ) {
1711
			$overwrite['device_type'] = $dt;
1712
			$inputs[ $type . $ds ]    = sd_get_flex_justify_content_input( $type, $overwrite );
1713
		}
1714
	}
1715
1716
	return $inputs;
1717
}
1718
1719
1720
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

1720
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...
1721
	$device_size = '';
1722
	if ( ! empty( $overwrite['device_type'] ) ) {
1723
		if ( $overwrite['device_type'] == 'Tablet' ) {
1724
			$device_size = '-md';
1725
		} elseif ( $overwrite['device_type'] == 'Desktop' ) {
1726
			$device_size = '-lg';
1727
		}
1728
	}
1729
	$options = array(
1730
		''                                         => __( 'Default', 'ayecode-connect' ),
1731
		'align-items' . $device_size . '-start'    => 'align-items-start',
1732
		'align-items' . $device_size . '-end'      => 'align-items-end',
1733
		'align-items' . $device_size . '-center'   => 'align-items-center',
1734
		'align-items' . $device_size . '-baseline' => 'align-items-baseline',
1735
		'align-items' . $device_size . '-stretch'  => 'align-items-stretch',
1736
	);
1737
1738
	$defaults = array(
1739
		'type'            => 'select',
1740
		'title'           => __( 'Align Self', 'ayecode-connect' ),
1741
		'options'         => $options,
1742
		'default'         => '',
1743
		'desc_tip'        => true,
1744
		'group'           => __( 'Wrapper Styles', 'ayecode-connect' ),
1745
		'element_require' => ' [%container%]=="col" ',
1746
1747
	);
1748
1749
	$input = wp_parse_args( $overwrite, $defaults );
1750
1751
	return $input;
1752
}
1753
1754
function sd_get_flex_align_self_input_group( $type = 'flex_align_self', $overwrite = array() ) {
1755
	$inputs = array();
1756
	$sizes  = array(
1757
		''    => 'Mobile',
1758
		'_md' => 'Tablet',
1759
		'_lg' => 'Desktop',
1760
	);
1761
1762
	if ( $overwrite !== false ) {
1763
1764
		foreach ( $sizes as $ds => $dt ) {
1765
			$overwrite['device_type'] = $dt;
1766
			$inputs[ $type . $ds ]    = sd_get_flex_align_self_input( $type, $overwrite );
1767
		}
1768
	}
1769
1770
	return $inputs;
1771
}
1772
1773
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

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

1846
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...
1847
	$device_size = '';
1848
	if ( ! empty( $overwrite['device_type'] ) ) {
1849
		if ( $overwrite['device_type'] == 'Tablet' ) {
1850
			$device_size = '-md';
1851
		} elseif ( $overwrite['device_type'] == 'Desktop' ) {
1852
			$device_size = '-lg';
1853
		}
1854
	}
1855
	$options = array(
1856
		''                                      => __( 'Default', 'ayecode-connect' ),
1857
		'flex' . $device_size . '-nowrap'       => 'nowrap',
1858
		'flex' . $device_size . '-wrap'         => 'wrap',
1859
		'flex' . $device_size . '-wrap-reverse' => 'wrap-reverse',
1860
	);
1861
1862
	$defaults = array(
1863
		'type'     => 'select',
1864
		'title'    => __( 'Flex wrap', 'ayecode-connect' ),
1865
		'options'  => $options,
1866
		'default'  => '',
1867
		'desc_tip' => true,
1868
		'group'    => __( 'Wrapper Styles', 'ayecode-connect' ),
1869
	);
1870
1871
	$input = wp_parse_args( $overwrite, $defaults );
1872
1873
	return $input;
1874
}
1875
1876
function sd_get_float_group( $type = 'float', $overwrite = array() ) {
1877
	$inputs = array();
1878
	$sizes  = array(
1879
		''    => 'Mobile',
1880
		'_md' => 'Tablet',
1881
		'_lg' => 'Desktop',
1882
	);
1883
1884
	if ( $overwrite !== false ) {
1885
1886
		foreach ( $sizes as $ds => $dt ) {
1887
			$overwrite['device_type'] = $dt;
1888
			$inputs[ $type . $ds ]    = sd_get_float_input( $type, $overwrite );
1889
		}
1890
	}
1891
1892
	return $inputs;
1893
}
1894
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

1894
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...
1895
	$device_size = '';
1896
	if ( ! empty( $overwrite['device_type'] ) ) {
1897
		if ( $overwrite['device_type'] == 'Tablet' ) {
1898
			$device_size = '-md';
1899
		} elseif ( $overwrite['device_type'] == 'Desktop' ) {
1900
			$device_size = '-lg';
1901
		}
1902
	}
1903
	$options = array(
1904
		''                                      => __( 'Default', 'ayecode-connect' ),
1905
		'float' . $device_size . '-start'       => 'left',
1906
		'float' . $device_size . '-end'         => 'right',
1907
		'float' . $device_size . '-none' => 'none',
1908
	);
1909
1910
	$defaults = array(
1911
		'type'     => 'select',
1912
		'title'    => __( 'Float', 'ayecode-connect' ),
1913
		'options'  => $options,
1914
		'default'  => '',
1915
		'desc_tip' => true,
1916
		'group'    => __( 'Wrapper Styles', 'ayecode-connect' ),
1917
	);
1918
1919
	$input = wp_parse_args( $overwrite, $defaults );
1920
1921
	return $input;
1922
}
1923
1924
/**
1925
 * @param $type
1926
 * @param $overwrite
1927
 *
1928
 * @return array
1929
 */
1930
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

1930
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...
1931
1932
	$options = array(
1933
		''          => __( 'Default', 'ayecode-connect' ),
1934
		'zindex-0'  => '0',
1935
		'zindex-1'  => '1',
1936
		'zindex-5'  => '5',
1937
		'zindex-10' => '10',
1938
	);
1939
1940
	$defaults = array(
1941
		'type'     => 'select',
1942
		'title'    => __( 'Z-index', 'ayecode-connect' ),
1943
		'options'  => $options,
1944
		'default'  => '',
1945
		'desc_tip' => true,
1946
		'group'    => __( 'Wrapper Styles', 'ayecode-connect' ),
1947
	);
1948
1949
	$input = wp_parse_args( $overwrite, $defaults );
1950
1951
	return $input;
1952
}
1953
1954
/**
1955
 * @param $type
1956
 * @param $overwrite
1957
 *
1958
 * @return array
1959
 */
1960
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

1960
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...
1961
1962
	$options = array(
1963
		''                 => __( 'Default', 'ayecode-connect' ),
1964
		'overflow-auto'    => __( 'Auto', 'ayecode-connect' ),
1965
		'overflow-hidden'  => __( 'Hidden', 'ayecode-connect' ),
1966
		'overflow-visible' => __( 'Visible', 'ayecode-connect' ),
1967
		'overflow-scroll'  => __( 'Scroll', 'ayecode-connect' ),
1968
	);
1969
1970
	$defaults = array(
1971
		'type'     => 'select',
1972
		'title'    => __( 'Overflow', 'ayecode-connect' ),
1973
		'options'  => $options,
1974
		'default'  => '',
1975
		'desc_tip' => true,
1976
		'group'    => __( 'Wrapper Styles', 'ayecode-connect' ),
1977
	);
1978
1979
	$input = wp_parse_args( $overwrite, $defaults );
1980
1981
	return $input;
1982
}
1983
1984
/**
1985
 * @param $type
1986
 * @param $overwrite
1987
 *
1988
 * @return array
1989
 */
1990
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

1990
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...
1991
1992
	$defaults = array(
1993
		'type'        => 'text',
1994
		'title'       => __( 'Max height', 'ayecode-connect' ),
1995
		'value'       => '',
1996
		'default'     => '',
1997
		'placeholder' => '',
1998
		'desc_tip'    => true,
1999
		'group'       => __( 'Wrapper Styles', 'ayecode-connect' ),
2000
	);
2001
2002
	$input = wp_parse_args( $overwrite, $defaults );
2003
2004
	return $input;
2005
}
2006
2007
/**
2008
 * @param $type
2009
 * @param $overwrite
2010
 *
2011
 * @return array
2012
 */
2013
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

2013
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...
2014
2015
	$options = array(
2016
		''               => __( 'Default', 'ayecode-connect' ),
2017
		'scrollbars-ios' => __( 'IOS Style', 'ayecode-connect' ),
2018
	);
2019
2020
	$defaults = array(
2021
		'type'     => 'select',
2022
		'title'    => __( 'Scrollbars', 'ayecode-connect' ),
2023
		'options'  => $options,
2024
		'default'  => '',
2025
		'desc_tip' => true,
2026
		'group'    => __( 'Wrapper Styles', 'ayecode-connect' ),
2027
	);
2028
2029
	$input = wp_parse_args( $overwrite, $defaults );
2030
2031
	return $input;
2032
}
2033
2034
/**
2035
 * Build AUI classes from settings.
2036
 *
2037
 * @param $args
2038
 *
2039
 * @return string
2040
 * @todo find best way to use px- py- or general p-
2041
 */
2042
function sd_build_aui_class( $args ) {
2043
	global $aui_bs5;
2044
2045
	$classes = array();
2046
2047
	if ( $aui_bs5 ) {
2048
		$p_ml = 'ms-';
2049
		$p_mr = 'me-';
2050
2051
		$p_pl = 'ps-';
2052
		$p_pr = 'pe-';
2053
	} else {
2054
		$p_ml = 'ml-';
2055
		$p_mr = 'mr-';
2056
2057
		$p_pl = 'pl-';
2058
		$p_pr = 'pr-';
2059
	}
2060
2061
	// margins.
2062
	if ( isset( $args['mt'] ) && $args['mt'] !== '' ) {
2063
		$classes[] = 'mt-' . sanitize_html_class( $args['mt'] );
2064
		$mt        = $args['mt'];
2065
	} else {
2066
		$mt = null;
2067
	}
2068
	if ( isset( $args['mr'] ) && $args['mr'] !== '' ) {
2069
		$classes[] = $p_mr . sanitize_html_class( $args['mr'] );
2070
		$mr        = $args['mr'];
2071
	} else {
2072
		$mr = null;
2073
	}
2074
	if ( isset( $args['mb'] ) && $args['mb'] !== '' ) {
2075
		$classes[] = 'mb-' . sanitize_html_class( $args['mb'] );
2076
		$mb        = $args['mb'];
2077
	} else {
2078
		$mb = null;
2079
	}
2080
	if ( isset( $args['ml'] ) && $args['ml'] !== '' ) {
2081
		$classes[] = $p_ml . sanitize_html_class( $args['ml'] );
2082
		$ml        = $args['ml'];
2083
	} else {
2084
		$ml = null;
2085
	}
2086
2087
	// margins tablet.
2088
	if ( isset( $args['mt_md'] ) && $args['mt_md'] !== '' ) {
2089
		$classes[] = 'mt-md-' . sanitize_html_class( $args['mt_md'] );
2090
		$mt_md     = $args['mt_md'];
2091
	} else {
2092
		$mt_md = null;
2093
	}
2094
	if ( isset( $args['mr_md'] ) && $args['mr_md'] !== '' ) {
2095
		$classes[] = $p_mr . 'md-' . sanitize_html_class( $args['mr_md'] );
2096
		$mt_md     = $args['mr_md'];
2097
	} else {
2098
		$mr_md = null;
2099
	}
2100
	if ( isset( $args['mb_md'] ) && $args['mb_md'] !== '' ) {
2101
		$classes[] = 'mb-md-' . sanitize_html_class( $args['mb_md'] );
2102
		$mt_md     = $args['mb_md'];
2103
	} else {
2104
		$mb_md = null;
2105
	}
2106
	if ( isset( $args['ml_md'] ) && $args['ml_md'] !== '' ) {
2107
		$classes[] = $p_ml . 'md-' . sanitize_html_class( $args['ml_md'] );
2108
		$mt_md     = $args['ml_md'];
2109
	} else {
2110
		$ml_md = null;
2111
	}
2112
2113
	// margins desktop.
2114
	if ( isset( $args['mt_lg'] ) && $args['mt_lg'] !== '' ) {
2115
		if ( $mt == null && $mt_md == null ) {
2116
			$classes[] = 'mt-' . sanitize_html_class( $args['mt_lg'] );
2117
		} else {
2118
			$classes[] = 'mt-lg-' . sanitize_html_class( $args['mt_lg'] );
2119
		}
2120
	}
2121
	if ( isset( $args['mr_lg'] ) && $args['mr_lg'] !== '' ) {
2122
		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...
2123
			$classes[] = $p_mr . sanitize_html_class( $args['mr_lg'] );
2124
		} else {
2125
			$classes[] = $p_mr . 'lg-' . sanitize_html_class( $args['mr_lg'] );
2126
		}
2127
	}
2128
	if ( isset( $args['mb_lg'] ) && $args['mb_lg'] !== '' ) {
2129
		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...
2130
			$classes[] = 'mb-' . sanitize_html_class( $args['mb_lg'] );
2131
		} else {
2132
			$classes[] = 'mb-lg-' . sanitize_html_class( $args['mb_lg'] );
2133
		}
2134
	}
2135
	if ( isset( $args['ml_lg'] ) && $args['ml_lg'] !== '' ) {
2136
		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...
2137
			$classes[] = $p_ml . sanitize_html_class( $args['ml_lg'] );
2138
		} else {
2139
			$classes[] = $p_ml . 'lg-' . sanitize_html_class( $args['ml_lg'] );
2140
		}
2141
	}
2142
2143
	// padding.
2144
	if ( isset( $args['pt'] ) && $args['pt'] !== '' ) {
2145
		$classes[] = 'pt-' . sanitize_html_class( $args['pt'] );
2146
		$pt        = $args['pt'];
2147
	} else {
2148
		$pt = null;
2149
	}
2150
	if ( isset( $args['pr'] ) && $args['pr'] !== '' ) {
2151
		$classes[] = $p_pr . sanitize_html_class( $args['pr'] );
2152
		$pr        = $args['pr'];
2153
	} else {
2154
		$pr = null;
2155
	}
2156
	if ( isset( $args['pb'] ) && $args['pb'] !== '' ) {
2157
		$classes[] = 'pb-' . sanitize_html_class( $args['pb'] );
2158
		$pb        = $args['pb'];
2159
	} else {
2160
		$pb = null;
2161
	}
2162
	if ( isset( $args['pl'] ) && $args['pl'] !== '' ) {
2163
		$classes[] = $p_pl . sanitize_html_class( $args['pl'] );
2164
		$pl        = $args['pl'];
2165
	} else {
2166
		$pl = null;
2167
	}
2168
2169
	// padding tablet.
2170
	if ( isset( $args['pt_md'] ) && $args['pt_md'] !== '' ) {
2171
		$classes[] = 'pt-md-' . sanitize_html_class( $args['pt_md'] );
2172
		$pt_md     = $args['pt_md'];
2173
	} else {
2174
		$pt_md = null;
2175
	}
2176
	if ( isset( $args['pr_md'] ) && $args['pr_md'] !== '' ) {
2177
		$classes[] = $p_pr . 'md-' . sanitize_html_class( $args['pr_md'] );
2178
		$pr_md     = $args['pr_md'];
2179
	} else {
2180
		$pr_md = null;
2181
	}
2182
	if ( isset( $args['pb_md'] ) && $args['pb_md'] !== '' ) {
2183
		$classes[] = 'pb-md-' . sanitize_html_class( $args['pb_md'] );
2184
		$pb_md     = $args['pb_md'];
2185
	} else {
2186
		$pb_md = null;
2187
	}
2188
	if ( isset( $args['pl_md'] ) && $args['pl_md'] !== '' ) {
2189
		$classes[] = $p_pl . 'md-' . sanitize_html_class( $args['pl_md'] );
2190
		$pl_md     = $args['pl_md'];
2191
	} else {
2192
		$pl_md = null;
2193
	}
2194
2195
	// padding desktop.
2196
	if ( isset( $args['pt_lg'] ) && $args['pt_lg'] !== '' ) {
2197
		if ( $pt == null && $pt_md == null ) {
2198
			$classes[] = 'pt-' . sanitize_html_class( $args['pt_lg'] );
2199
		} else {
2200
			$classes[] = 'pt-lg-' . sanitize_html_class( $args['pt_lg'] );
2201
		}
2202
	}
2203
	if ( isset( $args['pr_lg'] ) && $args['pr_lg'] !== '' ) {
2204
		if ( $pr == null && $pr_md == null ) {
2205
			$classes[] = $p_pr . sanitize_html_class( $args['pr_lg'] );
2206
		} else {
2207
			$classes[] = $p_pr . 'lg-' . sanitize_html_class( $args['pr_lg'] );
2208
		}
2209
	}
2210
	if ( isset( $args['pb_lg'] ) && $args['pb_lg'] !== '' ) {
2211
		if ( $pb == null && $pb_md == null ) {
2212
			$classes[] = 'pb-' . sanitize_html_class( $args['pb_lg'] );
2213
		} else {
2214
			$classes[] = 'pb-lg-' . sanitize_html_class( $args['pb_lg'] );
2215
		}
2216
	}
2217
	if ( isset( $args['pl_lg'] ) && $args['pl_lg'] !== '' ) {
2218
		if ( $pl == null && $pl_md == null ) {
2219
			$classes[] = $p_pl . sanitize_html_class( $args['pl_lg'] );
2220
		} else {
2221
			$classes[] = $p_pl . 'lg-' . sanitize_html_class( $args['pl_lg'] );
2222
		}
2223
	}
2224
2225
	// row cols, mobile, tablet, desktop
2226
	if ( ! empty( $args['row_cols'] ) && $args['row_cols'] !== '' ) {
2227
		$classes[] = sanitize_html_class( 'row-cols-' . $args['row_cols'] );
2228
		$row_cols  = $args['row_cols'];
2229
	} else {
2230
		$row_cols = null;
2231
	}
2232
	if ( ! empty( $args['row_cols_md'] ) && $args['row_cols_md'] !== '' ) {
2233
		$classes[]   = sanitize_html_class( 'row-cols-md-' . $args['row_cols_md'] );
2234
		$row_cols_md = $args['row_cols_md'];
2235
	} else {
2236
		$row_cols_md = null;
2237
	}
2238
	if ( ! empty( $args['row_cols_lg'] ) && $args['row_cols_lg'] !== '' ) {
2239
		if ( $row_cols == null && $row_cols_md == null ) {
2240
			$classes[] = sanitize_html_class( 'row-cols-' . $args['row_cols_lg'] );
2241
		} else {
2242
			$classes[] = sanitize_html_class( 'row-cols-lg-' . $args['row_cols_lg'] );
2243
		}
2244
	}
2245
2246
	// columns , mobile, tablet, desktop
2247
	if ( ! empty( $args['col'] ) && $args['col'] !== '' ) {
2248
		$classes[] = sanitize_html_class( 'col-' . $args['col'] );
2249
		$col       = $args['col'];
2250
	} else {
2251
		$col = null;
2252
	}
2253
	if ( ! empty( $args['col_md'] ) && $args['col_md'] !== '' ) {
2254
		$classes[] = sanitize_html_class( 'col-md-' . $args['col_md'] );
2255
		$col_md    = $args['col_md'];
2256
	} else {
2257
		$col_md = null;
2258
	}
2259
	if ( ! empty( $args['col_lg'] ) && $args['col_lg'] !== '' ) {
2260
		if ( $col == null && $col_md == null ) {
2261
			$classes[] = sanitize_html_class( 'col-' . $args['col_lg'] );
2262
		} else {
2263
			$classes[] = sanitize_html_class( 'col-lg-' . $args['col_lg'] );
2264
		}
2265
	}
2266
2267
	// border
2268
	if ( isset( $args['border'] ) && ( $args['border'] == 'none' || $args['border'] === '0' || $args['border'] === 0 ) ) {
2269
		$classes[] = 'border-0';
2270
	} elseif ( ! empty( $args['border'] ) ) {
2271
		$border_class = 'border';
2272
		if ( ! empty( $args['border_type'] ) && strpos( $args['border_type'], '-0' ) === false ) {
2273
			$border_class = '';
2274
		}
2275
		$classes[] = $border_class . ' border-' . sanitize_html_class( $args['border'] );
2276
	}
2277
2278
	// border radius type
2279
	if ( ! empty( $args['rounded'] ) ) {
2280
		$classes[] = sanitize_html_class( $args['rounded'] );
2281
	}
2282
2283
	// border radius size BS4
2284
	if ( isset( $args['rounded_size'] ) && in_array( $args['rounded_size'], array( 'sm', 'lg' ) ) ) {
2285
		$classes[] = 'rounded-' . sanitize_html_class( $args['rounded_size'] );
2286
		// if we set a size then we need to remove "rounded" if set
2287
		if ( ( $key = array_search( 'rounded', $classes ) ) !== false ) {
2288
			unset( $classes[ $key ] );
2289
		}
2290
	} else {
2291
2292
		// border radius size , mobile, tablet, desktop
2293
		if ( isset( $args['rounded_size'] ) && $args['rounded_size'] !== '' ) {
2294
			$classes[]    = sanitize_html_class( 'rounded-' . $args['rounded_size'] );
2295
			$rounded_size = $args['rounded_size'];
2296
		} else {
2297
			$rounded_size = null;
2298
		}
2299
		if ( isset( $args['rounded_size_md'] ) && $args['rounded_size_md'] !== '' ) {
2300
			$classes[]       = sanitize_html_class( 'rounded-md-' . $args['rounded_size_md'] );
2301
			$rounded_size_md = $args['rounded_size_md'];
2302
		} else {
2303
			$rounded_size_md = null;
2304
		}
2305
		if ( isset( $args['rounded_size_lg'] ) && $args['rounded_size_lg'] !== '' ) {
2306
			if ( $rounded_size == null && $rounded_size_md == null ) {
2307
				$classes[] = sanitize_html_class( 'rounded-' . $args['rounded_size_lg'] );
2308
			} else {
2309
				$classes[] = sanitize_html_class( 'rounded-lg-' . $args['rounded_size_lg'] );
2310
			}
2311
		}
2312
	}
2313
2314
	// shadow
2315
	//if ( !empty( $args['shadow'] ) ) { $classes[] = sanitize_html_class($args['shadow']); }
2316
2317
	// background
2318
	if ( ! empty( $args['bg'] ) ) {
2319
		$classes[] = 'bg-' . sanitize_html_class( $args['bg'] );
2320
	}
2321
2322
	// text_color
2323
	if ( ! empty( $args['text_color'] ) ) {
2324
		$classes[] = 'text-' . sanitize_html_class( $args['text_color'] );
2325
	}
2326
2327
	// text_align
2328
	if ( ! empty( $args['text_justify'] ) ) {
2329
		$classes[] = 'text-justify';
2330
	} else {
2331
		if ( ! empty( $args['text_align'] ) ) {
2332
			$classes[]  = sanitize_html_class( $args['text_align'] );
2333
			$text_align = $args['text_align'];
2334
		} else {
2335
			$text_align = null;
2336
		}
2337
		if ( ! empty( $args['text_align_md'] ) && $args['text_align_md'] !== '' ) {
2338
			$classes[]     = sanitize_html_class( $args['text_align_md'] );
2339
			$text_align_md = $args['text_align_md'];
2340
		} else {
2341
			$text_align_md = null;
2342
		}
2343
		if ( ! empty( $args['text_align_lg'] ) && $args['text_align_lg'] !== '' ) {
2344
			if ( $text_align == null && $text_align_md == null ) {
2345
				$classes[] = sanitize_html_class( str_replace( '-lg', '', $args['text_align_lg'] ) );
2346
			} else {
2347
				$classes[] = sanitize_html_class( $args['text_align_lg'] );
2348
			}
2349
		}
2350
	}
2351
2352
	// display
2353
	if ( ! empty( $args['display'] ) ) {
2354
		$classes[] = sanitize_html_class( $args['display'] );
2355
		$display   = $args['display'];
2356
	} else {
2357
		$display = null;
2358
	}
2359
	if ( ! empty( $args['display_md'] ) && $args['display_md'] !== '' ) {
2360
		$classes[]  = sanitize_html_class( $args['display_md'] );
2361
		$display_md = $args['display_md'];
2362
	} else {
2363
		$display_md = null;
2364
	}
2365
	if ( ! empty( $args['display_lg'] ) && $args['display_lg'] !== '' ) {
2366
		if ( $display == null && $display_md == null ) {
2367
			$classes[] = sanitize_html_class( str_replace( '-lg', '', $args['display_lg'] ) );
2368
		} else {
2369
			$classes[] = sanitize_html_class( $args['display_lg'] );
2370
		}
2371
	}
2372
2373
	// bgtus - background transparent until scroll
2374
	if ( ! empty( $args['bgtus'] ) ) {
2375
		$classes[] = sanitize_html_class( 'bg-transparent-until-scroll' );
2376
	}
2377
2378
	// cscos - change color scheme on scroll
2379
	if ( ! empty( $args['bgtus'] ) && ! empty( $args['cscos'] ) ) {
2380
		$classes[] = sanitize_html_class( 'color-scheme-flip-on-scroll' );
2381
	}
2382
2383
	// hover animations
2384
	if ( ! empty( $args['hover_animations'] ) ) {
2385
		$classes[] = sd_sanitize_html_classes( str_replace( ',', ' ', $args['hover_animations'] ) );
2386
	}
2387
2388
	// absolute_position
2389
	if ( ! empty( $args['absolute_position'] ) ) {
2390
		if ( 'top-left' === $args['absolute_position'] ) {
2391
			$classes[] = 'start-0 top-0';
2392
		} elseif ( 'top-center' === $args['absolute_position'] ) {
2393
			$classes[] = 'start-50 top-0 translate-middle';
2394
		} elseif ( 'top-right' === $args['absolute_position'] ) {
2395
			$classes[] = 'end-0 top-0';
2396
		} elseif ( 'center-left' === $args['absolute_position'] ) {
2397
			$classes[] = 'start-0 top-50';
2398
		} elseif ( 'center' === $args['absolute_position'] ) {
2399
			$classes[] = 'start-50 top-50 translate-middle';
2400
		} elseif ( 'center-right' === $args['absolute_position'] ) {
2401
			$classes[] = 'end-0 top-50';
2402
		} elseif ( 'bottom-left' === $args['absolute_position'] ) {
2403
			$classes[] = 'start-0 bottom-0';
2404
		} elseif ( 'bottom-center' === $args['absolute_position'] ) {
2405
			$classes[] = 'start-50 bottom-0 translate-middle';
2406
		} elseif ( 'bottom-right' === $args['absolute_position'] ) {
2407
			$classes[] = 'end-0 bottom-0';
2408
		}
2409
	}
2410
2411
	// build classes from build keys
2412
	$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...
2413
	if ( ! empty( $build_keys ) ) {
2414
		foreach ( $build_keys as $key ) {
0 ignored issues
show
Bug introduced by
The expression $build_keys of type void is not traversable.
Loading history...
2415
2416
			if ( substr( $key, -4 ) == '-MTD' ) {
2417
2418
				$k = str_replace( '-MTD', '', $key );
2419
2420
				// Mobile, Tablet, Desktop
2421
				if ( ! empty( $args[ $k ] ) && $args[ $k ] !== '' ) {
2422
					$classes[] = sanitize_html_class( $args[ $k ] );
2423
					$v         = $args[ $k ];
2424
				} else {
2425
					$v = null;
2426
				}
2427
				if ( ! empty( $args[ $k . '_md' ] ) && $args[ $k . '_md' ] !== '' ) {
2428
					$classes[] = sanitize_html_class( $args[ $k . '_md' ] );
2429
					$v_md      = $args[ $k . '_md' ];
2430
				} else {
2431
					$v_md = null;
2432
				}
2433
				if ( ! empty( $args[ $k . '_lg' ] ) && $args[ $k . '_lg' ] !== '' ) {
2434
					if ( $v == null && $v_md == null ) {
2435
						$classes[] = sanitize_html_class( str_replace( '-lg', '', $args[ $k . '_lg' ] ) );
2436
					} else {
2437
						$classes[] = sanitize_html_class( $args[ $k . '_lg' ] );
2438
					}
2439
				}
2440
			} else {
2441
				if ( $key == 'font_size' && ! empty( $args[ $key ] ) && $args[ $key ] == 'custom' ) {
2442
					continue;
2443
				}
2444
				if ( ! empty( $args[ $key ] ) ) {
2445
					$classes[] = sd_sanitize_html_classes( $args[ $key ] );
2446
				}
2447
			}
2448
		}
2449
	}
2450
2451
	return implode( ' ', $classes );
2452
}
2453
2454
/**
2455
 * Build Style output from arguments.
2456
 *
2457
 * @param $args
2458
 *
2459
 * @return array
2460
 */
2461
function sd_build_aui_styles( $args ) {
2462
2463
	$styles = array();
2464
2465
	// background color
2466
	if ( ! empty( $args['bg'] ) && $args['bg'] !== '' ) {
2467
		if ( $args['bg'] == 'custom-color' ) {
2468
			$styles['background-color'] = $args['bg_color'];
2469
		} elseif ( $args['bg'] == 'custom-gradient' ) {
2470
			$styles['background-image'] = $args['bg_gradient'];
2471
2472
			// use background on text.
2473
			if ( ! empty( $args['bg_on_text'] ) && $args['bg_on_text'] ) {
2474
				$styles['background-clip']         = 'text';
2475
				$styles['-webkit-background-clip'] = 'text';
2476
				$styles['text-fill-color']         = 'transparent';
2477
				$styles['-webkit-text-fill-color'] = 'transparent';
2478
			}
2479
		}
2480
	}
2481
2482
	if ( ! empty( $args['bg_image'] ) && $args['bg_image'] !== '' ) {
2483
		$hasImage = true;
2484
		if ( ! empty( $styles['background-color'] ) && $args['bg'] == 'custom-color' ) {
2485
			$styles['background-image']      = 'url(' . $args['bg_image'] . ')';
2486
			$styles['background-blend-mode'] = 'overlay';
2487
		} elseif ( ! empty( $styles['background-image'] ) && $args['bg'] == 'custom-gradient' ) {
2488
			$styles['background-image'] .= ',url(' . $args['bg_image'] . ')';
2489
		} elseif ( ! empty( $args['bg'] ) && $args['bg'] != '' && $args['bg'] != 'transparent' ) {
2490
			// do nothing as we alreay have a preset
2491
			$hasImage = false;
2492
		} else {
2493
			$styles['background-image'] = 'url(' . $args['bg_image'] . ')';
2494
		}
2495
2496
		if ( $hasImage ) {
2497
			$styles['background-size'] = 'cover';
2498
2499
			if ( ! empty( $args['bg_image_fixed'] ) && $args['bg_image_fixed'] ) {
2500
				$styles['background-attachment'] = 'fixed';
2501
			}
2502
		}
2503
2504
		if ( $hasImage && ! empty( $args['bg_image_xy'] ) && ! empty( $args['bg_image_xy']['x'] ) ) {
2505
			$styles['background-position'] = ( $args['bg_image_xy']['x'] * 100 ) . '% ' . ( $args['bg_image_xy']['y'] * 100 ) . '%';
2506
		}
2507
	}
2508
2509
	// sticky offset top
2510
	if ( ! empty( $args['sticky_offset_top'] ) && $args['sticky_offset_top'] !== '' ) {
2511
		$styles['top'] = absint( $args['sticky_offset_top'] );
2512
	}
2513
2514
	// sticky offset bottom
2515
	if ( ! empty( $args['sticky_offset_bottom'] ) && $args['sticky_offset_bottom'] !== '' ) {
2516
		$styles['bottom'] = absint( $args['sticky_offset_bottom'] );
2517
	}
2518
2519
	// font size
2520
	if ( ! empty( $args['font_size_custom'] ) && $args['font_size_custom'] !== '' ) {
2521
		$styles['font-size'] = (float) $args['font_size_custom'] . 'rem';
2522
	}
2523
2524
	// font color
2525
	if ( ! empty( $args['text_color_custom'] ) && $args['text_color_custom'] !== '' ) {
2526
		$styles['color'] = esc_attr( $args['text_color_custom'] );
2527
	}
2528
2529
	// font line height
2530
	if ( ! empty( $args['font_line_height'] ) && $args['font_line_height'] !== '' ) {
2531
		$styles['line-height'] = esc_attr( $args['font_line_height'] );
2532
	}
2533
2534
	// max height
2535
	if ( ! empty( $args['max_height'] ) && $args['max_height'] !== '' ) {
2536
		$styles['max-height'] = esc_attr( $args['max_height'] );
2537
	}
2538
2539
	$style_string = '';
2540
	if ( ! empty( $styles ) ) {
2541
		foreach ( $styles as $key => $val ) {
2542
			$style_string .= esc_attr( $key ) . ':' . esc_attr( $val ) . ';';
2543
		}
2544
	}
2545
2546
	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...
2547
2548
}
2549
2550
/**
2551
 * Build the hover styles from args.
2552
 *
2553
 * @param $args
2554
 * @param $is_preview
2555
 *
2556
 * @return string
2557
 */
2558
function sd_build_hover_styles( $args, $is_preview = false ) {
2559
	$rules = '';
2560
	// text color
2561
	if ( ! empty( $args['styleid'] ) ) {
2562
		$styleid = $is_preview ? 'html .editor-styles-wrapper .' . esc_attr( $args['styleid'] ) : 'html .' . esc_attr( $args['styleid'] );
2563
2564
		// text
2565
		if ( ! empty( $args['text_color_hover'] ) ) {
2566
			$key    = 'custom' === $args['text_color_hover'] && ! empty( $args['text_color_hover_custom'] ) ? 'text_color_hover_custom' : 'text_color_hover';
2567
			$color  = sd_get_color_from_var( $args[ $key ] );
2568
			$rules .= $styleid . ':hover {color: ' . $color . ' !important;} ';
2569
		}
2570
2571
		// bg
2572
		if ( ! empty( $args['bg_hover'] ) ) {
2573
			if ( 'custom-gradient' === $args['bg_hover'] ) {
2574
				$color  = $args['bg_hover_gradient'];
2575
				$rules .= $styleid . ':hover {background-image: ' . $color . ' !important;} ';
2576
				$rules .= $styleid . '.btn:hover {border-color: transparent !important;} ';
2577
			} else {
2578
				$key    = 'custom-color' === $args['bg_hover'] ? 'bg_hover_color' : 'bg_hover';
2579
				$color  = sd_get_color_from_var( $args[ $key ] );
2580
				$rules .= $styleid . ':hover {background: ' . $color . ' !important;} ';
2581
				$rules .= $styleid . '.btn:hover {border-color: ' . $color . ' !important;} ';
2582
			}
2583
		}
2584
	}
2585
2586
	return $rules ? '<style>' . $rules . '</style>' : '';
2587
}
2588
2589
/**
2590
 * Try to get a CSS color varibale for a given value.
2591
 *
2592
 * @param $var
2593
 *
2594
 * @return mixed|string
2595
 */
2596
function sd_get_color_from_var( $var ) {
2597
2598
	//sanitize_hex_color() @todo this does not cover transparency
2599
	if ( strpos( $var, '#' ) === false ) {
2600
		$var = defined( 'BLOCKSTRAP_BLOCKS_VERSION' ) ? 'var(--wp--preset--color--' . esc_attr( $var ) . ')' : 'var(--' . esc_attr( $var ) . ')';
2601
	}
2602
2603
	return $var;
2604
}
2605
2606
/**
2607
 * Sanitize single or multiple HTML classes.
2608
 *
2609
 * @param $classes
2610
 * @param $sep
2611
 *
2612
 * @return string
2613
 */
2614
function sd_sanitize_html_classes( $classes, $sep = ' ' ) {
2615
	$return = '';
2616
2617
	if ( ! is_array( $classes ) ) {
2618
		$classes = explode( $sep, $classes );
2619
	}
2620
2621
	if ( ! empty( $classes ) ) {
2622
		foreach ( $classes as $class ) {
2623
			$return .= sanitize_html_class( $class ) . ' ';
2624
		}
2625
	}
2626
2627
	return $return;
2628
}
2629
2630
2631
/**
2632
 * Keys that are used for the class builder.
2633
 *
2634
 * @return void
2635
 */
2636
function sd_get_class_build_keys() {
2637
	$keys = array(
2638
		'container',
2639
		'position',
2640
		'flex_direction',
2641
		'shadow',
2642
		'rounded',
2643
		'nav_style',
2644
		'horizontal_alignment',
2645
		'nav_fill',
2646
		'width',
2647
		'font_weight',
2648
		'font_size',
2649
		'font_case',
2650
		'css_class',
2651
		'flex_align_items-MTD',
2652
		'flex_justify_content-MTD',
2653
		'flex_align_self-MTD',
2654
		'flex_order-MTD',
2655
		'styleid',
2656
		'border_opacity',
2657
		'border_width',
2658
		'border_type',
2659
		'opacity',
2660
		'zindex',
2661
		'flex_wrap-MTD',
2662
		'h100',
2663
		'overflow',
2664
		'scrollbars',
2665
		'float-MTD'
2666
	);
2667
2668
	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...
2669
}
2670
2671
/**
2672
 * This is a placeholder function for the visibility conditions input.
2673
 *
2674
 * @param $type
2675
 * @param $overwrite
2676
 *
2677
 * @return array
2678
 */
2679
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

2679
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...
2680
	$defaults = array(
2681
		'type'         => 'visibility_conditions',
2682
		'title'        => __( 'Block Visibility', 'ayecode-connect' ),
2683
		'button_title' => __( 'Set Block Visibility', 'ayecode-connect' ),
2684
		'default'      => '',
2685
		'desc_tip'     => true,
2686
		'group'        => __( 'Visibility Conditions', 'ayecode-connect' ),
2687
	);
2688
2689
	$input = wp_parse_args( $overwrite, $defaults );
2690
2691
	return $input;
2692
}
2693
2694
/**
2695
 * Get a array of user roles.
2696
 *
2697
 *
2698
 *
2699
 * @param array $exclude An array of roles to exclude from the return array.
2700
 * @return array An array of roles.
2701
 */
2702
function sd_user_roles_options( $exclude = array() ) {
2703
	$user_roles = array();
2704
2705
	if ( !function_exists('get_editable_roles') ) {
2706
		require_once( ABSPATH . '/wp-admin/includes/user.php' );
2707
	}
2708
2709
	$roles = get_editable_roles();
2710
2711
	foreach ( $roles as $role => $data ) {
2712
		if ( ! ( ! empty( $exclude ) && in_array( $role, $exclude ) ) ) {
2713
			$user_roles[ esc_attr( $role ) ] = translate_user_role( $data['name'] );
2714
		}
2715
	}
2716
2717
	return apply_filters( 'sd_user_roles_options', $user_roles );
2718
}
2719
2720
/**
2721
 * Get visibility conditions rule options.
2722
 *
2723
 *
2724
 *
2725
 * @return array Rule options.
2726
 */
2727
function sd_visibility_rules_options() {
2728
	$options = array(
2729
		'logged_in'  => __( 'Logged In', 'ayecode-connect' ),
2730
		'logged_out' => __( 'Logged Out', 'ayecode-connect' ),
2731
		'post_author'  => __( 'Post Author', 'ayecode-connect' ),
2732
		'user_roles' => __( 'Specific User Roles', 'ayecode-connect' )
2733
	);
2734
2735
	if ( class_exists( 'GeoDirectory' ) ) {
2736
		$options['gd_field'] = __( 'GD Field', 'ayecode-connect' );
2737
	}
2738
2739
	return apply_filters( 'sd_visibility_rules_options', $options );
2740
}
2741
2742
/**
2743
 * Get visibility GD field options.
2744
 *
2745
 * @return array
2746
 */
2747
function sd_visibility_gd_field_options() {
2748
	$fields = geodir_post_custom_fields( '', 'all', 'all', 'none' );
0 ignored issues
show
Bug introduced by
The function geodir_post_custom_fields was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

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

2748
	$fields = /** @scrutinizer ignore-call */ geodir_post_custom_fields( '', 'all', 'all', 'none' );
Loading history...
2749
2750
	$keys = array();
2751
	if ( ! empty( $fields ) ) {
2752
		foreach( $fields as $field ) {
2753
			if ( apply_filters( 'geodir_badge_field_skip_key', false, $field ) ) {
2754
				continue;
2755
			}
2756
2757
			$keys[ $field['htmlvar_name'] ] = $field['htmlvar_name'] . ' ( ' . __( $field['admin_title'], 'geodirectory' ) . ' )';
2758
2759
			// Extra address fields
2760
			if ( $field['htmlvar_name'] == 'address' && ( $address_fields = geodir_post_meta_address_fields( '' ) ) ) {
0 ignored issues
show
Bug introduced by
The function geodir_post_meta_address_fields was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

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

2760
			if ( $field['htmlvar_name'] == 'address' && ( $address_fields = /** @scrutinizer ignore-call */ geodir_post_meta_address_fields( '' ) ) ) {
Loading history...
2761
				foreach ( $address_fields as $_field => $args ) {
2762
					if ( $_field != 'map_directions' && $_field != 'street' ) {
2763
						$keys[ $_field ] = $_field . ' ( ' . $args['frontend_title'] . ' )';
2764
					}
2765
				}
2766
			}
2767
		}
2768
	}
2769
2770
	$standard_fields = sd_visibility_gd_standard_field_options();
2771
2772
	if ( ! empty( $standard_fields ) ) {
2773
		foreach ( $standard_fields as $key => $option ) {
2774
			$keys[ $key ] = $option;
2775
		}
2776
	}
2777
2778
	$options = apply_filters( 'geodir_badge_field_keys', $keys );
2779
2780
	return apply_filters( 'sd_visibility_gd_field_options', $options );
2781
}
2782
2783
/**
2784
 * Get visibility GD post standard field options.
2785
 *
2786
 * @return array
2787
 */
2788
function sd_visibility_gd_standard_field_options( $post_type = '' ) {
2789
	$fields = sd_visibility_gd_standard_fields( $post_type );
2790
2791
	$options = array();
2792
2793
	foreach ( $fields as $key => $field ) {
2794
		if ( ! empty( $field['frontend_title'] ) ) {
2795
			$options[ $key ] = $key . ' ( ' . $field['frontend_title'] . ' )';
2796
		}
2797
	}
2798
2799
	return apply_filters( 'sd_visibility_gd_standard_field_options', $options, $fields );
2800
}
2801
2802
/**
2803
 * Get visibility GD post standard fields.
2804
 *
2805
 * @return array
2806
 */
2807
function sd_visibility_gd_standard_fields( $post_type = '' ) {
2808
	$standard_fields = geodir_post_meta_standard_fields( $post_type );
0 ignored issues
show
Bug introduced by
The function geodir_post_meta_standard_fields was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

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

2808
	$standard_fields = /** @scrutinizer ignore-call */ geodir_post_meta_standard_fields( $post_type );
Loading history...
2809
2810
	$fields = array();
2811
2812
	foreach ( $standard_fields as $key => $field ) {
2813
		if ( $key != 'post_link' && strpos( $key, 'event' ) === false && ! empty( $field['frontend_title'] ) ) {
2814
			$fields[ $key ] = $field;
2815
		}
2816
	}
2817
2818
	return apply_filters( 'sd_visibility_gd_standard_fields', $fields );
2819
}
2820
2821
/**
2822
 * Get visibility field conditions options.
2823
 *
2824
 * @return array
2825
 */
2826
function sd_visibility_field_condition_options(){
2827
	$options = array(
2828
		'is_empty' => __( 'is empty', 'ayecode-connect' ),
2829
		'is_not_empty' => __( 'is not empty', 'ayecode-connect' ),
2830
		'is_equal' => __( 'is equal', 'ayecode-connect' ),
2831
		'is_not_equal' => __( 'is not equal', 'ayecode-connect' ),
2832
		'is_greater_than' => __( 'is greater than', 'ayecode-connect' ),
2833
		'is_less_than' => __( 'is less than', 'ayecode-connect' ),
2834
		'is_contains' => __( 'is contains', 'ayecode-connect' ),
2835
		'is_not_contains' => __( 'is not contains', 'ayecode-connect' ),
2836
	);
2837
2838
	return apply_filters( 'sd_visibility_field_condition_options', $options );
2839
}
2840
2841
/**
2842
 * Get visibility conditions output options.
2843
 *
2844
 *
2845
 *
2846
 * @return array Template type options.
2847
 */
2848
function sd_visibility_output_options() {
2849
	$options = array(
2850
		'hide'          => __( 'Hide Block', 'ayecode-connect' ),
2851
		'message'       => __( 'Show Custom Message', 'ayecode-connect' ),
2852
		'page'          => __( 'Show Page Content', 'ayecode-connect' ),
2853
		'template_part' => __( 'Show Template Part', 'ayecode-connect' ),
2854
	);
2855
2856
	return apply_filters( 'sd_visibility_output_options', $options );
2857
}
2858
2859
/**
2860
 * Get the template page options.
2861
 *
2862
 *
2863
 *
2864
 * @param array $args Array of arguments.
2865
 * @return array Template page options.
2866
 */
2867
function sd_template_page_options( $args = array() ) {
2868
	global $sd_tmpl_page_options;
2869
2870
	if ( ! empty( $sd_tmpl_page_options ) ) {
2871
		return $sd_tmpl_page_options;
2872
	}
2873
2874
	$args = wp_parse_args( $args, array(
2875
		'child_of'    => 0,
2876
		'sort_column' => 'post_title',
2877
		'sort_order'  => 'ASC'
2878
	) );
2879
2880
	$exclude_pages = array();
2881
	if ( $page_on_front = get_option( 'page_on_front' ) ) {
2882
		$exclude_pages[] = $page_on_front;
2883
	}
2884
2885
	if ( $page_for_posts = get_option( 'page_for_posts' ) ) {
2886
		$exclude_pages[] = $page_for_posts;
2887
	}
2888
2889
	if ( ! empty( $exclude_pages ) ) {
2890
		$args['exclude'] = $exclude_pages;
2891
	}
2892
2893
	$pages = get_pages( $args );
2894
2895
	$options = array( '' => __( 'Select Page...', 'ayecode-connect' ) );
2896
	if ( ! empty( $pages ) ) {
2897
		foreach ( $pages as $page ) {
2898
			if ( ! empty( $page->ID ) && ! empty( $page->post_title ) ) {
2899
				$options[ $page->ID ] = $page->post_title . ' (#' . $page->ID . ')';
2900
			}
2901
		}
2902
	}
2903
2904
	$sd_tmpl_page_options = $options;
2905
2906
	return apply_filters( 'sd_template_page_options', $options );
2907
}
2908
2909
/**
2910
 * Get the template part options.
2911
 *
2912
 *
2913
 *
2914
 * @param array $args Array of arguments.
2915
 * @return array Template part options.
2916
 */
2917
function sd_template_part_options( $args = array() ) {
2918
	global $sd_tmpl_part_options;
2919
2920
	if ( ! empty( $sd_tmpl_part_options ) ) {
2921
		return $sd_tmpl_part_options;
2922
	}
2923
2924
	$options = array( '' => __( 'Select Template Part...', 'ayecode-connect' ) );
2925
2926
	$parts = get_block_templates( array(), 'wp_template_part' );
2927
2928
	if ( ! empty( $parts ) ) {
2929
		foreach ( $parts as $part ) {
2930
			$options[ $part->slug ] = $part->title . ' (#' . $part->slug . ')';
2931
		}
2932
	}
2933
2934
	$sd_tmpl_part_options = $options;
2935
2936
	return apply_filters( 'sd_template_part_options', $options, $args );
2937
}
2938
2939
/**
2940
 * Get the template part by slug.
2941
 *
2942
 *
2943
 *
2944
 * @param string $slug Template slug.
2945
 * @return array Template part object.
2946
 */
2947
function sd_get_template_part_by_slug( $slug ) {
2948
	global $bs_tmpl_part_by_slug;
2949
2950
	if ( empty( $bs_tmpl_part_by_slug ) ) {
2951
		$bs_tmpl_part_by_slug = array();
2952
	}
2953
2954
	if ( isset( $bs_tmpl_part_by_slug[ $slug ] ) ) {
2955
		return $bs_tmpl_part_by_slug[ $slug ];
2956
	}
2957
2958
	$template_query = get_block_templates( array( 'slug__in' => array( $slug ) ), 'wp_template_part' );
2959
2960
	$query_post = ! empty( $template_query ) ? $template_query[0] : array();
2961
2962
	$template_part = ! empty( $query_post ) && $query_post->status == 'publish' ? $query_post : array();
2963
2964
	$bs_tmpl_part_by_slug[ $slug ] = $template_part;
2965
2966
	return apply_filters( 'sd_get_template_part_by_slug', $template_part, $slug );
0 ignored issues
show
Bug Best Practice introduced by
The expression return apply_filters('sd... $template_part, $slug) also could return the type WP_Block_Template which is incompatible with the documented return type array.
Loading history...
2967
}
2968
2969
/**
2970
 * Filters the content of a single block.
2971
 *
2972
 *
2973
 *
2974
 * @param string   $block_content The block content.
2975
 * @param array    $block         The full block, including name and attributes.
2976
 * @param WP_Block $instance      The block instance.
2977
 */
2978
function sd_render_block( $block_content, $block, $instance = '' ) {
2979
	// No block visibility conditions set.
2980
	if ( empty( $block['attrs']['visibility_conditions'] ) ) {
2981
		return $block_content;
2982
	}
2983
2984
	$attributes = json_decode( $block['attrs']['visibility_conditions'], true );
2985
	$rules = ! empty( $attributes ) ? sd_block_parse_rules( $attributes ) : array();
2986
2987
	// No rules set.
2988
	if ( empty( $rules ) ) {
2989
		return $block_content;
2990
	}
2991
2992
	$_block_content = $block_content;
2993
2994
	if ( ! empty( $rules ) && sd_block_check_rules( $rules ) ) {
2995
		if ( ! empty( $attributes['output']['type'] ) ) {
2996
			switch ( $attributes['output']['type'] ) {
2997
				case 'hide':
2998
					$valid_type = true;
2999
					$content = '';
3000
3001
					break;
3002
				case 'message':
3003
					$valid_type = true;
3004
3005
					if ( isset( $attributes['output']['message'] ) ) {
3006
						$content = $attributes['output']['message'] != '' ? __( stripslashes( $attributes['output']['message'] ), 'ayecode-connect' ) : $attributes['output']['message'];
3007
3008
						if ( ! empty( $attributes['output']['message_type'] ) ) {
3009
							$content = aui()->alert( array(
3010
									'type'=> $attributes['output']['message_type'],
3011
									'content'=> $content
3012
								)
3013
							);
3014
						}
3015
					}
3016
3017
					break;
3018
				case 'page':
3019
					$valid_type = true;
3020
3021
					$page_id = ! empty( $attributes['output']['page'] ) ? absint( $attributes['output']['page'] ) : 0;
3022
					$content = sd_get_page_content( $page_id );
3023
3024
					break;
3025
				case 'template_part':
3026
					$valid_type = true;
3027
3028
					$template_part = ! empty( $attributes['output']['template_part'] ) ? $attributes['output']['template_part'] : '';
3029
					$content = sd_get_template_part_content( $template_part );
3030
3031
					break;
3032
				default:
3033
					$valid_type = false;
3034
					break;
3035
			}
3036
3037
			if ( $valid_type ) {
3038
				$block_content = '<div class="' . esc_attr( wp_get_block_default_classname( $instance->name ) ) . ' sd-block-has-rule">' . $content . '</div>';
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $content does not seem to be defined for all execution paths leading up to this point.
Loading history...
3039
			}
3040
		}
3041
	}
3042
3043
	return apply_filters( 'sd_render_block_visibility_content', $block_content, $_block_content, $attributes, $block, $instance );
3044
}
3045
add_filter( 'render_block', 'sd_render_block', 9, 3 );
3046
3047
function sd_get_page_content( $page_id ) {
3048
	$content = $page_id > 0 ? get_post_field( 'post_content', (int) $page_id ) : '';
3049
3050
	// Maybe bypass content
3051
	$bypass_content = apply_filters( 'sd_bypass_page_content', '', $content, $page_id );
3052
	if ( $bypass_content ) {
3053
		return $bypass_content;
3054
	}
3055
3056
	// Run the shortcodes on the content.
3057
	$content = do_shortcode( $content );
3058
3059
	// Run block content if its available.
3060
	if ( function_exists( 'do_blocks' ) ) {
3061
		$content = do_blocks( $content );
3062
	}
3063
3064
	return apply_filters( 'sd_get_page_content', $content, $page_id );
3065
}
3066
3067
function sd_get_template_part_content( $template_part ) {
3068
	$template_part_post = $template_part ? sd_get_template_part_by_slug( $template_part ) : array();
3069
	$content = ! empty( $template_part_post ) ? $template_part_post->content : '';
3070
3071
	// Maybe bypass content
3072
	$bypass_content = apply_filters( 'sd_bypass_template_part_content', '', $content, $template_part );
3073
	if ( $bypass_content ) {
3074
		return $bypass_content;
3075
	}
3076
3077
	// Run the shortcodes on the content.
3078
	$content = do_shortcode( $content );
3079
3080
	// Run block content if its available.
3081
	if ( function_exists( 'do_blocks' ) ) {
3082
		$content = do_blocks( $content );
3083
	}
3084
3085
	return apply_filters( 'sd_get_template_part_content', $content, $template_part );
3086
}
3087
3088
function sd_block_parse_rules( $attrs ) {
3089
	$rules = array();
3090
3091
	if ( ! empty( $attrs ) && is_array( $attrs ) ) {
3092
		$attrs_keys = array_keys( $attrs );
3093
3094
		for ( $i = 1; $i <= count( $attrs_keys ); $i++ ) {
0 ignored issues
show
Performance Best Practice introduced by
It seems like you are calling the size function count() as part of the test condition. You might want to compute the size beforehand, and not on each iteration.

If the size of the collection does not change during the iteration, it is generally a good practice to compute it beforehand, and not on each iteration:

for ($i=0; $i<count($array); $i++) { // calls count() on each iteration
}

// Better
for ($i=0, $c=count($array); $i<$c; $i++) { // calls count() just once
}
Loading history...
3095
			if ( ! empty( $attrs[ 'rule' . $i ] ) && is_array( $attrs[ 'rule' . $i ] ) ) {
3096
				$rules[] = $attrs[ 'rule' . $i ];
3097
			}
3098
		}
3099
	}
3100
3101
	return apply_filters( 'sd_block_parse_rules', $rules, $attrs );
3102
}
3103
3104
function sd_block_check_rules( $rules ) {
3105
	if ( ! ( is_array( $rules ) && ! empty( $rules ) ) ) {
3106
		return true;
3107
	}
3108
3109
	foreach ( $rules as $key => $rule ) {
3110
		$match = apply_filters( 'sd_block_check_rule', true, $rule );
3111
3112
		if ( ! $match ) {
3113
			break;
3114
		}
3115
	}
3116
3117
	return apply_filters( 'sd_block_check_rules', $match, $rules );
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $match seems to be defined by a foreach iteration on line 3109. Are you sure the iterator is never empty, otherwise this variable is not defined?
Loading history...
3118
}
3119
3120
function sd_block_check_rule( $match, $rule ) {
3121
	global $post;
3122
3123
	if ( $match && ! empty( $rule['type'] ) ) {
3124
		switch ( $rule['type'] ) {
3125
			case 'logged_in':
3126
				$match = (bool) is_user_logged_in();
3127
3128
				break;
3129
			case 'logged_out':
3130
				$match = ! is_user_logged_in();
3131
3132
				break;
3133
			case 'post_author':
3134
				if ( ! empty( $post ) && $post->post_type != 'page' && ! empty( $post->post_author ) && is_user_logged_in() ) {
3135
					$match = (int) $post->post_author === (int) get_current_user_id() ? true : false;
3136
				} else {
3137
					$match = false;
3138
				}
3139
3140
				break;
3141
			case 'user_roles':
3142
				$match = false;
3143
3144
				if ( ! empty( $rule['user_roles'] ) ) {
3145
					$user_roles = is_scalar( $rule['user_roles'] ) ? explode( ",", $rule['user_roles'] ) : $rule['user_roles'];
3146
3147
					if ( is_array( $user_roles ) ) {
3148
						$user_roles = array_filter( array_map( 'trim', $user_roles ) );
3149
					}
3150
3151
					if ( ! empty( $user_roles ) && is_array( $user_roles ) && is_user_logged_in() && ( $current_user = wp_get_current_user() ) ) {
3152
						$current_user_roles = $current_user->roles;
3153
3154
						foreach ( $user_roles as $role ) {
3155
							if ( in_array( $role, $current_user_roles ) ) {
3156
								$match = true;
3157
							}
3158
						}
3159
					}
3160
				}
3161
3162
				break;
3163
			case 'gd_field':
3164
				$match = sd_block_check_rule_gd_field( $rule );
3165
3166
				break;
3167
		}
3168
	}
3169
3170
	return $match;
3171
}
3172
add_filter( 'sd_block_check_rule', 'sd_block_check_rule', 10, 2 );
3173
3174
function sd_block_check_rule_gd_field( $rule ) {
3175
	global $gd_post;
3176
3177
	$match_found = false;
3178
3179
	if ( class_exists( 'GeoDirectory' ) && ! empty( $gd_post->ID ) && ! empty( $rule['field'] ) && ! empty( $rule['condition'] ) ) {
3180
		$args['block_visibility'] = true;
0 ignored issues
show
Comprehensibility Best Practice introduced by
$args was never initialized. Although not strictly required by PHP, it is generally a good practice to add $args = array(); before regardless.
Loading history...
3181
		$args['key'] = $rule['field'];
3182
		$args['condition'] = $rule['condition'];
3183
		$args['search'] = isset( $rule['search'] ) ? $rule['search'] : '';
3184
3185
		if ( $args['key'] == 'street' ) {
3186
			$args['key'] = 'address';
3187
		}
3188
3189
		$match_field = $_match_field = $args['key'];
3190
3191
		if ( $match_field == 'address' ) {
3192
			$match_field = 'street';
3193
		} elseif ( $match_field == 'post_images' ) {
3194
			$match_field = 'featured_image';
3195
		}
3196
3197
		$find_post = $gd_post;
3198
		$find_post_keys = ! empty( $find_post ) ? array_keys( (array) $find_post ) : array();
3199
3200
		if ( ! empty( $find_post->ID ) && ! in_array( 'post_category', $find_post_keys ) ) {
3201
			$find_post = geodir_get_post_info( (int) $find_post->ID );
0 ignored issues
show
Bug introduced by
The function geodir_get_post_info was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

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

3201
			$find_post = /** @scrutinizer ignore-call */ geodir_get_post_info( (int) $find_post->ID );
Loading history...
3202
			$find_post_keys = ! empty( $find_post ) ? array_keys( (array) $find_post ) : array();
3203
		}
3204
3205
		if ( $match_field === '' || ( ! empty( $find_post_keys ) && ( in_array( $match_field, $find_post_keys ) || in_array( $_match_field, $find_post_keys ) ) ) ) {
3206
			$address_fields = array( 'street2', 'neighbourhood', 'city', 'region', 'country', 'zip', 'latitude', 'longitude' ); // Address fields
3207
			$field = array();
3208
3209
			$standard_fields = sd_visibility_gd_standard_fields();
3210
3211
			if ( $match_field && ! in_array( $match_field, array_keys( $standard_fields ) ) && ! in_array( $match_field, $address_fields ) ) {
3212
				$package_id = geodir_get_post_package_id( $find_post->ID, $find_post->post_type );
0 ignored issues
show
Bug introduced by
The function geodir_get_post_package_id was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

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

3212
				$package_id = /** @scrutinizer ignore-call */ geodir_get_post_package_id( $find_post->ID, $find_post->post_type );
Loading history...
3213
				$fields = geodir_post_custom_fields( $package_id, 'all', $find_post->post_type, 'none' );
0 ignored issues
show
Bug introduced by
The function geodir_post_custom_fields was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

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

3213
				$fields = /** @scrutinizer ignore-call */ geodir_post_custom_fields( $package_id, 'all', $find_post->post_type, 'none' );
Loading history...
3214
3215
				foreach ( $fields as $field_info ) {
3216
					if ( $match_field == $field_info['htmlvar_name'] ) {
3217
						$field = $field_info;
3218
						break;
3219
					} elseif( $_match_field == $field_info['htmlvar_name'] ) {
3220
						$field = $field_info;
3221
						break;
3222
					}
3223
				}
3224
3225
				if ( empty( $field ) ) {
3226
					return false;
3227
				}
3228
			}
3229
3230
			// Address fields.
3231
			if ( in_array( $match_field, $address_fields ) && ( $address_fields = geodir_post_meta_address_fields( '' ) ) ) {
0 ignored issues
show
Bug introduced by
The function geodir_post_meta_address_fields was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

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

3231
			if ( in_array( $match_field, $address_fields ) && ( $address_fields = /** @scrutinizer ignore-call */ geodir_post_meta_address_fields( '' ) ) ) {
Loading history...
3232
				if ( ! empty( $address_fields[ $match_field ] ) ) {
3233
					$field = $address_fields[ $match_field ];
3234
				}
3235
			} else if ( in_array( $match_field, array_keys( $standard_fields ) ) ) {
3236
				if ( ! empty( $standard_fields[ $match_field ] ) ) {
3237
					$field = $standard_fields[ $match_field ];
3238
				}
3239
			}
3240
3241
			// Parse search.
3242
			$search = sd_gd_field_rule_search( $args['search'], $find_post->post_type, $rule, $field, $find_post );
3243
3244
			$is_date = ( ! empty( $field['type'] ) && $field['type'] == 'datepicker' ) || in_array( $match_field, array( 'post_date', 'post_modified' ) ) ? true : false;
3245
			$is_date = apply_filters( 'geodir_post_badge_is_date', $is_date, $match_field, $field, $args, $find_post );
0 ignored issues
show
Unused Code introduced by
The assignment to $is_date is dead and can be removed.
Loading history...
3246
3247
			$match_value = isset($find_post->{$match_field}) ? esc_attr( trim( $find_post->{$match_field} ) ) : '';
3248
			$match_found = $match_field === '' ? true : false;
3249
3250
			if ( ! $match_found ) {
3251
				if ( ( $match_field == 'post_date' || $match_field == 'post_modified' ) && ( empty( $args['condition'] ) || $args['condition'] == 'is_greater_than' || $args['condition'] == 'is_less_than' ) ) {
3252
					if ( strpos( $search, '+' ) === false && strpos( $search, '-' ) === false ) {
3253
						$search = '+' . $search;
3254
					}
3255
					$the_time = $match_field == 'post_modified' ? get_the_modified_date( 'Y-m-d', $find_post ) : get_the_time( 'Y-m-d', $find_post );
3256
					$until_time = strtotime( $the_time . ' ' . $search . ' days' );
0 ignored issues
show
Bug introduced by
Are you sure $the_time of type false|integer|string can be used in concatenation? ( Ignorable by Annotation )

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

3256
					$until_time = strtotime( /** @scrutinizer ignore-type */ $the_time . ' ' . $search . ' days' );
Loading history...
3257
					$now_time   = strtotime( date_i18n( 'Y-m-d', current_time( 'timestamp' ) ) );
3258
					if ( ( empty( $args['condition'] ) || $args['condition'] == 'is_less_than' ) && $until_time > $now_time ) {
3259
						$match_found = true;
3260
					} elseif ( $args['condition'] == 'is_greater_than' && $until_time < $now_time ) {
3261
						$match_found = true;
3262
					}
3263
				} else {
3264
					switch ( $args['condition'] ) {
3265
						case 'is_equal':
3266
							$match_found = (bool) ( $search != '' && $match_value == $search );
3267
							break;
3268
						case 'is_not_equal':
3269
							$match_found = (bool) ( $search != '' && $match_value != $search );
3270
							break;
3271
						case 'is_greater_than':
3272
							$match_found = (bool) ( $search != '' && ( is_float( $search ) || is_numeric( $search ) ) && ( is_float( $match_value ) || is_numeric( $match_value ) ) && $match_value > $search );
3273
							break;
3274
						case 'is_less_than':
3275
							$match_found = (bool) ( $search != '' && ( is_float( $search ) || is_numeric( $search ) ) && ( is_float( $match_value ) || is_numeric( $match_value ) ) && $match_value < $search );
3276
							break;
3277
						case 'is_empty':
3278
							$match_found = (bool) ( $match_value === '' || $match_value === false || $match_value === '0' || is_null( $match_value ) );
3279
							break;
3280
						case 'is_not_empty':
3281
							$match_found = (bool) ( $match_value !== '' && $match_value !== false && $match_value !== '0' && ! is_null( $match_value ) );
3282
							break;
3283
						case 'is_contains':
3284
							$match_found = (bool) ( $search != '' && stripos( $match_value, $search ) !== false );
3285
							break;
3286
						case 'is_not_contains':
3287
							$match_found = (bool) ( $search != '' && stripos( $match_value, $search ) === false );
3288
							break;
3289
					}
3290
				}
3291
			}
3292
3293
			$match_found = apply_filters( 'geodir_post_badge_check_match_found', $match_found, $args, $find_post );
3294
		}
3295
	}
3296
3297
	return $match_found;
3298
}
3299
3300
function sd_gd_field_rule_search( $search, $post_type, $rule, $field = array(), $gd_post = array() ) {
0 ignored issues
show
Unused Code introduced by
The parameter $field 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

3300
function sd_gd_field_rule_search( $search, $post_type, $rule, /** @scrutinizer ignore-unused */ $field = array(), $gd_post = 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...
Unused Code introduced by
The parameter $gd_post 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

3300
function sd_gd_field_rule_search( $search, $post_type, $rule, $field = array(), /** @scrutinizer ignore-unused */ $gd_post = 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...
3301
	global $post;
3302
3303
	if ( ! $search ) {
3304
		return $search;
3305
	}
3306
3307
	$orig_search = $search;
3308
	$_search = strtolower( $search );
3309
3310
	if ( ! empty( $rule['field'] ) && $rule['field'] == 'post_author' ) {
3311
		if ( $search == 'current_user' ) {
3312
			$search = is_user_logged_in() ? (int) get_current_user_id() : - 1;
3313
		} else if ( $search == 'current_author' ) {
3314
			$search = ( ! empty( $post ) && $post->post_type != 'page' && isset( $post->post_author ) ) ? absint( $post->post_author ) : - 1;
3315
		}
3316
	} else if ( $_search == 'date_today' ) {
3317
		$search = date( 'Y-m-d' );
3318
	} else if ( $_search == 'date_tomorrow' ) {
3319
		$search = date( 'Y-m-d', strtotime( "+1 day" ) );
3320
	} else if ( $_search == 'date_yesterday' ) {
3321
		$search = date( 'Y-m-d', strtotime( "-1 day" ) );
3322
	} else if ( $_search == 'time_his' ) {
3323
		$search = date( 'H:i:s' );
3324
	} else if ( $_search == 'time_hi' ) {
3325
		$search = date( 'H:i' );
3326
	} else if ( $_search == 'datetime_now' ) {
3327
		$search = date( 'Y-m-d H:i:s' );
3328
	} else if ( strpos( $_search, 'datetime_after_' ) === 0 ) {
3329
		$_searches = explode( 'datetime_after_', $_search, 2 );
3330
3331
		if ( ! empty( $_searches[1] ) ) {
3332
			$search = date( 'Y-m-d H:i:s', strtotime( "+ " . str_replace( "_", " ", $_searches[1] ) ) );
3333
		} else {
3334
			$search = date( 'Y-m-d H:i:s' );
3335
		}
3336
	} else if ( strpos( $_search, 'datetime_before_' ) === 0 ) {
3337
		$_searches = explode( 'datetime_before_', $_search, 2 );
3338
3339
		if ( ! empty( $_searches[1] ) ) {
3340
			$search = date( 'Y-m-d H:i:s', strtotime( "- " . str_replace( "_", " ", $_searches[1] ) ) );
3341
		} else {
3342
			$search = date( 'Y-m-d H:i:s' );
3343
		}
3344
	} else if ( strpos( $_search, 'date_after_' ) === 0 ) {
3345
		$_searches = explode( 'date_after_', $_search, 2 );
3346
3347
		if ( ! empty( $_searches[1] ) ) {
3348
			$search = date( 'Y-m-d', strtotime( "+ " . str_replace( "_", " ", $_searches[1] ) ) );
3349
		} else {
3350
			$search = date( 'Y-m-d' );
3351
		}
3352
	} else if ( strpos( $_search, 'date_before_' ) === 0 ) {
3353
		$_searches = explode( 'date_before_', $_search, 2 );
3354
3355
		if ( ! empty( $_searches[1] ) ) {
3356
			$search = date( 'Y-m-d', strtotime( "- " . str_replace( "_", " ", $_searches[1] ) ) );
3357
		} else {
3358
			$search = date( 'Y-m-d' );
3359
		}
3360
	}
3361
3362
	return apply_filters( 'sd_gd_field_rule_search', $search, $post_type, $rule, $orig_search );
3363
}