← All changes
|
backend/src/Services/Integrations/PluginInstaller.php
+20
-1
0.9
→
1.5.1
View file →
| @@ -18,9 +18,10 @@ | ||
| 18 | 18 | * |
| 19 | 19 | * @var array<string, string> |
| 20 | 20 | */ |
| 21 | 21 | private array $allowedPlugins = [ |
| 22 | - 'wpdatatables' => 'wpdatatables/wpdatatables.php', | |
| 22 | + 'wpdatatables' => 'wpdatatables/wpdatatables.php', | |
| 23 | + 'ameliabooking' => 'ameliabooking/ameliabooking.php', | |
| 23 | 24 | ]; |
| 24 | 25 | |
| 25 | 26 | /** |
| 26 | 27 | * Check if plugin is allowed to be installed |
| @@ -55,8 +56,26 @@ | ||
| 55 | 56 | */ |
| 56 | 57 | public function isPluginInstalled(string $pluginFile): bool |
| 57 | 58 | { |
| 58 | 59 | return file_exists(WP_PLUGIN_DIR . '/' . $pluginFile); |
| 60 | + } | |
| 61 | + | |
| 62 | + /** | |
| 63 | + * Check if plugin is active | |
| 64 | + * | |
| 65 | + * @param string $pluginSlug | |
| 66 | + * | |
| 67 | + * @return bool | |
| 68 | + */ | |
| 69 | + public function isPluginActive(string $pluginSlug): bool | |
| 70 | + { | |
| 71 | + if (!function_exists('is_plugin_active')) { | |
| 72 | + require_once ABSPATH . 'wp-admin/includes/plugin.php'; | |
| 73 | + } | |
| 74 | + | |
| 75 | + $pluginFile = self::getPluginFile($pluginSlug); | |
| 76 | + | |
| 77 | + return $pluginFile !== null && is_plugin_active($pluginFile); | |
| 59 | 78 | } |
| 60 | 79 | |
| 61 | 80 | /** |
| 62 | 81 | * Activate a plugin |