|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace GeminiLabs\SiteReviews\Integrations\Flatsome; |
|
4
|
|
|
|
|
5
|
|
|
use GeminiLabs\SiteReviews\Contracts\ShortcodeContract; |
|
6
|
|
|
use GeminiLabs\SiteReviews\Helpers\Cast; |
|
7
|
|
|
|
|
8
|
|
|
abstract class FlatsomeShortcode |
|
9
|
|
|
{ |
|
10
|
|
|
abstract public function options(): array; |
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* Override the "add_ux_builder_shortcode" data with |
|
14
|
|
|
* the "ux_builder_shortcode_data_{$tag}" filter hook. |
|
15
|
|
|
*/ |
|
16
|
|
|
public function register(): void |
|
17
|
|
|
{ |
|
18
|
|
|
add_action('ux_builder_setup', function () { |
|
19
|
|
|
add_ux_builder_shortcode($this->shortcode()->shortcode, [ |
|
|
|
|
|
|
20
|
|
|
'category' => glsr()->name, |
|
21
|
|
|
// 'inline' => true, |
|
22
|
|
|
'name' => $this->name(), |
|
23
|
|
|
'options' => $this->options(), |
|
24
|
|
|
'thumbnail' => $this->icon(), |
|
25
|
|
|
'wrap' => false, |
|
26
|
|
|
]); |
|
27
|
|
|
}); |
|
28
|
|
|
} |
|
29
|
|
|
|
|
30
|
|
|
protected function hideOptions(): array |
|
31
|
|
|
{ |
|
32
|
|
|
return [ |
|
33
|
|
|
'hide' => [ |
|
34
|
|
|
'type' => 'select', |
|
35
|
|
|
'heading' => esc_html_x('Hide Fields', 'admin-text', 'site-reviews'), |
|
36
|
|
|
'description' => esc_html_x('Flatsome UX Builder does not support multiple checkboxes here so instead please use the dropdown to select fields that you want to hide.', 'admin-text', 'site-reviews'), |
|
37
|
|
|
'full_width' => true, |
|
38
|
|
|
'config' => [ |
|
39
|
|
|
'multiple' => true, |
|
40
|
|
|
'options' => $this->shortcode()->getHideOptions(), |
|
41
|
|
|
'placeholder' => esc_html_x('Select...', 'admin-text', 'site-reviews'), |
|
42
|
|
|
'sortable' => false, |
|
43
|
|
|
], |
|
44
|
|
|
], |
|
45
|
|
|
]; |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
abstract protected function icon(): string; |
|
49
|
|
|
|
|
50
|
|
|
protected function name(): string |
|
51
|
|
|
{ |
|
52
|
|
|
return $this->shortcode()->name; |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
abstract protected function shortcode(): ShortcodeContract; |
|
56
|
|
|
|
|
57
|
|
|
protected function typeOptions(): array |
|
58
|
|
|
{ |
|
59
|
|
|
$types = glsr()->retrieveAs('array', 'review_types', []); |
|
60
|
|
|
if (2 > count($types)) { |
|
61
|
|
|
return []; |
|
62
|
|
|
} |
|
63
|
|
|
return [ |
|
64
|
|
|
'type' => 'select', |
|
65
|
|
|
'heading' => esc_html_x('Limit Reviews by Type', 'admin-text', 'site-reviews'), |
|
66
|
|
|
'full_width' => true, |
|
67
|
|
|
'default' => 'local', |
|
68
|
|
|
'options' => $types, |
|
69
|
|
|
]; |
|
70
|
|
|
} |
|
71
|
|
|
} |
|
72
|
|
|
|