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
Notice.php
65 lines
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * Notice |
| 5 | * |
| 6 | * @package WPDesk\FS\Compatibility |
| 7 | */ |
| 8 | namespace FSVendor\WPDesk\FS\Compatibility; |
| 9 | |
| 10 | /** |
| 11 | * Can display notice about incompatible plugins. |
| 12 | */ |
| 13 | class Notice |
| 14 | { |
| 15 | /** |
| 16 | * @var PluginCompatibilityChecker . |
| 17 | */ |
| 18 | private $plugin_compatibility_checker; |
| 19 | /** |
| 20 | * Notice constructor. |
| 21 | * |
| 22 | * @param PluginCompatibilityChecker $plugin_compatibility_checker . |
| 23 | */ |
| 24 | public function __construct(PluginCompatibilityChecker $plugin_compatibility_checker) |
| 25 | { |
| 26 | $this->plugin_compatibility_checker = $plugin_compatibility_checker; |
| 27 | } |
| 28 | /** |
| 29 | * Add hooks. |
| 30 | */ |
| 31 | public function hooks() |
| 32 | { |
| 33 | add_action('admin_notices', array($this, 'admin_notices')); |
| 34 | } |
| 35 | /** |
| 36 | * Display notices in admin. |
| 37 | */ |
| 38 | public function admin_notices() |
| 39 | { |
| 40 | $status = (bool) apply_filters('plugin_compatibility_checker/notice_added', \false); |
| 41 | if ($status) { |
| 42 | return; |
| 43 | } |
| 44 | add_filter('plugin_compatibility_checker/notice_added', '__return_true'); |
| 45 | $checker = $this->plugin_compatibility_checker; |
| 46 | $additional_info = ' ' . sprintf(__('If the WordPress updater hasn\'t informed you about the newer versions available, please %sfollow these instructions →%s', 'flexible-shipping'), sprintf('<a href="%s" target="_blank">', __('https://octol.io/fs-2-docs', 'flexible-shipping')), '</a>'); |
| 47 | if (!$checker->is_fs_compatible()) { |
| 48 | if ($checker->is_active_fs_pro() && $checker->is_fs_pro_compatible() && $checker->is_active_fs_loc() && $checker->is_fs_loc_compatible()) { |
| 49 | new \FSVendor\WPDesk\Notice\Notice(sprintf(__('%sFlexible Shipping%s plugin you are currently using is not compatible with the installed version of Flexible Shipping PRO and Flexible Shipping Locations. Please update the %sFlexible Shipping%s plugin to %s version or newer.', 'flexible-shipping'), '<strong>', '</strong>', '<strong>', '</strong>', $checker->fs->get_required_version()) . $additional_info, 'error'); |
| 50 | } elseif ($checker->is_active_fs_pro() && $checker->is_fs_pro_compatible()) { |
| 51 | new \FSVendor\WPDesk\Notice\Notice(sprintf(__('%sFlexible Shipping%s plugin you are currently using is not compatible with the installed version of Flexible Shipping PRO. Please update the %sFlexible Shipping%s plugin to %s version or newer.', 'flexible-shipping'), '<strong>', '</strong>', '<strong>', '</strong>', $checker->fs->get_required_version()) . $additional_info, 'error'); |
| 52 | } elseif ($checker->is_active_fs_loc() && $checker->is_fs_loc_compatible()) { |
| 53 | new \FSVendor\WPDesk\Notice\Notice(sprintf(__('%sFlexible Shipping%s plugin you are currently using is not compatible with the installed version of Flexible Shipping Locations. Please update the %sFlexible Shipping%s plugin to %s version or newer.', 'flexible-shipping'), '<strong>', '</strong>', '<strong>', '</strong>', $checker->fs->get_required_version()) . $additional_info, 'error'); |
| 54 | } |
| 55 | } else { |
| 56 | if (!$checker->is_fs_pro_compatible()) { |
| 57 | new \FSVendor\WPDesk\Notice\Notice(sprintf(__('%sFlexible Shipping PRO%s plugin you are currently using is not compatible with the installed version of Flexible Shipping free. Please update the %sFlexible Shipping PRO%s plugin to %s version or newer.', 'flexible-shipping'), '<strong>', '</strong>', '<strong>', '</strong>', $checker->fs_pro->get_required_version()) . $additional_info, 'error'); |
| 58 | } |
| 59 | if (!$checker->is_fs_loc_compatible()) { |
| 60 | new \FSVendor\WPDesk\Notice\Notice(sprintf(__('%sFlexible Shipping Locations%s plugin you are currently using is not compatible with the installed version of Flexible Shipping free. Please update the %sFlexible Shipping Locations%s plugin to %s version or newer.', 'flexible-shipping'), '<strong>', '</strong>', '<strong>', '</strong>', $checker->fs_loc->get_required_version()) . $additional_info, 'error'); |
| 61 | } |
| 62 | } |
| 63 | } |
| 64 | } |
| 65 |