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
|
|
|
['interceptGetPostsQuery', 'breakdance_ajax_breakdance_get_posts', 1], |
28
|
|
|
['interceptGetPostsQuery', 'wp_ajax_breakdance_get_posts', 1], |
29
|
|
|
['interceptGetPostsQuery', 'wp_ajax_nopriv_breakdance_get_posts', 1], |
30
|
|
|
['printInlineStyles', 'unofficial_i_am_kevin_geary_master_of_all_things_css_and_html'], |
31
|
|
|
['registerDesignControls', 'init'], |
32
|
|
|
['registerElements', 'breakdance_loaded', 5], |
33
|
|
|
['registerRoutes', 'breakdance_loaded'], |
34
|
|
|
]); |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
protected function isInstalled(): bool |
38
|
|
|
{ |
39
|
|
|
return class_exists('Breakdance\Elements\Element') |
40
|
|
|
&& function_exists('Breakdance\AJAX\get_nonce_for_ajax_requests') |
41
|
|
|
&& function_exists('Breakdance\AJAX\get_nonce_key_for_ajax_requests') |
42
|
|
|
&& function_exists('Breakdance\AJAX\register_handler') |
43
|
|
|
&& function_exists('Breakdance\Elements\c') |
44
|
|
|
&& function_exists('Breakdance\Elements\PresetSections\getPresetSection') |
45
|
|
|
&& function_exists('Breakdance\Elements\registerCategory') |
46
|
|
|
&& function_exists('Breakdance\Permissions\hasMinimumPermission'); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
protected function supportedVersion(): string |
50
|
|
|
{ |
51
|
|
|
return '2.2.0'; |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
protected function version(): string |
55
|
|
|
{ |
56
|
|
|
return defined('__BREAKDANCE_VERSION') |
57
|
|
|
? (string) \__BREAKDANCE_VERSION |
|
|
|
|
58
|
|
|
: ''; |
59
|
|
|
} |
60
|
|
|
} |
61
|
|
|
|