1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace GeminiLabs\SiteReviews\Integrations\Flatsome; |
4
|
|
|
|
5
|
|
|
use GeminiLabs\SiteReviews\Hooks\AbstractHooks; |
6
|
|
|
use GeminiLabs\SiteReviews\Modules\Notice; |
7
|
|
|
|
8
|
|
|
class Hooks extends AbstractHooks |
9
|
|
|
{ |
10
|
|
|
public function run(): void |
11
|
|
|
{ |
12
|
|
|
if (!$this->isInstalled()) { |
13
|
|
|
return; |
14
|
|
|
} |
15
|
|
|
if (!$this->isVersionSupported()) { |
16
|
|
|
$this->unsupportedVersionNotice(); |
17
|
|
|
return; |
18
|
|
|
} |
19
|
|
|
$this->hook(Controller::class, [ |
20
|
|
|
['printInlineScripts', 'ux_builder_enqueue_scripts'], |
21
|
|
|
['printInlineStyles', 'ux_builder_enqueue_scripts'], |
22
|
|
|
['registerShortcodes', 'init'], |
23
|
|
|
['searchAssignedPosts', 'wp_ajax_ux_builder_search_posts', 1], |
24
|
|
|
['searchAssignedUsers', 'wp_ajax_ux_builder_search_posts', 2], |
25
|
|
|
]); |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
protected function isInstalled(): bool |
29
|
|
|
{ |
30
|
|
|
return 'flatsome' === wp_get_theme(get_template())->get('TextDomain'); |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
protected function isVersionSupported(): bool |
34
|
|
|
{ |
35
|
|
|
return version_compare(wp_get_theme(get_template())->get('Version'), '3.19.0', '>='); |
|
|
|
|
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
protected function unsupportedVersionNotice(): void |
39
|
|
|
{ |
40
|
|
|
add_action('admin_notices', function () { |
41
|
|
|
if (!str_starts_with(glsr_current_screen()->post_type, glsr()->post_type)) { |
42
|
|
|
return; |
43
|
|
|
} |
44
|
|
|
glsr(Notice::class)->addWarning( |
45
|
|
|
_x('Update the Flatsome theme to v3.19.0 or higher to enable integration with Site Reviews.', 'admin-text', 'site-reviews') |
46
|
|
|
); |
47
|
|
|
}); |
48
|
|
|
} |
49
|
|
|
} |
50
|
|
|
|