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 |
13
|
|
|
{ |
14
|
|
|
$controls = array_merge(static::settingsConfig(), 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
|
|
|
'advanced' => esc_html_x('Advanced', 'admin-text', 'site-reviews'), |
19
|
|
|
]; |
20
|
|
|
$options = []; |
21
|
|
|
foreach ($controls as $name => $args) { |
22
|
|
|
$transformer = new Transformer($name, $args); |
23
|
|
|
$control = $transformer->control(); |
24
|
|
|
if ('select' === $control['type'] && empty($control['value'])) { |
25
|
|
|
continue; |
26
|
|
|
} |
27
|
|
|
$control['group'] = $groups[$control['group']] ?? ucfirst($control['group']); |
28
|
|
|
$options[] = $control; |
29
|
|
|
} |
30
|
|
|
return $options; |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
public static function registerElement(): void |
34
|
|
|
{ |
35
|
|
|
if (!function_exists('fusion_builder_map')) { |
36
|
|
|
return; |
37
|
|
|
} |
38
|
|
|
if (!function_exists('fusion_builder_frontend_data')) { |
39
|
|
|
return; |
40
|
|
|
} |
41
|
|
|
$instance = glsr(static::shortcodeClass()); |
42
|
|
|
$parameters = static::elementParameters(); |
43
|
|
|
$parameters = glsr()->filterArray("fusion-builder/controls/{$instance->tag}", $parameters); |
44
|
|
|
fusion_builder_map(fusion_builder_frontend_data(static::class, [ |
45
|
|
|
'name' => $instance->name, |
46
|
|
|
'shortcode' => $instance->tag, |
47
|
|
|
'icon' => static::shortcodeIcon(), |
48
|
|
|
'params' => $parameters, |
49
|
|
|
// 'callback' => [ |
50
|
|
|
// 'action' => glsr()->prefix.'fusion_get_query', |
51
|
|
|
// 'ajax' => true, |
52
|
|
|
// 'function' => 'fusion_ajax', |
53
|
|
|
// ], |
54
|
|
|
])); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
abstract protected static function shortcodeIcon(): string; |
58
|
|
|
|
59
|
|
|
protected static function settingsConfig(): array |
60
|
|
|
{ |
61
|
|
|
return glsr(static::shortcodeClass())->settings(); |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
protected static function styleConfig(): array |
65
|
|
|
{ |
66
|
|
|
return []; |
67
|
|
|
} |
68
|
|
|
} |
69
|
|
|
|