|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace GeminiLabs\SiteReviews\Integrations\FusionBuilder\Elements; |
|
4
|
|
|
|
|
5
|
|
|
use GeminiLabs\SiteReviews\Integrations\FusionBuilder\Transformer; |
|
6
|
|
|
use GeminiLabs\SiteReviews\Integrations\IntegrationShortcode; |
|
7
|
|
|
|
|
8
|
|
|
abstract class FusionElement extends \Fusion_Element |
|
9
|
|
|
{ |
|
10
|
|
|
use IntegrationShortcode; |
|
11
|
|
|
|
|
12
|
|
|
abstract public function elementIcon(): string; |
|
13
|
|
|
|
|
14
|
|
|
public function elementParameters(array $additional = []): array |
|
15
|
|
|
{ |
|
16
|
|
|
$controls = array_merge( |
|
17
|
|
|
$this->styleConfig(), |
|
18
|
|
|
$this->contentConfig(), |
|
19
|
|
|
$additional |
|
20
|
|
|
); |
|
21
|
|
|
$controls = glsr()->filterArray('fusion-builder/controls', $controls, $this->shortcodeInstance()); |
|
22
|
|
|
$params = []; |
|
23
|
|
|
foreach ($controls as $name => $control) { |
|
24
|
|
|
$transformer = new Transformer($name, $control, $this->shortcodeInstance()->tag); |
|
25
|
|
|
if ($transformedControl = $transformer->control()) { |
|
26
|
|
|
$params[$name] = $transformedControl; |
|
27
|
|
|
} |
|
28
|
|
|
} |
|
29
|
|
|
return $params; |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
public static function registerElement(): void |
|
33
|
|
|
{ |
|
34
|
|
|
$instance = new static(); |
|
35
|
|
|
add_action('fusion_builder_before_init', function () use ($instance) { |
|
36
|
|
|
if (!function_exists('fusion_builder_map')) { |
|
37
|
|
|
return; |
|
38
|
|
|
} |
|
39
|
|
|
if (!function_exists('fusion_builder_frontend_data')) { |
|
40
|
|
|
return; |
|
41
|
|
|
} |
|
42
|
|
|
fusion_builder_map(fusion_builder_frontend_data(static::class, [ |
|
43
|
|
|
'icon' => $instance->elementIcon(), |
|
44
|
|
|
'name' => $instance->shortcodeInstance()->name, |
|
45
|
|
|
'params' => $instance->elementParameters([ |
|
46
|
|
|
'from' => [ |
|
47
|
|
|
'type' => 'hidden', |
|
48
|
|
|
'value' => 'avada', |
|
49
|
|
|
], |
|
50
|
|
|
]), |
|
51
|
|
|
'shortcode' => $instance->shortcodeInstance()->tag, |
|
52
|
|
|
])); |
|
53
|
|
|
}); |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
protected function contentConfig(): array |
|
57
|
|
|
{ |
|
58
|
|
|
return $this->shortcodeInstance()->settings(); |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
protected function styleConfig(): array |
|
62
|
|
|
{ |
|
63
|
|
|
return []; |
|
64
|
|
|
} |
|
65
|
|
|
} |
|
66
|
|
|
|