1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace GeminiLabs\SiteReviews\Integrations\Breakdance; |
4
|
|
|
|
5
|
|
|
use GeminiLabs\SiteReviews\Integrations\IntegrationHooks; |
6
|
|
|
|
7
|
|
|
class Hooks extends IntegrationHooks |
8
|
|
|
{ |
9
|
|
|
public function hasPluginsLoaded(): bool |
10
|
|
|
{ |
11
|
|
|
return true; |
12
|
|
|
} |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* @action plugins_loaded:0 |
16
|
|
|
*/ |
17
|
|
|
public function onPluginsLoaded(): void |
18
|
|
|
{ |
19
|
|
|
if (!$this->isInstalled()) { |
20
|
|
|
return; |
21
|
|
|
} |
22
|
|
|
if (!$this->isVersionSupported()) { |
23
|
|
|
$this->notify('Breakdance'); |
24
|
|
|
return; |
25
|
|
|
} |
26
|
|
|
$this->hook(Controller::class, [ |
27
|
|
|
['registerElements', 'breakdance_loaded', 5], |
28
|
|
|
// Unfortunately we can't perform this action yet because Breakdance |
29
|
|
|
// does not support AJAX searching in multiselect controls. |
30
|
|
|
// ['registerRoutes', 'breakdance_loaded'], |
31
|
|
|
['searchAssignedPosts', 'breakdance_ajax_breakdance_get_posts', 1], |
32
|
|
|
['searchAssignedPosts', 'wp_ajax_breakdance_get_posts', 1], |
33
|
|
|
['searchAssignedPosts', 'wp_ajax_nopriv_breakdance_get_posts', 1], |
34
|
|
|
['searchAssignedTerms', 'breakdance_ajax_breakdance_get_posts', 1], |
35
|
|
|
['searchAssignedTerms', 'wp_ajax_breakdance_get_posts', 1], |
36
|
|
|
['searchAssignedTerms', 'wp_ajax_nopriv_breakdance_get_posts', 1], |
37
|
|
|
['searchAssignedUsers', 'breakdance_ajax_breakdance_get_posts', 1], |
38
|
|
|
['searchAssignedUsers', 'wp_ajax_breakdance_get_posts', 1], |
39
|
|
|
['searchAssignedUsers', 'wp_ajax_nopriv_breakdance_get_posts', 1], |
40
|
|
|
['searchPostId', 'breakdance_ajax_breakdance_get_posts', 1], |
41
|
|
|
['searchPostId', 'wp_ajax_breakdance_get_posts', 1], |
42
|
|
|
['searchPostId', 'wp_ajax_nopriv_breakdance_get_posts', 1], |
43
|
|
|
]); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
protected function isInstalled(): bool |
47
|
|
|
{ |
48
|
|
|
return class_exists('Breakdance\Elements\Element') |
49
|
|
|
&& function_exists('Breakdance\AJAX\get_nonce_for_ajax_requests') |
50
|
|
|
&& function_exists('Breakdance\AJAX\get_nonce_key_for_ajax_requests') |
51
|
|
|
&& function_exists('Breakdance\AJAX\register_handler') |
52
|
|
|
&& function_exists('Breakdance\Elements\registerCategory') |
53
|
|
|
&& function_exists('Breakdance\Permissions\hasMinimumPermission'); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
protected function supportedVersion(): string |
57
|
|
|
{ |
58
|
|
|
return '2.2.0'; |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
protected function version(): string |
62
|
|
|
{ |
63
|
|
|
return defined('__BREAKDANCE_VERSION') |
64
|
|
|
? (string) \__BREAKDANCE_VERSION |
|
|
|
|
65
|
|
|
: ''; |
66
|
|
|
} |
67
|
|
|
} |
68
|
|
|
|