flexible-shipping
/
vendor_prefixed
/
wpdesk
/
wp-wpdesk-fs-compatibility
/
src
/
PluginCompatibilityChecker.php
views
1 week ago
BlockSettings.php
1 week ago
Notice.php
1 week ago
PluginCompatibility.php
1 week ago
PluginCompatibilityChecker.php
1 week ago
PluginDetails.php
1 week ago
PluginCompatibilityChecker.php
117 lines
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * Plugin Compatibility Checker |
| 5 | * |
| 6 | * @package WPDesk\FS\TableRate |
| 7 | */ |
| 8 | namespace FSVendor\WPDesk\FS\Compatibility; |
| 9 | |
| 10 | /** |
| 11 | * Class PluginCompatibilityChecker |
| 12 | * |
| 13 | * @package WPDesk\FS\TableRate |
| 14 | */ |
| 15 | class PluginCompatibilityChecker |
| 16 | { |
| 17 | /** |
| 18 | * @var PluginDetails . |
| 19 | */ |
| 20 | public $fs; |
| 21 | /** |
| 22 | * @var PluginDetails . |
| 23 | */ |
| 24 | public $fs_pro; |
| 25 | /** |
| 26 | * @var PluginDetails . |
| 27 | */ |
| 28 | public $fs_loc; |
| 29 | /** |
| 30 | * PluginCompatibilityChecker constructor. |
| 31 | */ |
| 32 | public function __construct() |
| 33 | { |
| 34 | $this->fs = new PluginDetails('flexible-shipping/flexible-shipping.php', 'FLEXIBLE_SHIPPING_VERSION', '4.0.0'); |
| 35 | $this->fs_pro = new PluginDetails('flexible-shipping-pro/flexible-shipping-pro.php', 'FLEXIBLE_SHIPPING_PRO_VERSION', '2.0.0'); |
| 36 | $this->fs_loc = new PluginDetails('flexible-shipping-locations/flexible-shipping-locations.php', 'FLEXIBLE_SHIPPING_LOCATIONS_VERSION', '2.0.0'); |
| 37 | } |
| 38 | /** |
| 39 | * @return bool |
| 40 | */ |
| 41 | public function is_active_fs() |
| 42 | { |
| 43 | return $this->fs->is_active(); |
| 44 | } |
| 45 | /** |
| 46 | * @return bool |
| 47 | */ |
| 48 | public function is_active_fs_pro() |
| 49 | { |
| 50 | return $this->fs_pro->is_active(); |
| 51 | } |
| 52 | /** |
| 53 | * @return bool |
| 54 | */ |
| 55 | public function is_active_fs_loc() |
| 56 | { |
| 57 | return $this->fs_loc->is_active(); |
| 58 | } |
| 59 | /** |
| 60 | * @return bool |
| 61 | */ |
| 62 | public function are_plugins_compatible() |
| 63 | { |
| 64 | return $this->is_fs_compatible() && $this->is_fs_pro_compatible() && $this->is_fs_loc_compatible(); |
| 65 | } |
| 66 | /** |
| 67 | * @return bool |
| 68 | */ |
| 69 | public function is_fs_compatible() |
| 70 | { |
| 71 | return $this->check_plugin($this->fs); |
| 72 | } |
| 73 | /** |
| 74 | * @return bool |
| 75 | */ |
| 76 | public function is_fs_pro_compatible() |
| 77 | { |
| 78 | return $this->check_plugin($this->fs_pro); |
| 79 | } |
| 80 | /** |
| 81 | * @return bool |
| 82 | */ |
| 83 | public function is_fs_loc_compatible() |
| 84 | { |
| 85 | return $this->check_plugin($this->fs_loc); |
| 86 | } |
| 87 | /** |
| 88 | * @return array |
| 89 | */ |
| 90 | public function get_list_of_incompatible_plugins() |
| 91 | { |
| 92 | $plugins_list = []; |
| 93 | if (!$this->is_fs_compatible()) { |
| 94 | $plugins_list[] = __('Flexible Shipping', 'flexible-shipping'); |
| 95 | } |
| 96 | if (!$this->is_fs_pro_compatible()) { |
| 97 | $plugins_list[] = __('Flexible Shipping PRO', 'flexible-shipping'); |
| 98 | } |
| 99 | if (!$this->is_fs_loc_compatible()) { |
| 100 | $plugins_list[] = __('Flexible Shipping Locations', 'flexible-shipping'); |
| 101 | } |
| 102 | return $plugins_list; |
| 103 | } |
| 104 | /** |
| 105 | * @param PluginDetails $plugin . |
| 106 | * |
| 107 | * @return bool |
| 108 | */ |
| 109 | private function check_plugin($plugin) |
| 110 | { |
| 111 | if (!$plugin->is_active()) { |
| 112 | return \true; |
| 113 | } |
| 114 | return $plugin->is_compatible(); |
| 115 | } |
| 116 | } |
| 117 |