1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace GeminiLabs\SiteReviews\Integrations\Elementor\Widgets; |
4
|
|
|
|
5
|
|
|
use GeminiLabs\SiteReviews\Helpers\Cast; |
6
|
|
|
use GeminiLabs\SiteReviews\Integrations\Elementor\Widget; |
7
|
|
|
use GeminiLabs\SiteReviews\Modules\Rating; |
8
|
|
|
use GeminiLabs\SiteReviews\Shortcodes\SiteReviewsSummaryShortcode; |
9
|
|
|
|
10
|
|
|
class SummaryWidget extends Widget |
11
|
|
|
{ |
12
|
|
|
/** |
13
|
|
|
* @return string |
14
|
|
|
*/ |
15
|
|
|
public function get_shortcode() |
16
|
|
|
{ |
17
|
|
|
return SiteReviewsSummaryShortcode::class; |
18
|
|
|
} |
19
|
|
|
|
20
|
|
|
public function get_title() |
21
|
|
|
{ |
22
|
|
|
return _x('Rating Summary', 'admin-text', 'site-reviews'); |
23
|
|
|
} |
24
|
|
|
|
25
|
|
|
protected function settings_basic() |
26
|
|
|
{ |
27
|
|
|
$options = [ |
28
|
|
|
'assigned_posts' => [ |
29
|
|
|
'default' => '', |
30
|
|
|
'label' => _x('Limit Reviews to an Assigned Page', 'admin-text', 'site-reviews'), |
31
|
|
|
'label_block' => true, |
32
|
|
|
'options' => $this->assigned_posts_options(), |
33
|
|
|
'type' => \Elementor\Controls_Manager::SELECT2, |
34
|
|
|
], |
35
|
|
|
'assigned_posts_custom' => [ |
36
|
|
|
'condition' => ['assigned_posts' => 'custom'], |
37
|
|
|
'description' => _x('Separate with commas.', 'admin-text', 'site-reviews'), |
38
|
|
|
'label_block' => true, |
39
|
|
|
'placeholder' => _x('Enter the Post IDs', 'admin-text', 'site-reviews'), |
40
|
|
|
'show_label' => false, |
41
|
|
|
'type' => \Elementor\Controls_Manager::TEXT, |
42
|
|
|
], |
43
|
|
|
'assigned_terms' => [ |
44
|
|
|
'default' => '', |
45
|
|
|
'label' => _x('Limit Reviews to an Assigned Category', 'admin-text', 'site-reviews'), |
46
|
|
|
'label_block' => true, |
47
|
|
|
'multiple' => true, |
48
|
|
|
'options' => $this->assigned_terms_options(), |
49
|
|
|
'type' => \Elementor\Controls_Manager::SELECT2, |
50
|
|
|
], |
51
|
|
|
'assigned_users' => [ |
52
|
|
|
'default' => '', |
53
|
|
|
'label' => _x('Limit Reviews to an Assigned User', 'admin-text', 'site-reviews'), |
54
|
|
|
'label_block' => true, |
55
|
|
|
'multiple' => true, |
56
|
|
|
'options' => $this->assigned_users_options(), |
57
|
|
|
'type' => \Elementor\Controls_Manager::SELECT2, |
58
|
|
|
], |
59
|
|
|
'terms' => [ |
60
|
|
|
'default' => '', |
61
|
|
|
'label' => _x('Limit Reviews to terms', 'admin-text', 'site-reviews'), |
62
|
|
|
'label_block' => true, |
63
|
|
|
'options' => [ |
64
|
|
|
'true' => _x('Terms were accepted', 'admin-text', 'site-reviews'), |
65
|
|
|
'false' => _x('Terms were not accepted', 'admin-text', 'site-reviews'), |
66
|
|
|
], |
67
|
|
|
'type' => \Elementor\Controls_Manager::SELECT2, |
68
|
|
|
], |
69
|
|
|
'type' => $this->get_review_types(), |
70
|
|
|
'rating' => [ |
71
|
|
|
'default' => 0, |
72
|
|
|
'label' => _x('Minimum Rating', 'admin-text', 'site-reviews'), |
73
|
|
|
'max' => Cast::toInt(glsr()->constant('MAX_RATING', Rating::class)), |
74
|
|
|
'min' => Cast::toInt(glsr()->constant('MIN_RATING', Rating::class)), |
75
|
|
|
'separator' => 'before', |
76
|
|
|
'type' => \Elementor\Controls_Manager::NUMBER, |
77
|
|
|
], |
78
|
|
|
'schema' => [ |
79
|
|
|
'description' => _x('The schema should only be enabled once per page.', 'admin-text', 'site-reviews'), |
80
|
|
|
'label' => _x('Enable the schema?', 'admin-text', 'site-reviews'), |
81
|
|
|
'return_value' => 'true', |
82
|
|
|
'separator' => 'before', |
83
|
|
|
'type' => \Elementor\Controls_Manager::SWITCHER, |
84
|
|
|
], |
85
|
|
|
]; |
86
|
|
|
$hideOptions = $this->get_shortcode_instance()->getHideOptions(); |
87
|
|
|
foreach ($hideOptions as $key => $label) { |
88
|
|
|
$separator = $key === key(array_slice($hideOptions, 0, 1)) ? 'before' : 'default'; |
89
|
|
|
$options['hide-'.$key] = [ |
90
|
|
|
'label' => $label, |
91
|
|
|
'separator' => $separator, |
92
|
|
|
'return_value' => '1', |
93
|
|
|
'type' => \Elementor\Controls_Manager::SWITCHER, |
94
|
|
|
]; |
95
|
|
|
} |
96
|
|
|
return $options; |
97
|
|
|
} |
98
|
|
|
} |
99
|
|
|
|