-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathislamqa-advanced.php
47 lines (38 loc) · 1.45 KB
/
islamqa-advanced.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
/**
* Plugin Name: IslamQA Advanced
* Description: A WordPress plugin to extend WPGrapQL functionalites.
* Version: 0.1.0
* Author: Mohammad Jaqmaqji
* Author URI: https://github.com/mohjak
* License: MIT
* License URI: https://github.com/mohjak/islamqa-advanced/LICENSE
*/
add_action('plugins_loaded', function () {
$autoload = plugin_dir_path(__FILE__) . 'vendor/autoload.php';
$dependencies = [
'Composer autoload files' => is_readable($autoload),
'WPGraphQL' => class_exists('WPGraphQL'),
];
$missing_dependencies = array_keys(array_diff($dependencies, array_filter($dependencies)));
$display_admin_notice = function () use ($missing_dependencies) {
?>
<div class="notice notice-error">
<p>The IslamQA core plugin can't be loaded because these dependencies are missing:</p>
<ul>
<?php foreach ($missing_dependencies as $missing_dependency) : ?>
<li><?php echo esc_html($missing_dependency); ?></li>
<?php endforeach; ?>
</ul>
</div>
<?php
};
// If dependencies are missing, display admin notice and return early.
if ($missing_dependencies) {
add_action('admin_notices', $display_admin_notice);
add_action('network_admin_notices', $display_admin_notice); // Needed for multisite only.
return;
}
require_once $autoload;
(new IslamQA\IslamQA() )->run();
});