| @@ -1,4 +1,4 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | use SyncBasalam\Plugin; |
| 4 | 4 | use SyncBasalam\Admin\Settings\SettingsContainer; |
| @@ -5,8 +5,10 @@ | ||
| 5 | 5 | use SyncBasalam\Activator; |
| 6 | 6 | use SyncBasalam\JobsRunner; |
| 7 | 7 | use SyncBasalam\Infrastructure\Container\AppServiceProvider; |
| 8 | 8 | use SyncBasalam\Infrastructure\Container\Container; |
| 9 | +use SyncBasalam\Services\ForceUpdateGate; | |
| 10 | +use SyncBasalam\Services\VendorSyncPolicy; | |
| 9 | 11 | |
| 10 | 12 | defined('ABSPATH') || exit; |
| 11 | 13 | |
| 12 | 14 | /** |
| @@ -11,12 +13,12 @@ | ||
| 11 | 13 | |
| 12 | 14 | /** |
| 13 | 15 | * Plugin Name: sync basalam | ووسلام |
| 14 | 16 | * Description: با استفاده از پلاگین ووسلام میتوایند تمامی محصولات ووکامرس را با یک کلیک به غرفه باسلامی خود اضافه کنید، همچنین تمامی سفارش باسلامی شما به سایت شما اضافه میگردد. |
| 15 | - * Version: 1.10.3 | |
| 17 | + * Version: 1.10.21 | |
| 16 | 18 | * Author: Woosalam Dev |
| 17 | - * Author URI: https://wp.hamsalam.ir/ | |
| 18 | - * Plugin URI: https://wp.hamsalam.ir | |
| 19 | + * Author URI: https://hamsalam.ir/wp | |
| 20 | + * Plugin URI: https://hamsalam.ir/wp | |
| 19 | 21 | * Text Domain: sync-basalam |
| 20 | 22 | * WC requires at least: 10.0.0 |
| 21 | 23 | * WC tested up to: 9.9.5 |
| 22 | 24 | * Requires Plugins: woocommerce |
| @@ -26,8 +28,9 @@ | ||
| 26 | 28 | |
| 27 | 29 | require_once __DIR__ . '/vendor/autoload.php'; |
| 28 | 30 | |
| 29 | 31 | register_activation_hook(__FILE__, 'syncBasalamActivatePlugin'); |
| 32 | +register_deactivation_hook(__FILE__, 'syncBasalamDeactivatePlugin'); | |
| 30 | 33 | |
| 31 | 34 | add_action('before_woocommerce_init', function () { |
| 32 | 35 | if (class_exists(\Automattic\WooCommerce\Utilities\FeaturesUtil::class)) { |
| 33 | 36 | \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility('custom_order_tables', __FILE__, true); |
| @@ -33,16 +36,23 @@ | ||
| 33 | 36 | \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility('custom_order_tables', __FILE__, true); |
| 34 | 37 | } |
| 35 | 38 | }); |
| 36 | 39 | |
| 37 | -if (get_option('sync_basalam_force_update')) { | |
| 40 | +$forceUpdate = get_option('sync_basalam_force_update'); | |
| 41 | +$installedVersion = (string) (get_option('sync_basalam_version') ?: '0.0.0'); | |
| 42 | + | |
| 43 | +if (ForceUpdateGate::shouldBlock($forceUpdate, $installedVersion, Plugin::VERSION)) { | |
| 38 | 44 | add_action('admin_notices', function () { |
| 39 | 45 | $template = __DIR__ . '/templates/notifications/ForceUpdateAlert.php'; |
| 40 | 46 | require_once $template; |
| 41 | - }); | |
| 47 | + }); | |
| 42 | 48 | return; |
| 43 | 49 | } |
| 44 | 50 | |
| 51 | +if ($forceUpdate) { | |
| 52 | + delete_option('sync_basalam_force_update'); | |
| 53 | +} | |
| 54 | + | |
| 45 | 55 | add_action('init', 'syncBasalamPlugin'); |
| 46 | 56 | |
| 47 | 57 | function syncBasalamContainer() |
| 48 | 58 | { |
| @@ -70,8 +80,15 @@ | ||
| 70 | 80 | |
| 71 | 81 | function syncBasalamActivatePlugin() |
| 72 | 82 | { |
| 73 | 83 | Activator::activate(); |
| 84 | + syncBasalamContainer()->get(VendorSyncPolicy::class)->ensureScheduled(); | |
| 74 | 85 | set_transient('sync_basalam_just_activated', true, 10); |
| 75 | 86 | } |
| 76 | 87 | |
| 88 | +function syncBasalamDeactivatePlugin() | |
| 89 | +{ | |
| 90 | + VendorSyncPolicy::unschedule(); | |
| 91 | +} | |
| 92 | + | |
| 77 | 93 | syncBasalamContainer()->get(JobsRunner::class); |
| 94 | +syncBasalamContainer()->get(VendorSyncPolicy::class)->registerHooks(); | |