|
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
|
|
|
public static function elementParameters(array $params): array |
|
13
|
|
|
{ |
|
14
|
|
|
$controls = array_merge($params, static::styleConfig()); |
|
15
|
|
|
$groups = [ // order is intentional |
|
16
|
|
|
'design' => esc_html_x('Design', 'admin-text', 'site-reviews'), |
|
17
|
|
|
'general' => esc_html_x('General', 'admin-text', 'site-reviews'), |
|
18
|
|
|
]; |
|
19
|
|
|
$options = []; |
|
20
|
|
|
foreach ($controls as $name => $args) { |
|
21
|
|
|
$transform = new Transformer($name, $args); |
|
22
|
|
|
$control = $transform->control(); |
|
23
|
|
|
if ('select' === $control['type'] && empty($control['value'])) { |
|
24
|
|
|
continue; |
|
25
|
|
|
} |
|
26
|
|
|
$control['group'] = $groups[$control['group']] ?? ucfirst($control['group']); |
|
27
|
|
|
$options[$name] = $control; |
|
28
|
|
|
} |
|
29
|
|
|
return $options; |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
public static function registerElement(): void |
|
33
|
|
|
{ |
|
34
|
|
|
if (!function_exists('fusion_builder_map')) { |
|
35
|
|
|
return; |
|
36
|
|
|
} |
|
37
|
|
|
if (!function_exists('fusion_builder_frontend_data')) { |
|
38
|
|
|
return; |
|
39
|
|
|
} |
|
40
|
|
|
$instance = glsr(static::shortcodeClass()); |
|
41
|
|
|
$parameters = static::elementParameters($instance->settings()); |
|
42
|
|
|
$parameters = glsr()->filterArray("fusion-builder/controls/{$instance->tag}", $parameters); |
|
43
|
|
|
fusion_builder_map(fusion_builder_frontend_data(static::class, [ |
|
44
|
|
|
'icon' => static::shortcodeIcon(), |
|
45
|
|
|
'name' => $instance->name, |
|
46
|
|
|
'params' => $parameters, |
|
47
|
|
|
'shortcode' => $instance->tag, |
|
48
|
|
|
])); |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
abstract protected static function shortcodeIcon(): string; |
|
52
|
|
|
|
|
53
|
|
|
protected static function styleConfig(): array |
|
54
|
|
|
{ |
|
55
|
|
|
return []; |
|
56
|
|
|
} |
|
57
|
|
|
} |
|
58
|
|
|
|