Total Complexity | 13 |
Total Lines | 51 |
Duplicated Lines | 0 % |
Coverage | 0% |
Changes | 6 | ||
Bugs | 4 | Features | 1 |
1 | <?php |
||
7 | class Hooks implements HooksContract |
||
8 | { |
||
9 | /** |
||
10 | * @return void |
||
11 | */ |
||
12 | public function run() |
||
13 | { |
||
14 | $dir = glsr()->path('plugin/Hooks'); |
||
15 | if (!is_dir($dir)) { |
||
16 | return; |
||
17 | } |
||
18 | $iterator = new \DirectoryIterator($dir); |
||
19 | foreach ($iterator as $fileinfo) { |
||
20 | if (!$fileinfo->isFile()) { |
||
21 | continue; |
||
22 | } |
||
23 | try { |
||
24 | $hooks = '\GeminiLabs\SiteReviews\Hooks\\'.$fileinfo->getBasename('.php'); |
||
25 | $reflect = new \ReflectionClass($hooks); |
||
26 | if ($reflect->isInstantiable()) { |
||
27 | glsr()->singleton($hooks); |
||
28 | glsr($hooks)->run(); |
||
29 | } |
||
30 | } catch (\ReflectionException $e) { |
||
31 | glsr_log()->error($e->getMessage()); |
||
32 | } |
||
33 | } |
||
34 | add_action('plugins_loaded', [$this, 'runIntegrations'], 100); // run after all add-ons have loaded |
||
35 | } |
||
36 | |||
37 | /** |
||
38 | * @return void |
||
39 | */ |
||
40 | public function runIntegrations() |
||
58 | } |
||
59 | } |
||
62 |