|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace GeminiLabs\SiteReviews\Integrations\Elementor; |
|
4
|
|
|
|
|
5
|
|
|
use GeminiLabs\SiteReviews\Controllers\Controller as BaseController; |
|
6
|
|
|
use GeminiLabs\SiteReviews\Integrations\Elementor\Widgets\FormWidget; |
|
7
|
|
|
use GeminiLabs\SiteReviews\Integrations\Elementor\Widgets\ReviewsWidget; |
|
8
|
|
|
use GeminiLabs\SiteReviews\Integrations\Elementor\Widgets\SummaryWidget; |
|
9
|
|
|
|
|
10
|
|
|
class Controller extends BaseController |
|
11
|
|
|
{ |
|
12
|
|
|
/** |
|
13
|
|
|
* Fix Star Rating control when review form is used inside an Elementor Pro Popup. |
|
14
|
|
|
* @param string $script |
|
15
|
|
|
* @return string |
|
16
|
|
|
* @filter site-reviews/enqueue/public/inline-script/after |
|
17
|
|
|
*/ |
|
18
|
|
|
public function filterElementorPublicInlineScript($js) |
|
19
|
|
|
{ |
|
20
|
|
|
if (defined('ELEMENTOR_VERSION')) { |
|
21
|
|
|
$js .= 'function glsr_init_elementor(){GLSR.Event.trigger("site-reviews/init")}"undefined"!==typeof jQuery&&('; |
|
22
|
|
|
if (defined('ELEMENTOR_PRO_VERSION') && 0 > version_compare('2.7.0', ELEMENTOR_PRO_VERSION)) { |
|
23
|
|
|
$js .= 'jQuery(document).on("elementor/popup/show",glsr_init_elementor),'; |
|
24
|
|
|
} |
|
25
|
|
|
$js .= 'jQuery(window).on("elementor/frontend/init",function(){elementorFrontend.hooks.addAction("frontend/element_ready/site_reviews.default",glsr_init_elementor);elementorFrontend.hooks.addAction("frontend/element_ready/site_reviews_form.default",glsr_init_elementor)}));'; |
|
26
|
|
|
} |
|
27
|
|
|
return $js; |
|
28
|
|
|
} |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* Fix Star Rating CSS class prefix in the Elementor editor. |
|
32
|
|
|
* @return array |
|
33
|
|
|
* @filter site-reviews/defaults/star-rating/defaults |
|
34
|
|
|
*/ |
|
35
|
7 |
|
public function filterElementorStarRatingDefaults(array $defaults) |
|
36
|
|
|
{ |
|
37
|
7 |
|
if ('elementor' === filter_input(INPUT_GET, 'action')) { |
|
38
|
|
|
$defaults['prefix'] = 'glsr-'; |
|
39
|
|
|
} |
|
40
|
7 |
|
return $defaults; |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* @return void |
|
45
|
|
|
* @action elementor/init |
|
46
|
|
|
*/ |
|
47
|
|
|
public function registerElementorCategory() |
|
48
|
|
|
{ |
|
49
|
|
|
\Elementor\Plugin::instance()->elements_manager->add_category(glsr()->id, [ |
|
50
|
|
|
'title' => glsr()->name, |
|
51
|
|
|
'icon' => 'eicon-star-o', // default icon |
|
52
|
|
|
]); |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
/** |
|
56
|
|
|
* @return void |
|
57
|
|
|
* @action elementor/widgets/widgets_registered |
|
58
|
|
|
*/ |
|
59
|
|
|
public function registerElementorWidgets() |
|
60
|
|
|
{ |
|
61
|
|
|
\Elementor\Plugin::instance()->widgets_manager->register_widget_type( |
|
62
|
|
|
new FormWidget() |
|
63
|
|
|
); |
|
64
|
|
|
\Elementor\Plugin::instance()->widgets_manager->register_widget_type( |
|
65
|
|
|
new ReviewsWidget() |
|
66
|
|
|
); |
|
67
|
|
|
\Elementor\Plugin::instance()->widgets_manager->register_widget_type( |
|
68
|
|
|
new SummaryWidget() |
|
69
|
|
|
); |
|
70
|
|
|
} |
|
71
|
|
|
} |
|
72
|
|
|
|