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() ) { |
|
|
|
|
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() ) { |
|
|
|
|
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() ) { |
|
|
|
|
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 ) { |
|
|
|
|
439
|
|
|
$input[ $type ] = wp_parse_args( $overwrite, $defaults ); |
|
|
|
|
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; |
|
|
|
|
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() ) { |
|
|
|
|
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 ); |
|
|
|
|
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 ) { |
|
|
|
|
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 = '' ) { |
|
|
|
|
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() ) { |
|
|
|
|
826
|
|
|
|
827
|
|
|
$device_size = ''; |
828
|
|
|
if ( ! empty( $overwrite['device_type'] ) ) { |
829
|
|
|
if ( $overwrite['device_type'] == 'Tablet' ) { |
830
|
|
|
$device_size = '-md'; |
|
|
|
|
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() ) { |
|
|
|
|
876
|
|
|
|
877
|
|
|
$device_size = ''; |
878
|
|
|
if ( ! empty( $overwrite['device_type'] ) ) { |
879
|
|
|
if ( $overwrite['device_type'] == 'Tablet' ) { |
880
|
|
|
$device_size = '-md'; |
|
|
|
|
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() ) { |
|
|
|
|
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() ) { |
|
|
|
|
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() ) { |
|
|
|
|
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() ) { |
|
|
|
|
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() ) { |
|
|
|
|
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() ) { |
|
|
|
|
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 ) { |
|
|
|
|
1286
|
|
|
global $aui_bs5; |
1287
|
|
|
|
1288
|
|
|
$options[] = __( 'Inherit from parent', 'ayecode-connect' ); |
|
|
|
|
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 = '' ) { |
|
|
|
|
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() ) { |
|
|
|
|
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 ) { |
|
|
|
|
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() ) { |
|
|
|
|
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() ) { |
|
|
|
|
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() ) { |
|
|
|
|
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() ) { |
|
|
|
|
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() ) { |
|
|
|
|
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 the class input. |
1579
|
|
|
* |
1580
|
|
|
* @param $type |
1581
|
|
|
* @param $overwrite |
1582
|
|
|
* |
1583
|
|
|
* @return array |
1584
|
|
|
*/ |
1585
|
|
|
function sd_get_custom_name_input( $type = 'metadata_name', $overwrite = array() ) { |
|
|
|
|
1586
|
|
|
|
1587
|
|
|
$defaults = array( |
1588
|
|
|
'type' => 'text', |
1589
|
|
|
'title' => __( 'Block Name', 'ayecode-connect' ), |
1590
|
|
|
'desc' => __( 'Set a custom name for this block', 'ayecode-connect' ), |
1591
|
|
|
'default' => '', |
1592
|
|
|
'desc_tip' => true, |
1593
|
|
|
'group' => __( 'Advanced', 'ayecode-connect' ), |
1594
|
|
|
); |
1595
|
|
|
|
1596
|
|
|
$input = wp_parse_args( $overwrite, $defaults ); |
1597
|
|
|
|
1598
|
|
|
return $input; |
1599
|
|
|
} |
1600
|
|
|
|
1601
|
|
|
/** |
1602
|
|
|
* A helper function for font size inputs. |
1603
|
|
|
* |
1604
|
|
|
* @param string $type |
1605
|
|
|
* @param array $overwrite |
1606
|
|
|
* |
1607
|
|
|
* @return array |
1608
|
|
|
*/ |
1609
|
|
|
function sd_get_hover_animations_input( $type = 'hover_animations', $overwrite = array() ) { |
|
|
|
|
1610
|
|
|
|
1611
|
|
|
$options = array( |
1612
|
|
|
'' => __( 'none', 'ayecode-connect' ), |
1613
|
|
|
'hover-zoom' => __( 'Zoom', 'ayecode-connect' ), |
1614
|
|
|
'hover-shadow' => __( 'Shadow', 'ayecode-connect' ), |
1615
|
|
|
'hover-move-up' => __( 'Move up', 'ayecode-connect' ), |
1616
|
|
|
'hover-move-down' => __( 'Move down', 'ayecode-connect' ), |
1617
|
|
|
'hover-move-left' => __( 'Move left', 'ayecode-connect' ), |
1618
|
|
|
'hover-move-right' => __( 'Move right', 'ayecode-connect' ), |
1619
|
|
|
); |
1620
|
|
|
|
1621
|
|
|
$defaults = array( |
1622
|
|
|
'type' => 'select', |
1623
|
|
|
'multiple' => true, |
1624
|
|
|
'title' => __( 'Hover Animations', 'ayecode-connect' ), |
1625
|
|
|
'options' => $options, |
1626
|
|
|
'default' => '', |
1627
|
|
|
'desc_tip' => true, |
1628
|
|
|
'group' => __( 'Hover Animations', 'ayecode-connect' ), |
1629
|
|
|
); |
1630
|
|
|
|
1631
|
|
|
$input = wp_parse_args( $overwrite, $defaults ); |
1632
|
|
|
|
1633
|
|
|
return $input; |
1634
|
|
|
} |
1635
|
|
|
|
1636
|
|
|
|
1637
|
|
|
function sd_get_flex_align_items_input( $type = 'align-items', $overwrite = array() ) { |
|
|
|
|
1638
|
|
|
$device_size = ''; |
1639
|
|
|
if ( ! empty( $overwrite['device_type'] ) ) { |
1640
|
|
|
if ( $overwrite['device_type'] == 'Tablet' ) { |
1641
|
|
|
$device_size = '-md'; |
1642
|
|
|
} elseif ( $overwrite['device_type'] == 'Desktop' ) { |
1643
|
|
|
$device_size = '-lg'; |
1644
|
|
|
} |
1645
|
|
|
} |
1646
|
|
|
$options = array( |
1647
|
|
|
'' => __( 'Default', 'ayecode-connect' ), |
1648
|
|
|
'align-items' . $device_size . '-start' => 'align-items-start', |
1649
|
|
|
'align-items' . $device_size . '-end' => 'align-items-end', |
1650
|
|
|
'align-items' . $device_size . '-center' => 'align-items-center', |
1651
|
|
|
'align-items' . $device_size . '-baseline' => 'align-items-baseline', |
1652
|
|
|
'align-items' . $device_size . '-stretch' => 'align-items-stretch', |
1653
|
|
|
); |
1654
|
|
|
|
1655
|
|
|
$defaults = array( |
1656
|
|
|
'type' => 'select', |
1657
|
|
|
'title' => __( 'Vertical Align Items', 'ayecode-connect' ), |
1658
|
|
|
'options' => $options, |
1659
|
|
|
'default' => '', |
1660
|
|
|
'desc_tip' => true, |
1661
|
|
|
'group' => __( 'Wrapper Styles', 'ayecode-connect' ), |
1662
|
|
|
'element_require' => ' ( ( [%container%]=="row" ) || ( [%display%]=="d-flex" || [%display_md%]=="d-md-flex" || [%display_lg%]=="d-lg-flex" ) ) ', |
1663
|
|
|
|
1664
|
|
|
); |
1665
|
|
|
|
1666
|
|
|
$input = wp_parse_args( $overwrite, $defaults ); |
1667
|
|
|
|
1668
|
|
|
return $input; |
1669
|
|
|
} |
1670
|
|
|
|
1671
|
|
|
function sd_get_flex_align_items_input_group( $type = 'flex_align_items', $overwrite = array() ) { |
1672
|
|
|
$inputs = array(); |
1673
|
|
|
$sizes = array( |
1674
|
|
|
'' => 'Mobile', |
1675
|
|
|
'_md' => 'Tablet', |
1676
|
|
|
'_lg' => 'Desktop', |
1677
|
|
|
); |
1678
|
|
|
|
1679
|
|
|
if ( $overwrite !== false ) { |
1680
|
|
|
|
1681
|
|
|
foreach ( $sizes as $ds => $dt ) { |
1682
|
|
|
$overwrite['device_type'] = $dt; |
1683
|
|
|
$inputs[ $type . $ds ] = sd_get_flex_align_items_input( $type, $overwrite ); |
1684
|
|
|
} |
1685
|
|
|
} |
1686
|
|
|
|
1687
|
|
|
return $inputs; |
1688
|
|
|
} |
1689
|
|
|
|
1690
|
|
|
function sd_get_flex_justify_content_input( $type = 'flex_justify_content', $overwrite = array() ) { |
|
|
|
|
1691
|
|
|
$device_size = ''; |
1692
|
|
|
if ( ! empty( $overwrite['device_type'] ) ) { |
1693
|
|
|
if ( $overwrite['device_type'] == 'Tablet' ) { |
1694
|
|
|
$device_size = '-md'; |
1695
|
|
|
} elseif ( $overwrite['device_type'] == 'Desktop' ) { |
1696
|
|
|
$device_size = '-lg'; |
1697
|
|
|
} |
1698
|
|
|
} |
1699
|
|
|
$options = array( |
1700
|
|
|
'' => __( 'Default', 'ayecode-connect' ), |
1701
|
|
|
'justify-content' . $device_size . '-start' => 'justify-content-start', |
1702
|
|
|
'justify-content' . $device_size . '-end' => 'justify-content-end', |
1703
|
|
|
'justify-content' . $device_size . '-center' => 'justify-content-center', |
1704
|
|
|
'justify-content' . $device_size . '-between' => 'justify-content-between', |
1705
|
|
|
'justify-content' . $device_size . '-stretch' => 'justify-content-around', |
1706
|
|
|
); |
1707
|
|
|
|
1708
|
|
|
$defaults = array( |
1709
|
|
|
'type' => 'select', |
1710
|
|
|
'title' => __( 'Justify content', 'ayecode-connect' ), |
1711
|
|
|
'options' => $options, |
1712
|
|
|
'default' => '', |
1713
|
|
|
'desc_tip' => true, |
1714
|
|
|
'group' => __( 'Wrapper Styles', 'ayecode-connect' ), |
1715
|
|
|
'element_require' => '( ( [%container%]=="row" ) || ( [%display%]=="d-flex" || [%display_md%]=="d-md-flex" || [%display_lg%]=="d-lg-flex" ) ) ', |
1716
|
|
|
|
1717
|
|
|
); |
1718
|
|
|
|
1719
|
|
|
$input = wp_parse_args( $overwrite, $defaults ); |
1720
|
|
|
|
1721
|
|
|
return $input; |
1722
|
|
|
} |
1723
|
|
|
|
1724
|
|
|
function sd_get_flex_justify_content_input_group( $type = 'flex_justify_content', $overwrite = array() ) { |
1725
|
|
|
$inputs = array(); |
1726
|
|
|
$sizes = array( |
1727
|
|
|
'' => 'Mobile', |
1728
|
|
|
'_md' => 'Tablet', |
1729
|
|
|
'_lg' => 'Desktop', |
1730
|
|
|
); |
1731
|
|
|
|
1732
|
|
|
if ( $overwrite !== false ) { |
1733
|
|
|
|
1734
|
|
|
foreach ( $sizes as $ds => $dt ) { |
1735
|
|
|
$overwrite['device_type'] = $dt; |
1736
|
|
|
$inputs[ $type . $ds ] = sd_get_flex_justify_content_input( $type, $overwrite ); |
1737
|
|
|
} |
1738
|
|
|
} |
1739
|
|
|
|
1740
|
|
|
return $inputs; |
1741
|
|
|
} |
1742
|
|
|
|
1743
|
|
|
|
1744
|
|
|
function sd_get_flex_align_self_input( $type = 'flex_align_self', $overwrite = array() ) { |
|
|
|
|
1745
|
|
|
$device_size = ''; |
1746
|
|
|
if ( ! empty( $overwrite['device_type'] ) ) { |
1747
|
|
|
if ( $overwrite['device_type'] == 'Tablet' ) { |
1748
|
|
|
$device_size = '-md'; |
1749
|
|
|
} elseif ( $overwrite['device_type'] == 'Desktop' ) { |
1750
|
|
|
$device_size = '-lg'; |
1751
|
|
|
} |
1752
|
|
|
} |
1753
|
|
|
$options = array( |
1754
|
|
|
'' => __( 'Default', 'ayecode-connect' ), |
1755
|
|
|
'align-items' . $device_size . '-start' => 'align-items-start', |
1756
|
|
|
'align-items' . $device_size . '-end' => 'align-items-end', |
1757
|
|
|
'align-items' . $device_size . '-center' => 'align-items-center', |
1758
|
|
|
'align-items' . $device_size . '-baseline' => 'align-items-baseline', |
1759
|
|
|
'align-items' . $device_size . '-stretch' => 'align-items-stretch', |
1760
|
|
|
); |
1761
|
|
|
|
1762
|
|
|
$defaults = array( |
1763
|
|
|
'type' => 'select', |
1764
|
|
|
'title' => __( 'Align Self', 'ayecode-connect' ), |
1765
|
|
|
'options' => $options, |
1766
|
|
|
'default' => '', |
1767
|
|
|
'desc_tip' => true, |
1768
|
|
|
'group' => __( 'Wrapper Styles', 'ayecode-connect' ), |
1769
|
|
|
'element_require' => ' [%container%]=="col" ', |
1770
|
|
|
|
1771
|
|
|
); |
1772
|
|
|
|
1773
|
|
|
$input = wp_parse_args( $overwrite, $defaults ); |
1774
|
|
|
|
1775
|
|
|
return $input; |
1776
|
|
|
} |
1777
|
|
|
|
1778
|
|
|
function sd_get_flex_align_self_input_group( $type = 'flex_align_self', $overwrite = array() ) { |
1779
|
|
|
$inputs = array(); |
1780
|
|
|
$sizes = array( |
1781
|
|
|
'' => 'Mobile', |
1782
|
|
|
'_md' => 'Tablet', |
1783
|
|
|
'_lg' => 'Desktop', |
1784
|
|
|
); |
1785
|
|
|
|
1786
|
|
|
if ( $overwrite !== false ) { |
1787
|
|
|
|
1788
|
|
|
foreach ( $sizes as $ds => $dt ) { |
1789
|
|
|
$overwrite['device_type'] = $dt; |
1790
|
|
|
$inputs[ $type . $ds ] = sd_get_flex_align_self_input( $type, $overwrite ); |
1791
|
|
|
} |
1792
|
|
|
} |
1793
|
|
|
|
1794
|
|
|
return $inputs; |
1795
|
|
|
} |
1796
|
|
|
|
1797
|
|
|
function sd_get_flex_order_input( $type = 'flex_order', $overwrite = array() ) { |
|
|
|
|
1798
|
|
|
$device_size = ''; |
1799
|
|
|
if ( ! empty( $overwrite['device_type'] ) ) { |
1800
|
|
|
if ( $overwrite['device_type'] == 'Tablet' ) { |
1801
|
|
|
$device_size = '-md'; |
1802
|
|
|
} elseif ( $overwrite['device_type'] == 'Desktop' ) { |
1803
|
|
|
$device_size = '-lg'; |
1804
|
|
|
} |
1805
|
|
|
} |
1806
|
|
|
$options = array( |
1807
|
|
|
'' => __( 'Default', 'ayecode-connect' ), |
1808
|
|
|
); |
1809
|
|
|
|
1810
|
|
|
$i = 0; |
1811
|
|
|
while ( $i <= 5 ) { |
1812
|
|
|
$options[ 'order' . $device_size . '-' . $i ] = $i; |
1813
|
|
|
$i++; |
1814
|
|
|
} |
1815
|
|
|
|
1816
|
|
|
$defaults = array( |
1817
|
|
|
'type' => 'select', |
1818
|
|
|
'title' => __( 'Flex Order', 'ayecode-connect' ), |
1819
|
|
|
'options' => $options, |
1820
|
|
|
'default' => '', |
1821
|
|
|
'desc_tip' => true, |
1822
|
|
|
'group' => __( 'Wrapper Styles', 'ayecode-connect' ), |
1823
|
|
|
'element_require' => ' [%container%]=="col" ', |
1824
|
|
|
|
1825
|
|
|
); |
1826
|
|
|
|
1827
|
|
|
$input = wp_parse_args( $overwrite, $defaults ); |
1828
|
|
|
|
1829
|
|
|
return $input; |
1830
|
|
|
} |
1831
|
|
|
|
1832
|
|
|
function sd_get_flex_order_input_group( $type = 'flex_order', $overwrite = array() ) { |
1833
|
|
|
$inputs = array(); |
1834
|
|
|
$sizes = array( |
1835
|
|
|
'' => 'Mobile', |
1836
|
|
|
'_md' => 'Tablet', |
1837
|
|
|
'_lg' => 'Desktop', |
1838
|
|
|
); |
1839
|
|
|
|
1840
|
|
|
if ( $overwrite !== false ) { |
1841
|
|
|
|
1842
|
|
|
foreach ( $sizes as $ds => $dt ) { |
1843
|
|
|
$overwrite['device_type'] = $dt; |
1844
|
|
|
$inputs[ $type . $ds ] = sd_get_flex_order_input( $type, $overwrite ); |
1845
|
|
|
} |
1846
|
|
|
} |
1847
|
|
|
|
1848
|
|
|
return $inputs; |
1849
|
|
|
} |
1850
|
|
|
|
1851
|
|
|
function sd_get_flex_wrap_group( $type = 'flex_wrap', $overwrite = array() ) { |
1852
|
|
|
$inputs = array(); |
1853
|
|
|
$sizes = array( |
1854
|
|
|
'' => 'Mobile', |
1855
|
|
|
'_md' => 'Tablet', |
1856
|
|
|
'_lg' => 'Desktop', |
1857
|
|
|
); |
1858
|
|
|
|
1859
|
|
|
if ( $overwrite !== false ) { |
1860
|
|
|
|
1861
|
|
|
foreach ( $sizes as $ds => $dt ) { |
1862
|
|
|
$overwrite['device_type'] = $dt; |
1863
|
|
|
$inputs[ $type . $ds ] = sd_get_flex_wrap_input( $type, $overwrite ); |
1864
|
|
|
} |
1865
|
|
|
} |
1866
|
|
|
|
1867
|
|
|
return $inputs; |
1868
|
|
|
} |
1869
|
|
|
|
1870
|
|
|
function sd_get_flex_wrap_input( $type = 'flex_wrap', $overwrite = array() ) { |
|
|
|
|
1871
|
|
|
$device_size = ''; |
1872
|
|
|
if ( ! empty( $overwrite['device_type'] ) ) { |
1873
|
|
|
if ( $overwrite['device_type'] == 'Tablet' ) { |
1874
|
|
|
$device_size = '-md'; |
1875
|
|
|
} elseif ( $overwrite['device_type'] == 'Desktop' ) { |
1876
|
|
|
$device_size = '-lg'; |
1877
|
|
|
} |
1878
|
|
|
} |
1879
|
|
|
$options = array( |
1880
|
|
|
'' => __( 'Default', 'ayecode-connect' ), |
1881
|
|
|
'flex' . $device_size . '-nowrap' => 'nowrap', |
1882
|
|
|
'flex' . $device_size . '-wrap' => 'wrap', |
1883
|
|
|
'flex' . $device_size . '-wrap-reverse' => 'wrap-reverse', |
1884
|
|
|
); |
1885
|
|
|
|
1886
|
|
|
$defaults = array( |
1887
|
|
|
'type' => 'select', |
1888
|
|
|
'title' => __( 'Flex wrap', 'ayecode-connect' ), |
1889
|
|
|
'options' => $options, |
1890
|
|
|
'default' => '', |
1891
|
|
|
'desc_tip' => true, |
1892
|
|
|
'group' => __( 'Wrapper Styles', 'ayecode-connect' ), |
1893
|
|
|
); |
1894
|
|
|
|
1895
|
|
|
$input = wp_parse_args( $overwrite, $defaults ); |
1896
|
|
|
|
1897
|
|
|
return $input; |
1898
|
|
|
} |
1899
|
|
|
|
1900
|
|
|
function sd_get_float_group( $type = 'float', $overwrite = array() ) { |
1901
|
|
|
$inputs = array(); |
1902
|
|
|
$sizes = array( |
1903
|
|
|
'' => 'Mobile', |
1904
|
|
|
'_md' => 'Tablet', |
1905
|
|
|
'_lg' => 'Desktop', |
1906
|
|
|
); |
1907
|
|
|
|
1908
|
|
|
if ( $overwrite !== false ) { |
1909
|
|
|
|
1910
|
|
|
foreach ( $sizes as $ds => $dt ) { |
1911
|
|
|
$overwrite['device_type'] = $dt; |
1912
|
|
|
$inputs[ $type . $ds ] = sd_get_float_input( $type, $overwrite ); |
1913
|
|
|
} |
1914
|
|
|
} |
1915
|
|
|
|
1916
|
|
|
return $inputs; |
1917
|
|
|
} |
1918
|
|
|
function sd_get_float_input( $type = 'float', $overwrite = array() ) { |
|
|
|
|
1919
|
|
|
$device_size = ''; |
1920
|
|
|
if ( ! empty( $overwrite['device_type'] ) ) { |
1921
|
|
|
if ( $overwrite['device_type'] == 'Tablet' ) { |
1922
|
|
|
$device_size = '-md'; |
1923
|
|
|
} elseif ( $overwrite['device_type'] == 'Desktop' ) { |
1924
|
|
|
$device_size = '-lg'; |
1925
|
|
|
} |
1926
|
|
|
} |
1927
|
|
|
$options = array( |
1928
|
|
|
'' => __( 'Default', 'ayecode-connect' ), |
1929
|
|
|
'float' . $device_size . '-start' => 'left', |
1930
|
|
|
'float' . $device_size . '-end' => 'right', |
1931
|
|
|
'float' . $device_size . '-none' => 'none', |
1932
|
|
|
); |
1933
|
|
|
|
1934
|
|
|
$defaults = array( |
1935
|
|
|
'type' => 'select', |
1936
|
|
|
'title' => __( 'Float', 'ayecode-connect' ), |
1937
|
|
|
'options' => $options, |
1938
|
|
|
'default' => '', |
1939
|
|
|
'desc_tip' => true, |
1940
|
|
|
'group' => __( 'Wrapper Styles', 'ayecode-connect' ), |
1941
|
|
|
); |
1942
|
|
|
|
1943
|
|
|
$input = wp_parse_args( $overwrite, $defaults ); |
1944
|
|
|
|
1945
|
|
|
return $input; |
1946
|
|
|
} |
1947
|
|
|
|
1948
|
|
|
/** |
1949
|
|
|
* @param $type |
1950
|
|
|
* @param $overwrite |
1951
|
|
|
* |
1952
|
|
|
* @return array |
1953
|
|
|
*/ |
1954
|
|
|
function sd_get_zindex_input( $type = 'zindex', $overwrite = array() ) { |
|
|
|
|
1955
|
|
|
|
1956
|
|
|
$options = array( |
1957
|
|
|
'' => __( 'Default', 'ayecode-connect' ), |
1958
|
|
|
'zindex-0' => '0', |
1959
|
|
|
'zindex-1' => '1', |
1960
|
|
|
'zindex-5' => '5', |
1961
|
|
|
'zindex-10' => '10', |
1962
|
|
|
); |
1963
|
|
|
|
1964
|
|
|
$defaults = array( |
1965
|
|
|
'type' => 'select', |
1966
|
|
|
'title' => __( 'Z-index', 'ayecode-connect' ), |
1967
|
|
|
'options' => $options, |
1968
|
|
|
'default' => '', |
1969
|
|
|
'desc_tip' => true, |
1970
|
|
|
'group' => __( 'Wrapper Styles', 'ayecode-connect' ), |
1971
|
|
|
); |
1972
|
|
|
|
1973
|
|
|
$input = wp_parse_args( $overwrite, $defaults ); |
1974
|
|
|
|
1975
|
|
|
return $input; |
1976
|
|
|
} |
1977
|
|
|
|
1978
|
|
|
/** |
1979
|
|
|
* @param $type |
1980
|
|
|
* @param $overwrite |
1981
|
|
|
* |
1982
|
|
|
* @return array |
1983
|
|
|
*/ |
1984
|
|
|
function sd_get_overflow_input( $type = 'overflow', $overwrite = array() ) { |
|
|
|
|
1985
|
|
|
|
1986
|
|
|
$options = array( |
1987
|
|
|
'' => __( 'Default', 'ayecode-connect' ), |
1988
|
|
|
'overflow-auto' => __( 'Auto', 'ayecode-connect' ), |
1989
|
|
|
'overflow-hidden' => __( 'Hidden', 'ayecode-connect' ), |
1990
|
|
|
'overflow-visible' => __( 'Visible', 'ayecode-connect' ), |
1991
|
|
|
'overflow-scroll' => __( 'Scroll', 'ayecode-connect' ), |
1992
|
|
|
); |
1993
|
|
|
|
1994
|
|
|
$defaults = array( |
1995
|
|
|
'type' => 'select', |
1996
|
|
|
'title' => __( 'Overflow', 'ayecode-connect' ), |
1997
|
|
|
'options' => $options, |
1998
|
|
|
'default' => '', |
1999
|
|
|
'desc_tip' => true, |
2000
|
|
|
'group' => __( 'Wrapper Styles', 'ayecode-connect' ), |
2001
|
|
|
); |
2002
|
|
|
|
2003
|
|
|
$input = wp_parse_args( $overwrite, $defaults ); |
2004
|
|
|
|
2005
|
|
|
return $input; |
2006
|
|
|
} |
2007
|
|
|
|
2008
|
|
|
/** |
2009
|
|
|
* @param $type |
2010
|
|
|
* @param $overwrite |
2011
|
|
|
* |
2012
|
|
|
* @return array |
2013
|
|
|
*/ |
2014
|
|
|
function sd_get_max_height_input( $type = 'max_height', $overwrite = array() ) { |
|
|
|
|
2015
|
|
|
|
2016
|
|
|
$defaults = array( |
2017
|
|
|
'type' => 'text', |
2018
|
|
|
'title' => __( 'Max height', 'ayecode-connect' ), |
2019
|
|
|
'value' => '', |
2020
|
|
|
'default' => '', |
2021
|
|
|
'placeholder' => '', |
2022
|
|
|
'desc_tip' => true, |
2023
|
|
|
'group' => __( 'Wrapper Styles', 'ayecode-connect' ), |
2024
|
|
|
); |
2025
|
|
|
|
2026
|
|
|
$input = wp_parse_args( $overwrite, $defaults ); |
2027
|
|
|
|
2028
|
|
|
return $input; |
2029
|
|
|
} |
2030
|
|
|
|
2031
|
|
|
/** |
2032
|
|
|
* @param $type |
2033
|
|
|
* @param $overwrite |
2034
|
|
|
* |
2035
|
|
|
* @return array |
2036
|
|
|
*/ |
2037
|
|
|
function sd_get_scrollbars_input( $type = 'scrollbars', $overwrite = array() ) { |
|
|
|
|
2038
|
|
|
|
2039
|
|
|
$options = array( |
2040
|
|
|
'' => __( 'Default', 'ayecode-connect' ), |
2041
|
|
|
'scrollbars-ios' => __( 'IOS Style', 'ayecode-connect' ), |
2042
|
|
|
); |
2043
|
|
|
|
2044
|
|
|
$defaults = array( |
2045
|
|
|
'type' => 'select', |
2046
|
|
|
'title' => __( 'Scrollbars', 'ayecode-connect' ), |
2047
|
|
|
'options' => $options, |
2048
|
|
|
'default' => '', |
2049
|
|
|
'desc_tip' => true, |
2050
|
|
|
'group' => __( 'Wrapper Styles', 'ayecode-connect' ), |
2051
|
|
|
); |
2052
|
|
|
|
2053
|
|
|
$input = wp_parse_args( $overwrite, $defaults ); |
2054
|
|
|
|
2055
|
|
|
return $input; |
2056
|
|
|
} |
2057
|
|
|
|
2058
|
|
|
/** |
2059
|
|
|
* @param $type |
2060
|
|
|
* @param $overwrite |
2061
|
|
|
* |
2062
|
|
|
* @return array |
2063
|
|
|
*/ |
2064
|
|
|
function sd_get_new_window_input( $type = 'target', $overwrite = array() ) { |
|
|
|
|
2065
|
|
|
|
2066
|
|
|
$defaults = array( |
2067
|
|
|
'type' => 'checkbox', |
2068
|
|
|
'title' => __( 'Open in new window', 'ayecode-connect' ), |
2069
|
|
|
'default' => '', |
2070
|
|
|
'desc_tip' => true, |
2071
|
|
|
'group' => __( 'Link', 'ayecode-connect' ), |
2072
|
|
|
); |
2073
|
|
|
|
2074
|
|
|
$input = wp_parse_args( $overwrite, $defaults ); |
2075
|
|
|
|
2076
|
|
|
return $input; |
2077
|
|
|
} |
2078
|
|
|
|
2079
|
|
|
/** |
2080
|
|
|
* @param $type |
2081
|
|
|
* @param $overwrite |
2082
|
|
|
* |
2083
|
|
|
* @return array |
2084
|
|
|
*/ |
2085
|
|
|
function sd_get_nofollow_input( $type = 'nofollow', $overwrite = array() ) { |
|
|
|
|
2086
|
|
|
|
2087
|
|
|
$defaults = array( |
2088
|
|
|
'type' => 'checkbox', |
2089
|
|
|
'title' => __( 'Add nofollow', 'ayecode-connect' ), |
2090
|
|
|
'default' => '', |
2091
|
|
|
'desc_tip' => true, |
2092
|
|
|
'group' => __( 'Link', 'ayecode-connect' ), |
2093
|
|
|
); |
2094
|
|
|
|
2095
|
|
|
$input = wp_parse_args( $overwrite, $defaults ); |
2096
|
|
|
|
2097
|
|
|
return $input; |
2098
|
|
|
} |
2099
|
|
|
|
2100
|
|
|
/** |
2101
|
|
|
* @param $type |
2102
|
|
|
* @param $overwrite |
2103
|
|
|
* |
2104
|
|
|
* @return array |
2105
|
|
|
*/ |
2106
|
|
|
function sd_get_attributes_input( $type = 'attributes', $overwrite = array() ) { |
|
|
|
|
2107
|
|
|
|
2108
|
|
|
$defaults = array( |
2109
|
|
|
'type' => 'text', |
2110
|
|
|
'title' => __( 'Custom Attributes', 'ayecode-connect' ), |
2111
|
|
|
'value' => '', |
2112
|
|
|
'default' => '', |
2113
|
|
|
'placeholder' => 'key|value,key2|value2', |
2114
|
|
|
'desc_tip' => true, |
2115
|
|
|
'group' => __( 'Link', 'ayecode-connect' ), |
2116
|
|
|
); |
2117
|
|
|
|
2118
|
|
|
$input = wp_parse_args( $overwrite, $defaults ); |
2119
|
|
|
|
2120
|
|
|
return $input; |
2121
|
|
|
} |
2122
|
|
|
|
2123
|
|
|
/** |
2124
|
|
|
* @param $args |
2125
|
|
|
* |
2126
|
|
|
* @return string |
2127
|
|
|
*/ |
2128
|
|
|
function sd_build_attributes_string_escaped( $args ) { |
2129
|
|
|
global $aui_bs5; |
2130
|
|
|
|
2131
|
|
|
$attributes = array(); |
2132
|
|
|
$string_escaped = ''; |
2133
|
|
|
|
2134
|
|
|
if ( ! empty( $args['custom'] ) ) { |
2135
|
|
|
$attributes = sd_parse_custom_attributes($args['custom']); |
2136
|
|
|
} |
2137
|
|
|
|
2138
|
|
|
// new window |
2139
|
|
|
if ( ! empty( $args['new_window'] ) ) { |
2140
|
|
|
$attributes['target'] = '_blank'; |
2141
|
|
|
} |
2142
|
|
|
|
2143
|
|
|
// nofollow |
2144
|
|
|
if ( ! empty( $args['nofollow'] ) ) { |
2145
|
|
|
$attributes['rel'] = isset($attributes['rel']) ? $attributes['rel'] . ' nofollow' : 'nofollow'; |
2146
|
|
|
} |
2147
|
|
|
|
2148
|
|
|
if(!empty($attributes )){ |
2149
|
|
|
foreach ( $attributes as $key => $val ) { |
2150
|
|
|
$string_escaped .= esc_attr($key) . '="' . esc_attr($val) . '" '; |
2151
|
|
|
} |
2152
|
|
|
} |
2153
|
|
|
|
2154
|
|
|
return $string_escaped; |
2155
|
|
|
} |
2156
|
|
|
|
2157
|
|
|
/** |
2158
|
|
|
* @info borrowed from elementor |
2159
|
|
|
* |
2160
|
|
|
* @param $attributes_string |
2161
|
|
|
* @param $delimiter |
2162
|
|
|
* |
2163
|
|
|
* @return array |
2164
|
|
|
*/ |
2165
|
|
|
function sd_parse_custom_attributes( $attributes_string, $delimiter = ',' ) { |
2166
|
|
|
$attributes = explode( $delimiter, $attributes_string ); |
2167
|
|
|
$result = []; |
2168
|
|
|
|
2169
|
|
|
foreach ( $attributes as $attribute ) { |
2170
|
|
|
$attr_key_value = explode( '|', $attribute ); |
2171
|
|
|
|
2172
|
|
|
$attr_key = mb_strtolower( $attr_key_value[0] ); |
2173
|
|
|
|
2174
|
|
|
// Remove any not allowed characters. |
2175
|
|
|
preg_match( '/[-_a-z0-9]+/', $attr_key, $attr_key_matches ); |
2176
|
|
|
|
2177
|
|
|
if ( empty( $attr_key_matches[0] ) ) { |
2178
|
|
|
continue; |
2179
|
|
|
} |
2180
|
|
|
|
2181
|
|
|
$attr_key = $attr_key_matches[0]; |
2182
|
|
|
|
2183
|
|
|
// Avoid Javascript events and unescaped href. |
2184
|
|
|
if ( 'href' === $attr_key || 'on' === substr( $attr_key, 0, 2 ) ) { |
2185
|
|
|
continue; |
2186
|
|
|
} |
2187
|
|
|
|
2188
|
|
|
if ( isset( $attr_key_value[1] ) ) { |
2189
|
|
|
$attr_value = trim( $attr_key_value[1] ); |
2190
|
|
|
} else { |
2191
|
|
|
$attr_value = ''; |
2192
|
|
|
} |
2193
|
|
|
|
2194
|
|
|
$result[ $attr_key ] = $attr_value; |
2195
|
|
|
} |
2196
|
|
|
|
2197
|
|
|
return $result; |
2198
|
|
|
} |
2199
|
|
|
|
2200
|
|
|
/** |
2201
|
|
|
* Build AUI classes from settings. |
2202
|
|
|
* |
2203
|
|
|
* @param $args |
2204
|
|
|
* |
2205
|
|
|
* @return string |
2206
|
|
|
* @todo find best way to use px- py- or general p- |
2207
|
|
|
*/ |
2208
|
|
|
function sd_build_aui_class( $args ) { |
2209
|
|
|
global $aui_bs5; |
2210
|
|
|
|
2211
|
|
|
$classes = array(); |
2212
|
|
|
|
2213
|
|
|
if ( $aui_bs5 ) { |
2214
|
|
|
$p_ml = 'ms-'; |
2215
|
|
|
$p_mr = 'me-'; |
2216
|
|
|
|
2217
|
|
|
$p_pl = 'ps-'; |
2218
|
|
|
$p_pr = 'pe-'; |
2219
|
|
|
} else { |
2220
|
|
|
$p_ml = 'ml-'; |
2221
|
|
|
$p_mr = 'mr-'; |
2222
|
|
|
|
2223
|
|
|
$p_pl = 'pl-'; |
2224
|
|
|
$p_pr = 'pr-'; |
2225
|
|
|
} |
2226
|
|
|
|
2227
|
|
|
// margins. |
2228
|
|
|
if ( isset( $args['mt'] ) && $args['mt'] !== '' ) { |
2229
|
|
|
$classes[] = 'mt-' . sanitize_html_class( $args['mt'] ); |
2230
|
|
|
$mt = $args['mt']; |
2231
|
|
|
} else { |
2232
|
|
|
$mt = null; |
2233
|
|
|
} |
2234
|
|
|
if ( isset( $args['mr'] ) && $args['mr'] !== '' ) { |
2235
|
|
|
$classes[] = $p_mr . sanitize_html_class( $args['mr'] ); |
2236
|
|
|
$mr = $args['mr']; |
2237
|
|
|
} else { |
2238
|
|
|
$mr = null; |
2239
|
|
|
} |
2240
|
|
|
if ( isset( $args['mb'] ) && $args['mb'] !== '' ) { |
2241
|
|
|
$classes[] = 'mb-' . sanitize_html_class( $args['mb'] ); |
2242
|
|
|
$mb = $args['mb']; |
2243
|
|
|
} else { |
2244
|
|
|
$mb = null; |
2245
|
|
|
} |
2246
|
|
|
if ( isset( $args['ml'] ) && $args['ml'] !== '' ) { |
2247
|
|
|
$classes[] = $p_ml . sanitize_html_class( $args['ml'] ); |
2248
|
|
|
$ml = $args['ml']; |
2249
|
|
|
} else { |
2250
|
|
|
$ml = null; |
2251
|
|
|
} |
2252
|
|
|
|
2253
|
|
|
// margins tablet. |
2254
|
|
|
if ( isset( $args['mt_md'] ) && $args['mt_md'] !== '' ) { |
2255
|
|
|
$classes[] = 'mt-md-' . sanitize_html_class( $args['mt_md'] ); |
2256
|
|
|
$mt_md = $args['mt_md']; |
2257
|
|
|
} else { |
2258
|
|
|
$mt_md = null; |
2259
|
|
|
} |
2260
|
|
|
if ( isset( $args['mr_md'] ) && $args['mr_md'] !== '' ) { |
2261
|
|
|
$classes[] = $p_mr . 'md-' . sanitize_html_class( $args['mr_md'] ); |
2262
|
|
|
$mt_md = $args['mr_md']; |
2263
|
|
|
} else { |
2264
|
|
|
$mr_md = null; |
2265
|
|
|
} |
2266
|
|
|
if ( isset( $args['mb_md'] ) && $args['mb_md'] !== '' ) { |
2267
|
|
|
$classes[] = 'mb-md-' . sanitize_html_class( $args['mb_md'] ); |
2268
|
|
|
$mt_md = $args['mb_md']; |
2269
|
|
|
} else { |
2270
|
|
|
$mb_md = null; |
2271
|
|
|
} |
2272
|
|
|
if ( isset( $args['ml_md'] ) && $args['ml_md'] !== '' ) { |
2273
|
|
|
$classes[] = $p_ml . 'md-' . sanitize_html_class( $args['ml_md'] ); |
2274
|
|
|
$mt_md = $args['ml_md']; |
2275
|
|
|
} else { |
2276
|
|
|
$ml_md = null; |
2277
|
|
|
} |
2278
|
|
|
|
2279
|
|
|
// margins desktop. |
2280
|
|
|
if ( isset( $args['mt_lg'] ) && $args['mt_lg'] !== '' ) { |
2281
|
|
|
if ( $mt == null && $mt_md == null ) { |
2282
|
|
|
$classes[] = 'mt-' . sanitize_html_class( $args['mt_lg'] ); |
2283
|
|
|
} else { |
2284
|
|
|
$classes[] = 'mt-lg-' . sanitize_html_class( $args['mt_lg'] ); |
2285
|
|
|
} |
2286
|
|
|
} |
2287
|
|
|
if ( isset( $args['mr_lg'] ) && $args['mr_lg'] !== '' ) { |
2288
|
|
|
if ( $mr == null && $mr_md == null ) { |
|
|
|
|
2289
|
|
|
$classes[] = $p_mr . sanitize_html_class( $args['mr_lg'] ); |
2290
|
|
|
} else { |
2291
|
|
|
$classes[] = $p_mr . 'lg-' . sanitize_html_class( $args['mr_lg'] ); |
2292
|
|
|
} |
2293
|
|
|
} |
2294
|
|
|
if ( isset( $args['mb_lg'] ) && $args['mb_lg'] !== '' ) { |
2295
|
|
|
if ( $mb == null && $mb_md == null ) { |
|
|
|
|
2296
|
|
|
$classes[] = 'mb-' . sanitize_html_class( $args['mb_lg'] ); |
2297
|
|
|
} else { |
2298
|
|
|
$classes[] = 'mb-lg-' . sanitize_html_class( $args['mb_lg'] ); |
2299
|
|
|
} |
2300
|
|
|
} |
2301
|
|
|
if ( isset( $args['ml_lg'] ) && $args['ml_lg'] !== '' ) { |
2302
|
|
|
if ( $ml == null && $ml_md == null ) { |
|
|
|
|
2303
|
|
|
$classes[] = $p_ml . sanitize_html_class( $args['ml_lg'] ); |
2304
|
|
|
} else { |
2305
|
|
|
$classes[] = $p_ml . 'lg-' . sanitize_html_class( $args['ml_lg'] ); |
2306
|
|
|
} |
2307
|
|
|
} |
2308
|
|
|
|
2309
|
|
|
// padding. |
2310
|
|
|
if ( isset( $args['pt'] ) && $args['pt'] !== '' ) { |
2311
|
|
|
$classes[] = 'pt-' . sanitize_html_class( $args['pt'] ); |
2312
|
|
|
$pt = $args['pt']; |
2313
|
|
|
} else { |
2314
|
|
|
$pt = null; |
2315
|
|
|
} |
2316
|
|
|
if ( isset( $args['pr'] ) && $args['pr'] !== '' ) { |
2317
|
|
|
$classes[] = $p_pr . sanitize_html_class( $args['pr'] ); |
2318
|
|
|
$pr = $args['pr']; |
2319
|
|
|
} else { |
2320
|
|
|
$pr = null; |
2321
|
|
|
} |
2322
|
|
|
if ( isset( $args['pb'] ) && $args['pb'] !== '' ) { |
2323
|
|
|
$classes[] = 'pb-' . sanitize_html_class( $args['pb'] ); |
2324
|
|
|
$pb = $args['pb']; |
2325
|
|
|
} else { |
2326
|
|
|
$pb = null; |
2327
|
|
|
} |
2328
|
|
|
if ( isset( $args['pl'] ) && $args['pl'] !== '' ) { |
2329
|
|
|
$classes[] = $p_pl . sanitize_html_class( $args['pl'] ); |
2330
|
|
|
$pl = $args['pl']; |
2331
|
|
|
} else { |
2332
|
|
|
$pl = null; |
2333
|
|
|
} |
2334
|
|
|
|
2335
|
|
|
// padding tablet. |
2336
|
|
|
if ( isset( $args['pt_md'] ) && $args['pt_md'] !== '' ) { |
2337
|
|
|
$classes[] = 'pt-md-' . sanitize_html_class( $args['pt_md'] ); |
2338
|
|
|
$pt_md = $args['pt_md']; |
2339
|
|
|
} else { |
2340
|
|
|
$pt_md = null; |
2341
|
|
|
} |
2342
|
|
|
if ( isset( $args['pr_md'] ) && $args['pr_md'] !== '' ) { |
2343
|
|
|
$classes[] = $p_pr . 'md-' . sanitize_html_class( $args['pr_md'] ); |
2344
|
|
|
$pr_md = $args['pr_md']; |
2345
|
|
|
} else { |
2346
|
|
|
$pr_md = null; |
2347
|
|
|
} |
2348
|
|
|
if ( isset( $args['pb_md'] ) && $args['pb_md'] !== '' ) { |
2349
|
|
|
$classes[] = 'pb-md-' . sanitize_html_class( $args['pb_md'] ); |
2350
|
|
|
$pb_md = $args['pb_md']; |
2351
|
|
|
} else { |
2352
|
|
|
$pb_md = null; |
2353
|
|
|
} |
2354
|
|
|
if ( isset( $args['pl_md'] ) && $args['pl_md'] !== '' ) { |
2355
|
|
|
$classes[] = $p_pl . 'md-' . sanitize_html_class( $args['pl_md'] ); |
2356
|
|
|
$pl_md = $args['pl_md']; |
2357
|
|
|
} else { |
2358
|
|
|
$pl_md = null; |
2359
|
|
|
} |
2360
|
|
|
|
2361
|
|
|
// padding desktop. |
2362
|
|
|
if ( isset( $args['pt_lg'] ) && $args['pt_lg'] !== '' ) { |
2363
|
|
|
if ( $pt == null && $pt_md == null ) { |
2364
|
|
|
$classes[] = 'pt-' . sanitize_html_class( $args['pt_lg'] ); |
2365
|
|
|
} else { |
2366
|
|
|
$classes[] = 'pt-lg-' . sanitize_html_class( $args['pt_lg'] ); |
2367
|
|
|
} |
2368
|
|
|
} |
2369
|
|
|
if ( isset( $args['pr_lg'] ) && $args['pr_lg'] !== '' ) { |
2370
|
|
|
if ( $pr == null && $pr_md == null ) { |
2371
|
|
|
$classes[] = $p_pr . sanitize_html_class( $args['pr_lg'] ); |
2372
|
|
|
} else { |
2373
|
|
|
$classes[] = $p_pr . 'lg-' . sanitize_html_class( $args['pr_lg'] ); |
2374
|
|
|
} |
2375
|
|
|
} |
2376
|
|
|
if ( isset( $args['pb_lg'] ) && $args['pb_lg'] !== '' ) { |
2377
|
|
|
if ( $pb == null && $pb_md == null ) { |
2378
|
|
|
$classes[] = 'pb-' . sanitize_html_class( $args['pb_lg'] ); |
2379
|
|
|
} else { |
2380
|
|
|
$classes[] = 'pb-lg-' . sanitize_html_class( $args['pb_lg'] ); |
2381
|
|
|
} |
2382
|
|
|
} |
2383
|
|
|
if ( isset( $args['pl_lg'] ) && $args['pl_lg'] !== '' ) { |
2384
|
|
|
if ( $pl == null && $pl_md == null ) { |
2385
|
|
|
$classes[] = $p_pl . sanitize_html_class( $args['pl_lg'] ); |
2386
|
|
|
} else { |
2387
|
|
|
$classes[] = $p_pl . 'lg-' . sanitize_html_class( $args['pl_lg'] ); |
2388
|
|
|
} |
2389
|
|
|
} |
2390
|
|
|
|
2391
|
|
|
// row cols, mobile, tablet, desktop |
2392
|
|
|
if ( ! empty( $args['row_cols'] ) && $args['row_cols'] !== '' ) { |
2393
|
|
|
$classes[] = sanitize_html_class( 'row-cols-' . $args['row_cols'] ); |
2394
|
|
|
$row_cols = $args['row_cols']; |
2395
|
|
|
} else { |
2396
|
|
|
$row_cols = null; |
2397
|
|
|
} |
2398
|
|
|
if ( ! empty( $args['row_cols_md'] ) && $args['row_cols_md'] !== '' ) { |
2399
|
|
|
$classes[] = sanitize_html_class( 'row-cols-md-' . $args['row_cols_md'] ); |
2400
|
|
|
$row_cols_md = $args['row_cols_md']; |
2401
|
|
|
} else { |
2402
|
|
|
$row_cols_md = null; |
2403
|
|
|
} |
2404
|
|
|
if ( ! empty( $args['row_cols_lg'] ) && $args['row_cols_lg'] !== '' ) { |
2405
|
|
|
if ( $row_cols == null && $row_cols_md == null ) { |
2406
|
|
|
$classes[] = sanitize_html_class( 'row-cols-' . $args['row_cols_lg'] ); |
2407
|
|
|
} else { |
2408
|
|
|
$classes[] = sanitize_html_class( 'row-cols-lg-' . $args['row_cols_lg'] ); |
2409
|
|
|
} |
2410
|
|
|
} |
2411
|
|
|
|
2412
|
|
|
// columns , mobile, tablet, desktop |
2413
|
|
|
if ( ! empty( $args['col'] ) && $args['col'] !== '' ) { |
2414
|
|
|
$classes[] = sanitize_html_class( 'col-' . $args['col'] ); |
2415
|
|
|
$col = $args['col']; |
2416
|
|
|
} else { |
2417
|
|
|
$col = null; |
2418
|
|
|
} |
2419
|
|
|
if ( ! empty( $args['col_md'] ) && $args['col_md'] !== '' ) { |
2420
|
|
|
$classes[] = sanitize_html_class( 'col-md-' . $args['col_md'] ); |
2421
|
|
|
$col_md = $args['col_md']; |
2422
|
|
|
} else { |
2423
|
|
|
$col_md = null; |
2424
|
|
|
} |
2425
|
|
|
if ( ! empty( $args['col_lg'] ) && $args['col_lg'] !== '' ) { |
2426
|
|
|
if ( $col == null && $col_md == null ) { |
2427
|
|
|
$classes[] = sanitize_html_class( 'col-' . $args['col_lg'] ); |
2428
|
|
|
} else { |
2429
|
|
|
$classes[] = sanitize_html_class( 'col-lg-' . $args['col_lg'] ); |
2430
|
|
|
} |
2431
|
|
|
} |
2432
|
|
|
|
2433
|
|
|
// border |
2434
|
|
|
if ( isset( $args['border'] ) && ( $args['border'] == 'none' || $args['border'] === '0' || $args['border'] === 0 ) ) { |
2435
|
|
|
$classes[] = 'border-0'; |
2436
|
|
|
} elseif ( ! empty( $args['border'] ) ) { |
2437
|
|
|
$border_class = 'border'; |
2438
|
|
|
if ( ! empty( $args['border_type'] ) && strpos( $args['border_type'], '-0' ) === false ) { |
2439
|
|
|
$border_class = ''; |
2440
|
|
|
} |
2441
|
|
|
$classes[] = $border_class . ' border-' . sanitize_html_class( $args['border'] ); |
2442
|
|
|
} |
2443
|
|
|
|
2444
|
|
|
// border radius type |
2445
|
|
|
if ( ! empty( $args['rounded'] ) ) { |
2446
|
|
|
$classes[] = sanitize_html_class( $args['rounded'] ); |
2447
|
|
|
} |
2448
|
|
|
|
2449
|
|
|
// border radius size BS4 |
2450
|
|
|
if ( isset( $args['rounded_size'] ) && in_array( $args['rounded_size'], array( 'sm', 'lg' ) ) ) { |
2451
|
|
|
$classes[] = 'rounded-' . sanitize_html_class( $args['rounded_size'] ); |
2452
|
|
|
// if we set a size then we need to remove "rounded" if set |
2453
|
|
|
if ( ( $key = array_search( 'rounded', $classes ) ) !== false ) { |
2454
|
|
|
unset( $classes[ $key ] ); |
2455
|
|
|
} |
2456
|
|
|
} else { |
2457
|
|
|
|
2458
|
|
|
// border radius size , mobile, tablet, desktop |
2459
|
|
|
if ( isset( $args['rounded_size'] ) && $args['rounded_size'] !== '' ) { |
2460
|
|
|
$classes[] = sanitize_html_class( 'rounded-' . $args['rounded_size'] ); |
2461
|
|
|
$rounded_size = $args['rounded_size']; |
2462
|
|
|
} else { |
2463
|
|
|
$rounded_size = null; |
2464
|
|
|
} |
2465
|
|
|
if ( isset( $args['rounded_size_md'] ) && $args['rounded_size_md'] !== '' ) { |
2466
|
|
|
$classes[] = sanitize_html_class( 'rounded-md-' . $args['rounded_size_md'] ); |
2467
|
|
|
$rounded_size_md = $args['rounded_size_md']; |
2468
|
|
|
} else { |
2469
|
|
|
$rounded_size_md = null; |
2470
|
|
|
} |
2471
|
|
|
if ( isset( $args['rounded_size_lg'] ) && $args['rounded_size_lg'] !== '' ) { |
2472
|
|
|
if ( $rounded_size == null && $rounded_size_md == null ) { |
2473
|
|
|
$classes[] = sanitize_html_class( 'rounded-' . $args['rounded_size_lg'] ); |
2474
|
|
|
} else { |
2475
|
|
|
$classes[] = sanitize_html_class( 'rounded-lg-' . $args['rounded_size_lg'] ); |
2476
|
|
|
} |
2477
|
|
|
} |
2478
|
|
|
} |
2479
|
|
|
|
2480
|
|
|
// shadow |
2481
|
|
|
//if ( !empty( $args['shadow'] ) ) { $classes[] = sanitize_html_class($args['shadow']); } |
2482
|
|
|
|
2483
|
|
|
// background |
2484
|
|
|
if ( ! empty( $args['bg'] ) ) { |
2485
|
|
|
$classes[] = 'bg-' . sanitize_html_class( $args['bg'] ); |
2486
|
|
|
} |
2487
|
|
|
|
2488
|
|
|
// text_color |
2489
|
|
|
if ( ! empty( $args['text_color'] ) ) { |
2490
|
|
|
$classes[] = 'text-' . sanitize_html_class( $args['text_color'] ); |
2491
|
|
|
} |
2492
|
|
|
|
2493
|
|
|
// text_align |
2494
|
|
|
if ( ! empty( $args['text_justify'] ) ) { |
2495
|
|
|
$classes[] = 'text-justify'; |
2496
|
|
|
} else { |
2497
|
|
|
if ( ! empty( $args['text_align'] ) ) { |
2498
|
|
|
$classes[] = sanitize_html_class( $args['text_align'] ); |
2499
|
|
|
$text_align = $args['text_align']; |
2500
|
|
|
} else { |
2501
|
|
|
$text_align = null; |
2502
|
|
|
} |
2503
|
|
|
if ( ! empty( $args['text_align_md'] ) && $args['text_align_md'] !== '' ) { |
2504
|
|
|
$classes[] = sanitize_html_class( $args['text_align_md'] ); |
2505
|
|
|
$text_align_md = $args['text_align_md']; |
2506
|
|
|
} else { |
2507
|
|
|
$text_align_md = null; |
2508
|
|
|
} |
2509
|
|
|
if ( ! empty( $args['text_align_lg'] ) && $args['text_align_lg'] !== '' ) { |
2510
|
|
|
if ( $text_align == null && $text_align_md == null ) { |
2511
|
|
|
$classes[] = sanitize_html_class( str_replace( '-lg', '', $args['text_align_lg'] ) ); |
2512
|
|
|
} else { |
2513
|
|
|
$classes[] = sanitize_html_class( $args['text_align_lg'] ); |
2514
|
|
|
} |
2515
|
|
|
} |
2516
|
|
|
} |
2517
|
|
|
|
2518
|
|
|
// display |
2519
|
|
|
if ( ! empty( $args['display'] ) ) { |
2520
|
|
|
$classes[] = sanitize_html_class( $args['display'] ); |
2521
|
|
|
$display = $args['display']; |
2522
|
|
|
} else { |
2523
|
|
|
$display = null; |
2524
|
|
|
} |
2525
|
|
|
if ( ! empty( $args['display_md'] ) && $args['display_md'] !== '' ) { |
2526
|
|
|
$classes[] = sanitize_html_class( $args['display_md'] ); |
2527
|
|
|
$display_md = $args['display_md']; |
2528
|
|
|
} else { |
2529
|
|
|
$display_md = null; |
2530
|
|
|
} |
2531
|
|
|
if ( ! empty( $args['display_lg'] ) && $args['display_lg'] !== '' ) { |
2532
|
|
|
if ( $display == null && $display_md == null ) { |
2533
|
|
|
$classes[] = sanitize_html_class( str_replace( '-lg', '', $args['display_lg'] ) ); |
2534
|
|
|
} else { |
2535
|
|
|
$classes[] = sanitize_html_class( $args['display_lg'] ); |
2536
|
|
|
} |
2537
|
|
|
} |
2538
|
|
|
|
2539
|
|
|
// bgtus - background transparent until scroll |
2540
|
|
|
if ( ! empty( $args['bgtus'] ) ) { |
2541
|
|
|
$classes[] = sanitize_html_class( 'bg-transparent-until-scroll' ); |
2542
|
|
|
} |
2543
|
|
|
|
2544
|
|
|
// cscos - change color scheme on scroll |
2545
|
|
|
if ( ! empty( $args['bgtus'] ) && ! empty( $args['cscos'] ) ) { |
2546
|
|
|
$classes[] = sanitize_html_class( 'color-scheme-flip-on-scroll' ); |
2547
|
|
|
} |
2548
|
|
|
|
2549
|
|
|
// hover animations |
2550
|
|
|
if ( ! empty( $args['hover_animations'] ) ) { |
2551
|
|
|
$classes[] = sd_sanitize_html_classes( str_replace( ',', ' ', $args['hover_animations'] ) ); |
2552
|
|
|
} |
2553
|
|
|
|
2554
|
|
|
// absolute_position |
2555
|
|
|
if ( ! empty( $args['absolute_position'] ) ) { |
2556
|
|
|
if ( 'top-left' === $args['absolute_position'] ) { |
2557
|
|
|
$classes[] = 'start-0 top-0'; |
2558
|
|
|
} elseif ( 'top-center' === $args['absolute_position'] ) { |
2559
|
|
|
$classes[] = 'start-50 top-0 translate-middle'; |
2560
|
|
|
} elseif ( 'top-right' === $args['absolute_position'] ) { |
2561
|
|
|
$classes[] = 'end-0 top-0'; |
2562
|
|
|
} elseif ( 'center-left' === $args['absolute_position'] ) { |
2563
|
|
|
$classes[] = 'start-0 top-50'; |
2564
|
|
|
} elseif ( 'center' === $args['absolute_position'] ) { |
2565
|
|
|
$classes[] = 'start-50 top-50 translate-middle'; |
2566
|
|
|
} elseif ( 'center-right' === $args['absolute_position'] ) { |
2567
|
|
|
$classes[] = 'end-0 top-50'; |
2568
|
|
|
} elseif ( 'bottom-left' === $args['absolute_position'] ) { |
2569
|
|
|
$classes[] = 'start-0 bottom-0'; |
2570
|
|
|
} elseif ( 'bottom-center' === $args['absolute_position'] ) { |
2571
|
|
|
$classes[] = 'start-50 bottom-0 translate-middle'; |
2572
|
|
|
} elseif ( 'bottom-right' === $args['absolute_position'] ) { |
2573
|
|
|
$classes[] = 'end-0 bottom-0'; |
2574
|
|
|
} |
2575
|
|
|
} |
2576
|
|
|
|
2577
|
|
|
// build classes from build keys |
2578
|
|
|
$build_keys = sd_get_class_build_keys(); |
|
|
|
|
2579
|
|
|
if ( ! empty( $build_keys ) ) { |
2580
|
|
|
foreach ( $build_keys as $key ) { |
|
|
|
|
2581
|
|
|
|
2582
|
|
|
if ( substr( $key, -4 ) == '-MTD' ) { |
2583
|
|
|
|
2584
|
|
|
$k = str_replace( '-MTD', '', $key ); |
2585
|
|
|
|
2586
|
|
|
// Mobile, Tablet, Desktop |
2587
|
|
|
if ( ! empty( $args[ $k ] ) && $args[ $k ] !== '' ) { |
2588
|
|
|
$classes[] = sanitize_html_class( $args[ $k ] ); |
2589
|
|
|
$v = $args[ $k ]; |
2590
|
|
|
} else { |
2591
|
|
|
$v = null; |
2592
|
|
|
} |
2593
|
|
|
if ( ! empty( $args[ $k . '_md' ] ) && $args[ $k . '_md' ] !== '' ) { |
2594
|
|
|
$classes[] = sanitize_html_class( $args[ $k . '_md' ] ); |
2595
|
|
|
$v_md = $args[ $k . '_md' ]; |
2596
|
|
|
} else { |
2597
|
|
|
$v_md = null; |
2598
|
|
|
} |
2599
|
|
|
if ( ! empty( $args[ $k . '_lg' ] ) && $args[ $k . '_lg' ] !== '' ) { |
2600
|
|
|
if ( $v == null && $v_md == null ) { |
2601
|
|
|
$classes[] = sanitize_html_class( str_replace( '-lg', '', $args[ $k . '_lg' ] ) ); |
2602
|
|
|
} else { |
2603
|
|
|
$classes[] = sanitize_html_class( $args[ $k . '_lg' ] ); |
2604
|
|
|
} |
2605
|
|
|
} |
2606
|
|
|
} else { |
2607
|
|
|
if ( $key == 'font_size' && ! empty( $args[ $key ] ) && $args[ $key ] == 'custom' ) { |
2608
|
|
|
continue; |
2609
|
|
|
} |
2610
|
|
|
if ( ! empty( $args[ $key ] ) ) { |
2611
|
|
|
$classes[] = sd_sanitize_html_classes( $args[ $key ] ); |
2612
|
|
|
} |
2613
|
|
|
} |
2614
|
|
|
} |
2615
|
|
|
} |
2616
|
|
|
|
2617
|
|
|
if ( ! empty( $classes ) ) { |
2618
|
|
|
$classes = array_unique( array_filter( array_map( 'trim', $classes ) ) ); |
2619
|
|
|
} |
2620
|
|
|
|
2621
|
|
|
return implode( ' ', $classes ); |
2622
|
|
|
} |
2623
|
|
|
|
2624
|
|
|
/** |
2625
|
|
|
* Build Style output from arguments. |
2626
|
|
|
* |
2627
|
|
|
* @param $args |
2628
|
|
|
* |
2629
|
|
|
* @return array |
2630
|
|
|
*/ |
2631
|
|
|
function sd_build_aui_styles( $args ) { |
2632
|
|
|
|
2633
|
|
|
$styles = array(); |
2634
|
|
|
|
2635
|
|
|
// background color |
2636
|
|
|
if ( ! empty( $args['bg'] ) && $args['bg'] !== '' ) { |
2637
|
|
|
if ( $args['bg'] == 'custom-color' ) { |
2638
|
|
|
$styles['background-color'] = $args['bg_color']; |
2639
|
|
|
} elseif ( $args['bg'] == 'custom-gradient' ) { |
2640
|
|
|
$styles['background-image'] = $args['bg_gradient']; |
2641
|
|
|
|
2642
|
|
|
// use background on text. |
2643
|
|
|
if ( ! empty( $args['bg_on_text'] ) && $args['bg_on_text'] ) { |
2644
|
|
|
$styles['background-clip'] = 'text'; |
2645
|
|
|
$styles['-webkit-background-clip'] = 'text'; |
2646
|
|
|
$styles['text-fill-color'] = 'transparent'; |
2647
|
|
|
$styles['-webkit-text-fill-color'] = 'transparent'; |
2648
|
|
|
} |
2649
|
|
|
} |
2650
|
|
|
} |
2651
|
|
|
|
2652
|
|
|
if ( ! empty( $args['bg_image'] ) && $args['bg_image'] !== '' ) { |
2653
|
|
|
$hasImage = true; |
2654
|
|
|
if ( ! empty( $styles['background-color'] ) && $args['bg'] == 'custom-color' ) { |
2655
|
|
|
$styles['background-image'] = 'url(' . $args['bg_image'] . ')'; |
2656
|
|
|
$styles['background-blend-mode'] = 'overlay'; |
2657
|
|
|
} elseif ( ! empty( $styles['background-image'] ) && $args['bg'] == 'custom-gradient' ) { |
2658
|
|
|
$styles['background-image'] .= ',url(' . $args['bg_image'] . ')'; |
2659
|
|
|
} elseif ( ! empty( $args['bg'] ) && $args['bg'] != '' && $args['bg'] != 'transparent' ) { |
2660
|
|
|
// do nothing as we alreay have a preset |
2661
|
|
|
$hasImage = false; |
2662
|
|
|
} else { |
2663
|
|
|
$styles['background-image'] = 'url(' . $args['bg_image'] . ')'; |
2664
|
|
|
} |
2665
|
|
|
|
2666
|
|
|
if ( $hasImage ) { |
2667
|
|
|
$styles['background-size'] = 'cover'; |
2668
|
|
|
|
2669
|
|
|
if ( ! empty( $args['bg_image_fixed'] ) && $args['bg_image_fixed'] ) { |
2670
|
|
|
$styles['background-attachment'] = 'fixed'; |
2671
|
|
|
} |
2672
|
|
|
} |
2673
|
|
|
|
2674
|
|
|
if ( $hasImage && ! empty( $args['bg_image_xy'] ) && ! empty( $args['bg_image_xy']['x'] ) ) { |
2675
|
|
|
$styles['background-position'] = ( $args['bg_image_xy']['x'] * 100 ) . '% ' . ( $args['bg_image_xy']['y'] * 100 ) . '%'; |
2676
|
|
|
} |
2677
|
|
|
} |
2678
|
|
|
|
2679
|
|
|
// sticky offset top |
2680
|
|
|
if ( ! empty( $args['sticky_offset_top'] ) && $args['sticky_offset_top'] !== '' ) { |
2681
|
|
|
$styles['top'] = absint( $args['sticky_offset_top'] ); |
2682
|
|
|
} |
2683
|
|
|
|
2684
|
|
|
// sticky offset bottom |
2685
|
|
|
if ( ! empty( $args['sticky_offset_bottom'] ) && $args['sticky_offset_bottom'] !== '' ) { |
2686
|
|
|
$styles['bottom'] = absint( $args['sticky_offset_bottom'] ); |
2687
|
|
|
} |
2688
|
|
|
|
2689
|
|
|
// font size |
2690
|
|
|
if ( ! empty( $args['font_size_custom'] ) && $args['font_size_custom'] !== '' ) { |
2691
|
|
|
$styles['font-size'] = (float) $args['font_size_custom'] . 'rem'; |
2692
|
|
|
} |
2693
|
|
|
|
2694
|
|
|
// font color |
2695
|
|
|
if ( ! empty( $args['text_color_custom'] ) && $args['text_color_custom'] !== '' ) { |
2696
|
|
|
$styles['color'] = esc_attr( $args['text_color_custom'] ); |
2697
|
|
|
} |
2698
|
|
|
|
2699
|
|
|
// font line height |
2700
|
|
|
if ( ! empty( $args['font_line_height'] ) && $args['font_line_height'] !== '' ) { |
2701
|
|
|
$styles['line-height'] = esc_attr( $args['font_line_height'] ); |
2702
|
|
|
} |
2703
|
|
|
|
2704
|
|
|
// max height |
2705
|
|
|
if ( ! empty( $args['max_height'] ) && $args['max_height'] !== '' ) { |
2706
|
|
|
$styles['max-height'] = esc_attr( $args['max_height'] ); |
2707
|
|
|
} |
2708
|
|
|
|
2709
|
|
|
$style_string = ''; |
2710
|
|
|
if ( ! empty( $styles ) ) { |
2711
|
|
|
foreach ( $styles as $key => $val ) { |
2712
|
|
|
$style_string .= esc_attr( $key ) . ':' . esc_attr( $val ) . ';'; |
2713
|
|
|
} |
2714
|
|
|
} |
2715
|
|
|
|
2716
|
|
|
return $style_string; |
|
|
|
|
2717
|
|
|
|
2718
|
|
|
} |
2719
|
|
|
|
2720
|
|
|
/** |
2721
|
|
|
* Build the hover styles from args. |
2722
|
|
|
* |
2723
|
|
|
* @param $args |
2724
|
|
|
* @param $is_preview |
2725
|
|
|
* |
2726
|
|
|
* @return string |
2727
|
|
|
*/ |
2728
|
|
|
function sd_build_hover_styles( $args, $is_preview = false ) { |
2729
|
|
|
$rules = ''; |
2730
|
|
|
// text color |
2731
|
|
|
if ( ! empty( $args['styleid'] ) ) { |
2732
|
|
|
$styleid = $is_preview ? 'html .editor-styles-wrapper .' . esc_attr( $args['styleid'] ) : 'html .' . esc_attr( $args['styleid'] ); |
2733
|
|
|
|
2734
|
|
|
// text |
2735
|
|
|
if ( ! empty( $args['text_color_hover'] ) ) { |
2736
|
|
|
$key = 'custom' === $args['text_color_hover'] && ! empty( $args['text_color_hover_custom'] ) ? 'text_color_hover_custom' : 'text_color_hover'; |
2737
|
|
|
$color = sd_get_color_from_var( $args[ $key ] ); |
2738
|
|
|
$rules .= $styleid . ':hover {color: ' . $color . ' !important;} '; |
2739
|
|
|
} |
2740
|
|
|
|
2741
|
|
|
// bg |
2742
|
|
|
if ( ! empty( $args['bg_hover'] ) ) { |
2743
|
|
|
if ( 'custom-gradient' === $args['bg_hover'] ) { |
2744
|
|
|
$color = $args['bg_hover_gradient']; |
2745
|
|
|
$rules .= $styleid . ':hover {background-image: ' . $color . ' !important;} '; |
2746
|
|
|
$rules .= $styleid . '.btn:hover {border-color: transparent !important;} '; |
2747
|
|
|
} else { |
2748
|
|
|
$key = 'custom-color' === $args['bg_hover'] ? 'bg_hover_color' : 'bg_hover'; |
2749
|
|
|
$color = sd_get_color_from_var( $args[ $key ] ); |
2750
|
|
|
$rules .= $styleid . ':hover {background: ' . $color . ' !important;} '; |
2751
|
|
|
$rules .= $styleid . '.btn:hover {border-color: ' . $color . ' !important;} '; |
2752
|
|
|
} |
2753
|
|
|
} |
2754
|
|
|
} |
2755
|
|
|
|
2756
|
|
|
return $rules ? '<style>' . $rules . '</style>' : ''; |
2757
|
|
|
} |
2758
|
|
|
|
2759
|
|
|
/** |
2760
|
|
|
* Try to get a CSS color variable for a given value. |
2761
|
|
|
* |
2762
|
|
|
* @param $var |
2763
|
|
|
* |
2764
|
|
|
* @return mixed|string |
2765
|
|
|
*/ |
2766
|
|
|
function sd_get_color_from_var( $var ) { |
2767
|
|
|
|
2768
|
|
|
//sanitize_hex_color() @todo this does not cover transparency |
2769
|
|
|
if ( strpos( $var, '#' ) === false ) { |
2770
|
|
|
$var = defined( 'BLOCKSTRAP_BLOCKS_VERSION' ) ? 'var(--wp--preset--color--' . esc_attr( $var ) . ')' : 'var(--' . esc_attr( $var ) . ')'; |
2771
|
|
|
} |
2772
|
|
|
|
2773
|
|
|
return $var; |
2774
|
|
|
} |
2775
|
|
|
|
2776
|
|
|
/** |
2777
|
|
|
* Sanitize single or multiple HTML classes. |
2778
|
|
|
* |
2779
|
|
|
* @param $classes |
2780
|
|
|
* @param $sep |
2781
|
|
|
* |
2782
|
|
|
* @return string |
2783
|
|
|
*/ |
2784
|
|
|
function sd_sanitize_html_classes( $classes, $sep = ' ' ) { |
2785
|
|
|
$return = ''; |
2786
|
|
|
|
2787
|
|
|
if ( ! is_array( $classes ) ) { |
2788
|
|
|
$classes = explode( $sep, $classes ); |
2789
|
|
|
} |
2790
|
|
|
|
2791
|
|
|
if ( ! empty( $classes ) ) { |
2792
|
|
|
foreach ( $classes as $class ) { |
2793
|
|
|
$return .= sanitize_html_class( $class ) . ' '; |
2794
|
|
|
} |
2795
|
|
|
} |
2796
|
|
|
|
2797
|
|
|
return $return; |
2798
|
|
|
} |
2799
|
|
|
|
2800
|
|
|
|
2801
|
|
|
/** |
2802
|
|
|
* Keys that are used for the class builder. |
2803
|
|
|
* |
2804
|
|
|
* @return void |
2805
|
|
|
*/ |
2806
|
|
|
function sd_get_class_build_keys() { |
2807
|
|
|
$keys = array( |
2808
|
|
|
'container', |
2809
|
|
|
'position', |
2810
|
|
|
'flex_direction', |
2811
|
|
|
'shadow', |
2812
|
|
|
'rounded', |
2813
|
|
|
'nav_style', |
2814
|
|
|
'horizontal_alignment', |
2815
|
|
|
'nav_fill', |
2816
|
|
|
'width', |
2817
|
|
|
'font_weight', |
2818
|
|
|
'font_size', |
2819
|
|
|
'font_case', |
2820
|
|
|
'css_class', |
2821
|
|
|
'flex_align_items-MTD', |
2822
|
|
|
'flex_justify_content-MTD', |
2823
|
|
|
'flex_align_self-MTD', |
2824
|
|
|
'flex_order-MTD', |
2825
|
|
|
'styleid', |
2826
|
|
|
'border_opacity', |
2827
|
|
|
'border_width', |
2828
|
|
|
'border_type', |
2829
|
|
|
'opacity', |
2830
|
|
|
'zindex', |
2831
|
|
|
'flex_wrap-MTD', |
2832
|
|
|
'h100', |
2833
|
|
|
'overflow', |
2834
|
|
|
'scrollbars', |
2835
|
|
|
'float-MTD' |
2836
|
|
|
); |
2837
|
|
|
|
2838
|
|
|
return apply_filters( 'sd_class_build_keys', $keys ); |
|
|
|
|
2839
|
|
|
} |
2840
|
|
|
|
2841
|
|
|
/** |
2842
|
|
|
* This is a placeholder function for the visibility conditions input. |
2843
|
|
|
* |
2844
|
|
|
* @param $type |
2845
|
|
|
* @param $overwrite |
2846
|
|
|
* |
2847
|
|
|
* @return array |
2848
|
|
|
*/ |
2849
|
|
|
function sd_get_visibility_conditions_input( $type = 'visibility_conditions', $overwrite = array() ) { |
|
|
|
|
2850
|
|
|
$defaults = array( |
2851
|
|
|
'type' => 'visibility_conditions', |
2852
|
|
|
'title' => __( 'Block Visibility', 'ayecode-connect' ), |
2853
|
|
|
'button_title' => __( 'Set Block Visibility', 'ayecode-connect' ), |
2854
|
|
|
'default' => '', |
2855
|
|
|
'desc_tip' => true, |
2856
|
|
|
'group' => __( 'Visibility Conditions', 'ayecode-connect' ), |
2857
|
|
|
); |
2858
|
|
|
|
2859
|
|
|
$input = wp_parse_args( $overwrite, $defaults ); |
2860
|
|
|
|
2861
|
|
|
return $input; |
2862
|
|
|
} |
2863
|
|
|
|
2864
|
|
|
/** |
2865
|
|
|
* Get a array of user roles. |
2866
|
|
|
* |
2867
|
|
|
* |
2868
|
|
|
* |
2869
|
|
|
* @param array $exclude An array of roles to exclude from the return array. |
2870
|
|
|
* @return array An array of roles. |
2871
|
|
|
*/ |
2872
|
|
|
function sd_user_roles_options( $exclude = array() ) { |
2873
|
|
|
$user_roles = array(); |
2874
|
|
|
|
2875
|
|
|
if ( !function_exists('get_editable_roles') ) { |
2876
|
|
|
require_once( ABSPATH . '/wp-admin/includes/user.php' ); |
2877
|
|
|
} |
2878
|
|
|
|
2879
|
|
|
$roles = get_editable_roles(); |
2880
|
|
|
|
2881
|
|
|
foreach ( $roles as $role => $data ) { |
2882
|
|
|
if ( ! ( ! empty( $exclude ) && in_array( $role, $exclude ) ) ) { |
2883
|
|
|
$user_roles[ esc_attr( $role ) ] = translate_user_role( $data['name'] ); |
2884
|
|
|
} |
2885
|
|
|
} |
2886
|
|
|
|
2887
|
|
|
return apply_filters( 'sd_user_roles_options', $user_roles ); |
2888
|
|
|
} |
2889
|
|
|
|
2890
|
|
|
/** |
2891
|
|
|
* Get visibility conditions rule options. |
2892
|
|
|
* |
2893
|
|
|
* |
2894
|
|
|
* |
2895
|
|
|
* @return array Rule options. |
2896
|
|
|
*/ |
2897
|
|
|
function sd_visibility_rules_options() { |
2898
|
|
|
$options = array( |
2899
|
|
|
'logged_in' => __( 'Logged In', 'ayecode-connect' ), |
2900
|
|
|
'logged_out' => __( 'Logged Out', 'ayecode-connect' ), |
2901
|
|
|
'post_author' => __( 'Post Author', 'ayecode-connect' ), |
2902
|
|
|
'user_roles' => __( 'Specific User Roles', 'ayecode-connect' ) |
2903
|
|
|
); |
2904
|
|
|
|
2905
|
|
|
if ( class_exists( 'GeoDirectory' ) ) { |
2906
|
|
|
$options['gd_field'] = __( 'GD Field', 'ayecode-connect' ); |
2907
|
|
|
} |
2908
|
|
|
|
2909
|
|
|
return apply_filters( 'sd_visibility_rules_options', $options ); |
2910
|
|
|
} |
2911
|
|
|
|
2912
|
|
|
/** |
2913
|
|
|
* Get visibility GD field options. |
2914
|
|
|
* |
2915
|
|
|
* @return array |
2916
|
|
|
*/ |
2917
|
|
|
function sd_visibility_gd_field_options() { |
2918
|
|
|
$fields = geodir_post_custom_fields( '', 'all', 'all', 'none' ); |
|
|
|
|
2919
|
|
|
|
2920
|
|
|
$keys = array(); |
2921
|
|
|
if ( ! empty( $fields ) ) { |
2922
|
|
|
foreach( $fields as $field ) { |
2923
|
|
|
if ( apply_filters( 'geodir_badge_field_skip_key', false, $field ) ) { |
2924
|
|
|
continue; |
2925
|
|
|
} |
2926
|
|
|
|
2927
|
|
|
$keys[ $field['htmlvar_name'] ] = $field['htmlvar_name'] . ' ( ' . __( $field['admin_title'], 'geodirectory' ) . ' )'; |
2928
|
|
|
|
2929
|
|
|
// Extra address fields |
2930
|
|
|
if ( $field['htmlvar_name'] == 'address' && ( $address_fields = geodir_post_meta_address_fields( '' ) ) ) { |
|
|
|
|
2931
|
|
|
foreach ( $address_fields as $_field => $args ) { |
2932
|
|
|
if ( $_field != 'map_directions' && $_field != 'street' ) { |
2933
|
|
|
$keys[ $_field ] = $_field . ' ( ' . $args['frontend_title'] . ' )'; |
2934
|
|
|
} |
2935
|
|
|
} |
2936
|
|
|
} |
2937
|
|
|
} |
2938
|
|
|
} |
2939
|
|
|
|
2940
|
|
|
$standard_fields = sd_visibility_gd_standard_field_options(); |
2941
|
|
|
|
2942
|
|
|
if ( ! empty( $standard_fields ) ) { |
2943
|
|
|
foreach ( $standard_fields as $key => $option ) { |
2944
|
|
|
$keys[ $key ] = $option; |
2945
|
|
|
} |
2946
|
|
|
} |
2947
|
|
|
|
2948
|
|
|
$options = apply_filters( 'geodir_badge_field_keys', $keys ); |
2949
|
|
|
|
2950
|
|
|
return apply_filters( 'sd_visibility_gd_field_options', $options ); |
2951
|
|
|
} |
2952
|
|
|
|
2953
|
|
|
/** |
2954
|
|
|
* Get visibility GD post standard field options. |
2955
|
|
|
* |
2956
|
|
|
* @return array |
2957
|
|
|
*/ |
2958
|
|
|
function sd_visibility_gd_standard_field_options( $post_type = '' ) { |
2959
|
|
|
$fields = sd_visibility_gd_standard_fields( $post_type ); |
2960
|
|
|
|
2961
|
|
|
$options = array(); |
2962
|
|
|
|
2963
|
|
|
foreach ( $fields as $key => $field ) { |
2964
|
|
|
if ( ! empty( $field['frontend_title'] ) ) { |
2965
|
|
|
$options[ $key ] = $key . ' ( ' . $field['frontend_title'] . ' )'; |
2966
|
|
|
} |
2967
|
|
|
} |
2968
|
|
|
|
2969
|
|
|
return apply_filters( 'sd_visibility_gd_standard_field_options', $options, $fields ); |
2970
|
|
|
} |
2971
|
|
|
|
2972
|
|
|
/** |
2973
|
|
|
* Get visibility GD post standard fields. |
2974
|
|
|
* |
2975
|
|
|
* @return array |
2976
|
|
|
*/ |
2977
|
|
|
function sd_visibility_gd_standard_fields( $post_type = '' ) { |
2978
|
|
|
$standard_fields = geodir_post_meta_standard_fields( $post_type ); |
|
|
|
|
2979
|
|
|
|
2980
|
|
|
$fields = array(); |
2981
|
|
|
|
2982
|
|
|
foreach ( $standard_fields as $key => $field ) { |
2983
|
|
|
if ( $key != 'post_link' && strpos( $key, 'event' ) === false && ! empty( $field['frontend_title'] ) ) { |
2984
|
|
|
$fields[ $key ] = $field; |
2985
|
|
|
} |
2986
|
|
|
} |
2987
|
|
|
|
2988
|
|
|
return apply_filters( 'sd_visibility_gd_standard_fields', $fields ); |
2989
|
|
|
} |
2990
|
|
|
|
2991
|
|
|
/** |
2992
|
|
|
* Get visibility field conditions options. |
2993
|
|
|
* |
2994
|
|
|
* @return array |
2995
|
|
|
*/ |
2996
|
|
|
function sd_visibility_field_condition_options(){ |
2997
|
|
|
$options = array( |
2998
|
|
|
'is_empty' => __( 'is empty', 'ayecode-connect' ), |
2999
|
|
|
'is_not_empty' => __( 'is not empty', 'ayecode-connect' ), |
3000
|
|
|
'is_equal' => __( 'is equal', 'ayecode-connect' ), |
3001
|
|
|
'is_not_equal' => __( 'is not equal', 'ayecode-connect' ), |
3002
|
|
|
'is_greater_than' => __( 'is greater than', 'ayecode-connect' ), |
3003
|
|
|
'is_less_than' => __( 'is less than', 'ayecode-connect' ), |
3004
|
|
|
'is_contains' => __( 'is contains', 'ayecode-connect' ), |
3005
|
|
|
'is_not_contains' => __( 'is not contains', 'ayecode-connect' ), |
3006
|
|
|
); |
3007
|
|
|
|
3008
|
|
|
return apply_filters( 'sd_visibility_field_condition_options', $options ); |
3009
|
|
|
} |
3010
|
|
|
|
3011
|
|
|
/** |
3012
|
|
|
* Get visibility conditions output options. |
3013
|
|
|
* |
3014
|
|
|
* |
3015
|
|
|
* |
3016
|
|
|
* @return array Template type options. |
3017
|
|
|
*/ |
3018
|
|
|
function sd_visibility_output_options() { |
3019
|
|
|
$options = array( |
3020
|
|
|
'hide' => __( 'Hide Block', 'ayecode-connect' ), |
3021
|
|
|
'message' => __( 'Show Custom Message', 'ayecode-connect' ), |
3022
|
|
|
'page' => __( 'Show Page Content', 'ayecode-connect' ), |
3023
|
|
|
'template_part' => __( 'Show Template Part', 'ayecode-connect' ), |
3024
|
|
|
); |
3025
|
|
|
|
3026
|
|
|
return apply_filters( 'sd_visibility_output_options', $options ); |
3027
|
|
|
} |
3028
|
|
|
|
3029
|
|
|
/** |
3030
|
|
|
* Get the template page options. |
3031
|
|
|
* |
3032
|
|
|
* |
3033
|
|
|
* |
3034
|
|
|
* @param array $args Array of arguments. |
3035
|
|
|
* @return array Template page options. |
3036
|
|
|
*/ |
3037
|
|
|
function sd_template_page_options( $args = array() ) { |
3038
|
|
|
global $sd_tmpl_page_options; |
3039
|
|
|
|
3040
|
|
|
if ( ! empty( $sd_tmpl_page_options ) ) { |
3041
|
|
|
return $sd_tmpl_page_options; |
3042
|
|
|
} |
3043
|
|
|
|
3044
|
|
|
$args = wp_parse_args( $args, array( |
3045
|
|
|
'child_of' => 0, |
3046
|
|
|
'sort_column' => 'post_title', |
3047
|
|
|
'sort_order' => 'ASC' |
3048
|
|
|
) ); |
3049
|
|
|
|
3050
|
|
|
$exclude_pages = array(); |
3051
|
|
|
if ( $page_on_front = get_option( 'page_on_front' ) ) { |
3052
|
|
|
$exclude_pages[] = $page_on_front; |
3053
|
|
|
} |
3054
|
|
|
|
3055
|
|
|
if ( $page_for_posts = get_option( 'page_for_posts' ) ) { |
3056
|
|
|
$exclude_pages[] = $page_for_posts; |
3057
|
|
|
} |
3058
|
|
|
|
3059
|
|
|
if ( ! empty( $exclude_pages ) ) { |
3060
|
|
|
$args['exclude'] = $exclude_pages; |
3061
|
|
|
} |
3062
|
|
|
|
3063
|
|
|
$pages = get_pages( $args ); |
3064
|
|
|
|
3065
|
|
|
$options = array( '' => __( 'Select Page...', 'ayecode-connect' ) ); |
3066
|
|
|
if ( ! empty( $pages ) ) { |
3067
|
|
|
foreach ( $pages as $page ) { |
3068
|
|
|
if ( ! empty( $page->ID ) && ! empty( $page->post_title ) ) { |
3069
|
|
|
$options[ $page->ID ] = $page->post_title . ' (#' . $page->ID . ')'; |
3070
|
|
|
} |
3071
|
|
|
} |
3072
|
|
|
} |
3073
|
|
|
|
3074
|
|
|
$sd_tmpl_page_options = $options; |
3075
|
|
|
|
3076
|
|
|
return apply_filters( 'sd_template_page_options', $options ); |
3077
|
|
|
} |
3078
|
|
|
|
3079
|
|
|
/** |
3080
|
|
|
* Get the template part options. |
3081
|
|
|
* |
3082
|
|
|
* |
3083
|
|
|
* |
3084
|
|
|
* @param array $args Array of arguments. |
3085
|
|
|
* @return array Template part options. |
3086
|
|
|
*/ |
3087
|
|
|
function sd_template_part_options( $args = array() ) { |
3088
|
|
|
global $sd_tmpl_part_options; |
3089
|
|
|
|
3090
|
|
|
if ( ! empty( $sd_tmpl_part_options ) ) { |
3091
|
|
|
return $sd_tmpl_part_options; |
3092
|
|
|
} |
3093
|
|
|
|
3094
|
|
|
$options = array( '' => __( 'Select Template Part...', 'ayecode-connect' ) ); |
3095
|
|
|
|
3096
|
|
|
$parts = get_block_templates( array(), 'wp_template_part' ); |
3097
|
|
|
|
3098
|
|
|
if ( ! empty( $parts ) ) { |
3099
|
|
|
foreach ( $parts as $part ) { |
3100
|
|
|
$options[ $part->slug ] = $part->title . ' (#' . $part->slug . ')'; |
3101
|
|
|
} |
3102
|
|
|
} |
3103
|
|
|
|
3104
|
|
|
$sd_tmpl_part_options = $options; |
3105
|
|
|
|
3106
|
|
|
return apply_filters( 'sd_template_part_options', $options, $args ); |
3107
|
|
|
} |
3108
|
|
|
|
3109
|
|
|
/** |
3110
|
|
|
* Get the template part by slug. |
3111
|
|
|
* |
3112
|
|
|
* |
3113
|
|
|
* |
3114
|
|
|
* @param string $slug Template slug. |
3115
|
|
|
* @return array Template part object. |
3116
|
|
|
*/ |
3117
|
|
|
function sd_get_template_part_by_slug( $slug ) { |
3118
|
|
|
global $bs_tmpl_part_by_slug; |
3119
|
|
|
|
3120
|
|
|
if ( empty( $bs_tmpl_part_by_slug ) ) { |
3121
|
|
|
$bs_tmpl_part_by_slug = array(); |
3122
|
|
|
} |
3123
|
|
|
|
3124
|
|
|
if ( isset( $bs_tmpl_part_by_slug[ $slug ] ) ) { |
3125
|
|
|
return $bs_tmpl_part_by_slug[ $slug ]; |
3126
|
|
|
} |
3127
|
|
|
|
3128
|
|
|
$template_query = get_block_templates( array( 'slug__in' => array( $slug ) ), 'wp_template_part' ); |
3129
|
|
|
|
3130
|
|
|
$query_post = ! empty( $template_query ) ? $template_query[0] : array(); |
3131
|
|
|
|
3132
|
|
|
$template_part = ! empty( $query_post ) && $query_post->status == 'publish' ? $query_post : array(); |
3133
|
|
|
|
3134
|
|
|
$bs_tmpl_part_by_slug[ $slug ] = $template_part; |
3135
|
|
|
|
3136
|
|
|
return apply_filters( 'sd_get_template_part_by_slug', $template_part, $slug ); |
|
|
|
|
3137
|
|
|
} |
3138
|
|
|
|
3139
|
|
|
/** |
3140
|
|
|
* Filters the content of a single block. |
3141
|
|
|
* |
3142
|
|
|
* |
3143
|
|
|
* |
3144
|
|
|
* @param string $block_content The block content. |
3145
|
|
|
* @param array $block The full block, including name and attributes. |
3146
|
|
|
* @param WP_Block $instance The block instance. |
3147
|
|
|
*/ |
3148
|
|
|
function sd_render_block( $block_content, $block, $instance = '' ) { |
3149
|
|
|
// No block visibility conditions set. |
3150
|
|
|
if ( empty( $block['attrs']['visibility_conditions'] ) ) { |
3151
|
|
|
return $block_content; |
3152
|
|
|
} |
3153
|
|
|
|
3154
|
|
|
$attributes = json_decode( $block['attrs']['visibility_conditions'], true ); |
3155
|
|
|
$rules = ! empty( $attributes ) ? sd_block_parse_rules( $attributes ) : array(); |
3156
|
|
|
|
3157
|
|
|
// No rules set. |
3158
|
|
|
if ( empty( $rules ) ) { |
3159
|
|
|
return $block_content; |
3160
|
|
|
} |
3161
|
|
|
|
3162
|
|
|
$_block_content = $block_content; |
3163
|
|
|
|
3164
|
|
|
if ( ! empty( $rules ) && sd_block_check_rules( $rules ) ) { |
3165
|
|
|
if ( ! empty( $attributes['output']['type'] ) ) { |
3166
|
|
|
switch ( $attributes['output']['type'] ) { |
3167
|
|
|
case 'hide': |
3168
|
|
|
$valid_type = true; |
3169
|
|
|
$content = ''; |
3170
|
|
|
|
3171
|
|
|
break; |
3172
|
|
|
case 'message': |
3173
|
|
|
$valid_type = true; |
3174
|
|
|
|
3175
|
|
|
if ( isset( $attributes['output']['message'] ) ) { |
3176
|
|
|
$content = $attributes['output']['message'] != '' ? __( stripslashes( $attributes['output']['message'] ), 'ayecode-connect' ) : $attributes['output']['message']; |
3177
|
|
|
|
3178
|
|
|
if ( ! empty( $attributes['output']['message_type'] ) ) { |
3179
|
|
|
$content = aui()->alert( array( |
3180
|
|
|
'type'=> $attributes['output']['message_type'], |
3181
|
|
|
'content'=> $content |
3182
|
|
|
) |
3183
|
|
|
); |
3184
|
|
|
} |
3185
|
|
|
} |
3186
|
|
|
|
3187
|
|
|
break; |
3188
|
|
|
case 'page': |
3189
|
|
|
$valid_type = true; |
3190
|
|
|
|
3191
|
|
|
$page_id = ! empty( $attributes['output']['page'] ) ? absint( $attributes['output']['page'] ) : 0; |
3192
|
|
|
$content = sd_get_page_content( $page_id ); |
3193
|
|
|
|
3194
|
|
|
break; |
3195
|
|
|
case 'template_part': |
3196
|
|
|
$valid_type = true; |
3197
|
|
|
|
3198
|
|
|
$template_part = ! empty( $attributes['output']['template_part'] ) ? $attributes['output']['template_part'] : ''; |
3199
|
|
|
$content = sd_get_template_part_content( $template_part ); |
3200
|
|
|
|
3201
|
|
|
break; |
3202
|
|
|
default: |
3203
|
|
|
$valid_type = false; |
3204
|
|
|
break; |
3205
|
|
|
} |
3206
|
|
|
|
3207
|
|
|
if ( $valid_type ) { |
3208
|
|
|
$block_content = '<div class="' . esc_attr( wp_get_block_default_classname( $instance->name ) ) . ' sd-block-has-rule">' . $content . '</div>'; |
|
|
|
|
3209
|
|
|
} |
3210
|
|
|
} |
3211
|
|
|
} |
3212
|
|
|
|
3213
|
|
|
return apply_filters( 'sd_render_block_visibility_content', $block_content, $_block_content, $attributes, $block, $instance ); |
3214
|
|
|
} |
3215
|
|
|
add_filter( 'render_block', 'sd_render_block', 9, 3 ); |
3216
|
|
|
|
3217
|
|
|
function sd_get_page_content( $page_id ) { |
3218
|
|
|
$content = $page_id > 0 ? get_post_field( 'post_content', (int) $page_id ) : ''; |
3219
|
|
|
|
3220
|
|
|
// Maybe bypass content |
3221
|
|
|
$bypass_content = apply_filters( 'sd_bypass_page_content', '', $content, $page_id ); |
3222
|
|
|
if ( $bypass_content ) { |
3223
|
|
|
return $bypass_content; |
3224
|
|
|
} |
3225
|
|
|
|
3226
|
|
|
// Run the shortcodes on the content. |
3227
|
|
|
$content = do_shortcode( $content ); |
3228
|
|
|
|
3229
|
|
|
// Run block content if its available. |
3230
|
|
|
if ( function_exists( 'do_blocks' ) ) { |
3231
|
|
|
$content = do_blocks( $content ); |
3232
|
|
|
} |
3233
|
|
|
|
3234
|
|
|
return apply_filters( 'sd_get_page_content', $content, $page_id ); |
3235
|
|
|
} |
3236
|
|
|
|
3237
|
|
|
function sd_get_template_part_content( $template_part ) { |
3238
|
|
|
$template_part_post = $template_part ? sd_get_template_part_by_slug( $template_part ) : array(); |
3239
|
|
|
$content = ! empty( $template_part_post ) ? $template_part_post->content : ''; |
3240
|
|
|
|
3241
|
|
|
// Maybe bypass content |
3242
|
|
|
$bypass_content = apply_filters( 'sd_bypass_template_part_content', '', $content, $template_part ); |
3243
|
|
|
if ( $bypass_content ) { |
3244
|
|
|
return $bypass_content; |
3245
|
|
|
} |
3246
|
|
|
|
3247
|
|
|
// Run the shortcodes on the content. |
3248
|
|
|
$content = do_shortcode( $content ); |
3249
|
|
|
|
3250
|
|
|
// Run block content if its available. |
3251
|
|
|
if ( function_exists( 'do_blocks' ) ) { |
3252
|
|
|
$content = do_blocks( $content ); |
3253
|
|
|
} |
3254
|
|
|
|
3255
|
|
|
return apply_filters( 'sd_get_template_part_content', $content, $template_part ); |
3256
|
|
|
} |
3257
|
|
|
|
3258
|
|
|
function sd_block_parse_rules( $attrs ) { |
3259
|
|
|
$rules = array(); |
3260
|
|
|
|
3261
|
|
|
if ( ! empty( $attrs ) && is_array( $attrs ) ) { |
3262
|
|
|
$attrs_keys = array_keys( $attrs ); |
3263
|
|
|
|
3264
|
|
|
for ( $i = 1; $i <= count( $attrs_keys ); $i++ ) { |
|
|
|
|
3265
|
|
|
if ( ! empty( $attrs[ 'rule' . $i ] ) && is_array( $attrs[ 'rule' . $i ] ) ) { |
3266
|
|
|
$rules[] = $attrs[ 'rule' . $i ]; |
3267
|
|
|
} |
3268
|
|
|
} |
3269
|
|
|
} |
3270
|
|
|
|
3271
|
|
|
return apply_filters( 'sd_block_parse_rules', $rules, $attrs ); |
3272
|
|
|
} |
3273
|
|
|
|
3274
|
|
|
function sd_block_check_rules( $rules ) { |
3275
|
|
|
if ( ! ( is_array( $rules ) && ! empty( $rules ) ) ) { |
3276
|
|
|
return true; |
3277
|
|
|
} |
3278
|
|
|
|
3279
|
|
|
foreach ( $rules as $key => $rule ) { |
3280
|
|
|
$match = apply_filters( 'sd_block_check_rule', true, $rule ); |
3281
|
|
|
|
3282
|
|
|
if ( ! $match ) { |
3283
|
|
|
break; |
3284
|
|
|
} |
3285
|
|
|
} |
3286
|
|
|
|
3287
|
|
|
return apply_filters( 'sd_block_check_rules', $match, $rules ); |
|
|
|
|
3288
|
|
|
} |
3289
|
|
|
|
3290
|
|
|
function sd_block_check_rule( $match, $rule ) { |
3291
|
|
|
global $post; |
3292
|
|
|
|
3293
|
|
|
if ( $match && ! empty( $rule['type'] ) ) { |
3294
|
|
|
switch ( $rule['type'] ) { |
3295
|
|
|
case 'logged_in': |
3296
|
|
|
$match = (bool) is_user_logged_in(); |
3297
|
|
|
|
3298
|
|
|
break; |
3299
|
|
|
case 'logged_out': |
3300
|
|
|
$match = ! is_user_logged_in(); |
3301
|
|
|
|
3302
|
|
|
break; |
3303
|
|
|
case 'post_author': |
3304
|
|
|
if ( ! empty( $post ) && $post->post_type != 'page' && ! empty( $post->post_author ) && is_user_logged_in() ) { |
3305
|
|
|
$match = (int) $post->post_author === (int) get_current_user_id() ? true : false; |
3306
|
|
|
} else { |
3307
|
|
|
$match = false; |
3308
|
|
|
} |
3309
|
|
|
|
3310
|
|
|
break; |
3311
|
|
|
case 'user_roles': |
3312
|
|
|
$match = false; |
3313
|
|
|
|
3314
|
|
|
if ( ! empty( $rule['user_roles'] ) ) { |
3315
|
|
|
$user_roles = is_scalar( $rule['user_roles'] ) ? explode( ",", $rule['user_roles'] ) : $rule['user_roles']; |
3316
|
|
|
|
3317
|
|
|
if ( is_array( $user_roles ) ) { |
3318
|
|
|
$user_roles = array_filter( array_map( 'trim', $user_roles ) ); |
3319
|
|
|
} |
3320
|
|
|
|
3321
|
|
|
if ( ! empty( $user_roles ) && is_array( $user_roles ) && is_user_logged_in() && ( $current_user = wp_get_current_user() ) ) { |
3322
|
|
|
$current_user_roles = $current_user->roles; |
3323
|
|
|
|
3324
|
|
|
foreach ( $user_roles as $role ) { |
3325
|
|
|
if ( in_array( $role, $current_user_roles ) ) { |
3326
|
|
|
$match = true; |
3327
|
|
|
} |
3328
|
|
|
} |
3329
|
|
|
} |
3330
|
|
|
} |
3331
|
|
|
|
3332
|
|
|
break; |
3333
|
|
|
case 'gd_field': |
3334
|
|
|
$match = sd_block_check_rule_gd_field( $rule ); |
3335
|
|
|
|
3336
|
|
|
break; |
3337
|
|
|
} |
3338
|
|
|
} |
3339
|
|
|
|
3340
|
|
|
return $match; |
3341
|
|
|
} |
3342
|
|
|
add_filter( 'sd_block_check_rule', 'sd_block_check_rule', 10, 2 ); |
3343
|
|
|
|
3344
|
|
|
function sd_block_check_rule_gd_field( $rule ) { |
3345
|
|
|
global $gd_post; |
3346
|
|
|
|
3347
|
|
|
$match_found = false; |
3348
|
|
|
|
3349
|
|
|
if ( class_exists( 'GeoDirectory' ) && ! empty( $gd_post->ID ) && ! empty( $rule['field'] ) && ! empty( $rule['condition'] ) ) { |
3350
|
|
|
$args['block_visibility'] = true; |
|
|
|
|
3351
|
|
|
$args['key'] = $rule['field']; |
3352
|
|
|
$args['condition'] = $rule['condition']; |
3353
|
|
|
$args['search'] = isset( $rule['search'] ) ? $rule['search'] : ''; |
3354
|
|
|
|
3355
|
|
|
if ( $args['key'] == 'street' ) { |
3356
|
|
|
$args['key'] = 'address'; |
3357
|
|
|
} |
3358
|
|
|
|
3359
|
|
|
$match_field = $_match_field = $args['key']; |
3360
|
|
|
|
3361
|
|
|
if ( $match_field == 'address' ) { |
3362
|
|
|
$match_field = 'street'; |
3363
|
|
|
} elseif ( $match_field == 'post_images' ) { |
3364
|
|
|
$match_field = 'featured_image'; |
3365
|
|
|
} |
3366
|
|
|
|
3367
|
|
|
$find_post = $gd_post; |
3368
|
|
|
$find_post_keys = ! empty( $find_post ) ? array_keys( (array) $find_post ) : array(); |
3369
|
|
|
|
3370
|
|
|
if ( ! empty( $find_post->ID ) && ! in_array( 'post_category', $find_post_keys ) ) { |
3371
|
|
|
$find_post = geodir_get_post_info( (int) $find_post->ID ); |
|
|
|
|
3372
|
|
|
$find_post_keys = ! empty( $find_post ) ? array_keys( (array) $find_post ) : array(); |
3373
|
|
|
} |
3374
|
|
|
|
3375
|
|
|
if ( $match_field === '' || ( ! empty( $find_post_keys ) && ( in_array( $match_field, $find_post_keys ) || in_array( $_match_field, $find_post_keys ) ) ) ) { |
3376
|
|
|
$address_fields = array( 'street2', 'neighbourhood', 'city', 'region', 'country', 'zip', 'latitude', 'longitude' ); // Address fields |
3377
|
|
|
$field = array(); |
3378
|
|
|
$empty_field = false; |
3379
|
|
|
|
3380
|
|
|
$standard_fields = sd_visibility_gd_standard_fields(); |
3381
|
|
|
|
3382
|
|
|
if ( $match_field && ! in_array( $match_field, array_keys( $standard_fields ) ) && ! in_array( $match_field, $address_fields ) ) { |
3383
|
|
|
$package_id = geodir_get_post_package_id( $find_post->ID, $find_post->post_type ); |
|
|
|
|
3384
|
|
|
$fields = geodir_post_custom_fields( $package_id, 'all', $find_post->post_type, 'none' ); |
|
|
|
|
3385
|
|
|
|
3386
|
|
|
foreach ( $fields as $field_info ) { |
3387
|
|
|
if ( $match_field == $field_info['htmlvar_name'] ) { |
3388
|
|
|
$field = $field_info; |
3389
|
|
|
break; |
3390
|
|
|
} elseif( $_match_field == $field_info['htmlvar_name'] ) { |
3391
|
|
|
$field = $field_info; |
3392
|
|
|
break; |
3393
|
|
|
} |
3394
|
|
|
} |
3395
|
|
|
|
3396
|
|
|
if ( empty( $field ) ) { |
3397
|
|
|
$empty_field = true; |
3398
|
|
|
} |
3399
|
|
|
} |
3400
|
|
|
|
3401
|
|
|
// Address fields. |
3402
|
|
|
if ( in_array( $match_field, $address_fields ) && ( $address_fields = geodir_post_meta_address_fields( '' ) ) ) { |
|
|
|
|
3403
|
|
|
if ( ! empty( $address_fields[ $match_field ] ) ) { |
3404
|
|
|
$field = $address_fields[ $match_field ]; |
3405
|
|
|
} |
3406
|
|
|
} else if ( in_array( $match_field, array_keys( $standard_fields ) ) ) { |
3407
|
|
|
if ( ! empty( $standard_fields[ $match_field ] ) ) { |
3408
|
|
|
$field = $standard_fields[ $match_field ]; |
3409
|
|
|
} |
3410
|
|
|
} |
3411
|
|
|
|
3412
|
|
|
// Parse search. |
3413
|
|
|
$search = sd_gd_field_rule_search( $args['search'], $find_post->post_type, $rule, $field, $find_post ); |
3414
|
|
|
|
3415
|
|
|
$is_date = ( ! empty( $field['type'] ) && $field['type'] == 'datepicker' ) || in_array( $match_field, array( 'post_date', 'post_modified' ) ) ? true : false; |
3416
|
|
|
$is_date = apply_filters( 'geodir_post_badge_is_date', $is_date, $match_field, $field, $args, $find_post ); |
|
|
|
|
3417
|
|
|
|
3418
|
|
|
$match_value = isset( $find_post->{$match_field} ) && empty( $empty_field ) ? esc_attr( trim( $find_post->{$match_field} ) ) : ''; |
3419
|
|
|
$match_found = $match_field === '' ? true : false; |
3420
|
|
|
|
3421
|
|
|
if ( ! $match_found ) { |
3422
|
|
|
if ( ( $match_field == 'post_date' || $match_field == 'post_modified' ) && ( empty( $args['condition'] ) || $args['condition'] == 'is_greater_than' || $args['condition'] == 'is_less_than' ) ) { |
3423
|
|
|
if ( strpos( $search, '+' ) === false && strpos( $search, '-' ) === false ) { |
3424
|
|
|
$search = '+' . $search; |
3425
|
|
|
} |
3426
|
|
|
$the_time = $match_field == 'post_modified' ? get_the_modified_date( 'Y-m-d', $find_post ) : get_the_time( 'Y-m-d', $find_post ); |
3427
|
|
|
$until_time = strtotime( $the_time . ' ' . $search . ' days' ); |
|
|
|
|
3428
|
|
|
$now_time = strtotime( date_i18n( 'Y-m-d', current_time( 'timestamp' ) ) ); |
3429
|
|
|
if ( ( empty( $args['condition'] ) || $args['condition'] == 'is_less_than' ) && $until_time > $now_time ) { |
3430
|
|
|
$match_found = true; |
3431
|
|
|
} elseif ( $args['condition'] == 'is_greater_than' && $until_time < $now_time ) { |
3432
|
|
|
$match_found = true; |
3433
|
|
|
} |
3434
|
|
|
} else { |
3435
|
|
|
switch ( $args['condition'] ) { |
3436
|
|
|
case 'is_equal': |
3437
|
|
|
$match_found = (bool) ( $search != '' && $match_value == $search ); |
3438
|
|
|
break; |
3439
|
|
|
case 'is_not_equal': |
3440
|
|
|
$match_found = (bool) ( $search != '' && $match_value != $search ); |
3441
|
|
|
break; |
3442
|
|
|
case 'is_greater_than': |
3443
|
|
|
$match_found = (bool) ( $search != '' && ( is_float( $search ) || is_numeric( $search ) ) && ( is_float( $match_value ) || is_numeric( $match_value ) ) && $match_value > $search ); |
3444
|
|
|
break; |
3445
|
|
|
case 'is_less_than': |
3446
|
|
|
$match_found = (bool) ( $search != '' && ( is_float( $search ) || is_numeric( $search ) ) && ( is_float( $match_value ) || is_numeric( $match_value ) ) && $match_value < $search ); |
3447
|
|
|
break; |
3448
|
|
|
case 'is_empty': |
3449
|
|
|
$match_found = (bool) ( $match_value === '' || $match_value === false || $match_value === '0' || is_null( $match_value ) ); |
3450
|
|
|
break; |
3451
|
|
|
case 'is_not_empty': |
3452
|
|
|
$match_found = (bool) ( $match_value !== '' && $match_value !== false && $match_value !== '0' && ! is_null( $match_value ) ); |
3453
|
|
|
break; |
3454
|
|
|
case 'is_contains': |
3455
|
|
|
$match_found = (bool) ( $search != '' && stripos( $match_value, $search ) !== false ); |
3456
|
|
|
break; |
3457
|
|
|
case 'is_not_contains': |
3458
|
|
|
$match_found = (bool) ( $search != '' && stripos( $match_value, $search ) === false ); |
3459
|
|
|
break; |
3460
|
|
|
} |
3461
|
|
|
} |
3462
|
|
|
} |
3463
|
|
|
|
3464
|
|
|
$match_found = apply_filters( 'geodir_post_badge_check_match_found', $match_found, $args, $find_post ); |
3465
|
|
|
} else { |
3466
|
|
|
$field = array(); |
3467
|
|
|
|
3468
|
|
|
// Parse search. |
3469
|
|
|
$search = sd_gd_field_rule_search( $args['search'], $find_post->post_type, $rule, $field, $find_post ); |
3470
|
|
|
|
3471
|
|
|
$match_value = ''; |
3472
|
|
|
$match_found = $match_field === '' ? true : false; |
3473
|
|
|
|
3474
|
|
|
if ( ! $match_found ) { |
3475
|
|
|
switch ( $args['condition'] ) { |
3476
|
|
|
case 'is_equal': |
3477
|
|
|
$match_found = (bool) ( $search != '' && $match_value == $search ); |
3478
|
|
|
break; |
3479
|
|
|
case 'is_not_equal': |
3480
|
|
|
$match_found = (bool) ( $search != '' && $match_value != $search ); |
3481
|
|
|
break; |
3482
|
|
|
case 'is_greater_than': |
3483
|
|
|
$match_found = false; |
3484
|
|
|
break; |
3485
|
|
|
case 'is_less_than': |
3486
|
|
|
$match_found = false; |
3487
|
|
|
break; |
3488
|
|
|
case 'is_empty': |
3489
|
|
|
$match_found = true; |
3490
|
|
|
break; |
3491
|
|
|
case 'is_not_empty': |
3492
|
|
|
$match_found = false; |
3493
|
|
|
break; |
3494
|
|
|
case 'is_contains': |
3495
|
|
|
$match_found = false; |
3496
|
|
|
break; |
3497
|
|
|
case 'is_not_contains': |
3498
|
|
|
$match_found = false; |
3499
|
|
|
break; |
3500
|
|
|
} |
3501
|
|
|
} |
3502
|
|
|
|
3503
|
|
|
$match_found = apply_filters( 'geodir_post_badge_check_match_found_empty', $match_found, $args, $find_post ); |
3504
|
|
|
} |
3505
|
|
|
} |
3506
|
|
|
|
3507
|
|
|
return $match_found; |
3508
|
|
|
} |
3509
|
|
|
|
3510
|
|
|
function sd_gd_field_rule_search( $search, $post_type, $rule, $field = array(), $gd_post = array() ) { |
|
|
|
|
3511
|
|
|
global $post; |
3512
|
|
|
|
3513
|
|
|
if ( ! $search ) { |
3514
|
|
|
return $search; |
3515
|
|
|
} |
3516
|
|
|
|
3517
|
|
|
$orig_search = $search; |
3518
|
|
|
$_search = strtolower( $search ); |
3519
|
|
|
|
3520
|
|
|
if ( ! empty( $rule['field'] ) && $rule['field'] == 'post_author' ) { |
3521
|
|
|
if ( $search == 'current_user' ) { |
3522
|
|
|
$search = is_user_logged_in() ? (int) get_current_user_id() : - 1; |
3523
|
|
|
} else if ( $search == 'current_author' ) { |
3524
|
|
|
$search = ( ! empty( $post ) && $post->post_type != 'page' && isset( $post->post_author ) ) ? absint( $post->post_author ) : - 1; |
3525
|
|
|
} |
3526
|
|
|
} else if ( $_search == 'date_today' ) { |
3527
|
|
|
$search = date( 'Y-m-d' ); |
3528
|
|
|
} else if ( $_search == 'date_tomorrow' ) { |
3529
|
|
|
$search = date( 'Y-m-d', strtotime( "+1 day" ) ); |
3530
|
|
|
} else if ( $_search == 'date_yesterday' ) { |
3531
|
|
|
$search = date( 'Y-m-d', strtotime( "-1 day" ) ); |
3532
|
|
|
} else if ( $_search == 'time_his' ) { |
3533
|
|
|
$search = date( 'H:i:s' ); |
3534
|
|
|
} else if ( $_search == 'time_hi' ) { |
3535
|
|
|
$search = date( 'H:i' ); |
3536
|
|
|
} else if ( $_search == 'datetime_now' ) { |
3537
|
|
|
$search = date( 'Y-m-d H:i:s' ); |
3538
|
|
|
} else if ( strpos( $_search, 'datetime_after_' ) === 0 ) { |
3539
|
|
|
$_searches = explode( 'datetime_after_', $_search, 2 ); |
3540
|
|
|
|
3541
|
|
|
if ( ! empty( $_searches[1] ) ) { |
3542
|
|
|
$search = date( 'Y-m-d H:i:s', strtotime( "+ " . str_replace( "_", " ", $_searches[1] ) ) ); |
3543
|
|
|
} else { |
3544
|
|
|
$search = date( 'Y-m-d H:i:s' ); |
3545
|
|
|
} |
3546
|
|
|
} else if ( strpos( $_search, 'datetime_before_' ) === 0 ) { |
3547
|
|
|
$_searches = explode( 'datetime_before_', $_search, 2 ); |
3548
|
|
|
|
3549
|
|
|
if ( ! empty( $_searches[1] ) ) { |
3550
|
|
|
$search = date( 'Y-m-d H:i:s', strtotime( "- " . str_replace( "_", " ", $_searches[1] ) ) ); |
3551
|
|
|
} else { |
3552
|
|
|
$search = date( 'Y-m-d H:i:s' ); |
3553
|
|
|
} |
3554
|
|
|
} else if ( strpos( $_search, 'date_after_' ) === 0 ) { |
3555
|
|
|
$_searches = explode( 'date_after_', $_search, 2 ); |
3556
|
|
|
|
3557
|
|
|
if ( ! empty( $_searches[1] ) ) { |
3558
|
|
|
$search = date( 'Y-m-d', strtotime( "+ " . str_replace( "_", " ", $_searches[1] ) ) ); |
3559
|
|
|
} else { |
3560
|
|
|
$search = date( 'Y-m-d' ); |
3561
|
|
|
} |
3562
|
|
|
} else if ( strpos( $_search, 'date_before_' ) === 0 ) { |
3563
|
|
|
$_searches = explode( 'date_before_', $_search, 2 ); |
3564
|
|
|
|
3565
|
|
|
if ( ! empty( $_searches[1] ) ) { |
3566
|
|
|
$search = date( 'Y-m-d', strtotime( "- " . str_replace( "_", " ", $_searches[1] ) ) ); |
3567
|
|
|
} else { |
3568
|
|
|
$search = date( 'Y-m-d' ); |
3569
|
|
|
} |
3570
|
|
|
} |
3571
|
|
|
|
3572
|
|
|
return apply_filters( 'sd_gd_field_rule_search', $search, $post_type, $rule, $orig_search ); |
3573
|
|
|
} |
3574
|
|
|
|
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.