1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace GeminiLabs\SiteReviews\Integrations\Elementor\Defaults; |
4
|
|
|
|
5
|
|
|
use Elementor\Controls_Manager; |
6
|
|
|
use GeminiLabs\SiteReviews\Defaults\DefaultsAbstract; |
7
|
|
|
|
8
|
|
|
class ControlDefaults extends DefaultsAbstract |
9
|
|
|
{ |
10
|
|
|
protected function defaults(): array |
11
|
|
|
{ |
12
|
|
|
return [ |
13
|
|
|
'description' => '', |
14
|
|
|
'label' => '', |
15
|
|
|
'type' => 'text', |
16
|
|
|
]; |
17
|
|
|
} |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* Finalize provided values, this always runs last. |
21
|
|
|
*/ |
22
|
|
|
protected function finalize(array $values = []): array |
23
|
|
|
{ |
24
|
|
|
$types = [ |
25
|
|
|
'checkbox' => Controls_Manager::SWITCHER, |
26
|
|
|
'number' => Controls_Manager::NUMBER, |
27
|
|
|
'radio' => Controls_Manager::CHOOSE, |
28
|
|
|
'select' => Controls_Manager::SELECT2, |
29
|
|
|
'text' => Controls_Manager::TEXT, |
30
|
|
|
'textarea' => Controls_Manager::TEXTAREA, |
31
|
|
|
]; |
32
|
|
|
if (array_key_exists($values['type'], $types)) { |
33
|
|
|
$values['type'] = $types[$values['type']]; |
34
|
|
|
} |
35
|
|
|
if (Controls_Manager::SWITCHER === $values['type'] && !empty($values['options'])) { |
36
|
|
|
$values['type'] = 'multi_switcher'; |
37
|
|
|
} |
38
|
|
|
if (!in_array($values['type'], [ |
39
|
|
|
Controls_Manager::CHOOSE, |
40
|
|
|
Controls_Manager::COLOR, |
41
|
|
|
Controls_Manager::NUMBER, |
42
|
|
|
Controls_Manager::SWITCHER, |
43
|
|
|
]) && !isset($values['label_block'])) { |
44
|
|
|
$values['label_block'] = true; |
45
|
|
|
} |
46
|
|
|
if (Controls_Manager::SELECT2 === $values['type'] && !empty($values['placeholder'])) { |
47
|
|
|
$values['select2options'] ??= []; |
48
|
|
|
$values['select2options']['placeholder'] = $values['placeholder']; |
49
|
|
|
} |
50
|
|
|
if (Controls_Manager::SELECT2 === $values['type'] && !isset($values['options'])) { |
51
|
|
|
$values['type'] = 'select2_ajax'; |
52
|
|
|
} |
53
|
|
|
return $values; |
54
|
|
|
} |
55
|
|
|
} |
56
|
|
|
|