PluginProbe
ووسلام – همگام سازی ووکامرس و باسلام / 1.10.28
ووسلام – همگام سازی ووکامرس و باسلام v1.10.28
1.10.28 1.1.26 1.10.27 1.10.24 1.10.25 1.10.23 1.10.22 1.10.21 1.10.19 1.10.20 1.10.18 1.10.17 1.10.15 1.10.14 1.10.13 1.10.12 1.10.10 1.10.9 1.10.8 1.10.7 1.10.6 1.10.5 1.10.4 1.10.3 1.10.2 All 61 releases
← All changes | includes/Admin/Settings/SettingsPageHandler.php +37 -7 1.10.8 → 1.10.28 View file →
@@ -5,8 +5,9 @@
5 5 use SyncBasalam\Queue\Tasks\Debug;
6 6 use SyncBasalam\Actions\Controller\ProductActions\CancelDebug;
7 7 use SyncBasalam\Services\WebhookService;
8 8 use SyncBasalam\Services\VendorInfoService;
9 +use SyncBasalam\Services\ScheduledProductSync;
9 10
10 11 defined('ABSPATH') || exit;
11 12
12 13 class SettingsPageHandler
@@ -15,11 +16,28 @@
15 16
16 17 public static function saveSettings()
17 18 {
18 19 $data = isset($_POST['sync_basalam_settings']) ? array_map('sanitize_text_field', wp_unslash($_POST['sync_basalam_settings'])) : [];
20 + $toggleProductSync = !empty($_POST['sync_basalam_toggle_product']);
19 21
22 + if ($toggleProductSync) {
23 + $nextStatus = !SettingsManager::getSettings(SettingsConfig::SYNC_STATUS_PRODUCT);
24 + $nextValue = $nextStatus ? '1' : '0';
25 + $data[SettingsConfig::SYNC_STATUS_PRODUCT] = $nextValue;
26 + $data[SettingsConfig::SYNC_STATUS_PRODUCT_CREATE] = $nextValue;
27 + $data[SettingsConfig::SYNC_STATUS_PRODUCT_UPDATE] = $nextValue;
28 + }
29 +
20 30 if ($data) {
21 - if (!SettingsManager::isProductUpdateSelectionValid($data)) {
31 + $syncToggleSubmitted = array_key_exists(SettingsConfig::SYNC_STATUS_PRODUCT, $data)
32 + || array_key_exists(SettingsConfig::SYNC_STATUS_PRODUCT_CREATE, $data)
33 + || array_key_exists(SettingsConfig::SYNC_STATUS_PRODUCT_UPDATE, $data);
34 + $candidateSettings = SettingsManager::sanitizeSettings($data);
35 +
36 + if (
37 + (!$syncToggleSubmitted || $candidateSettings[SettingsConfig::SYNC_STATUS_PRODUCT_UPDATE])
38 + && !SettingsManager::isProductUpdateSelectionValid($data)
39 + ) {
22 40 self::pushValidationError(SettingsConfig::CUSTOM_PRODUCT_UPDATE_REQUIRED_MESSAGE);
23 41 return false;
24 42 }
25 43
@@ -24,14 +42,20 @@
24 42 }
25 43
26 44 SettingsManager::updateSettings($data);
27 45
28 - if (!empty($data[SettingsConfig::DEVELOPER_MODE]) && $data[SettingsConfig::DEVELOPER_MODE] === 'true') {
29 - $debugTask = new Debug();
30 - $debugTask->schedule();
31 - } else {
32 - (new CancelDebug())();
46 + if (array_key_exists(SettingsConfig::AUTO_FULL_UPDATE_INTERVAL, $data)) {
47 + (new ScheduledProductSync())->ensureScheduled();
33 48 }
49 +
50 + if (array_key_exists(SettingsConfig::DEVELOPER_MODE, $data)) {
51 + if ($data[SettingsConfig::DEVELOPER_MODE] === 'true') {
52 + $debugTask = new Debug();
53 + $debugTask->schedule();
54 + } else {
55 + (new CancelDebug())();
56 + }
57 + }
34 58 }
35 59
36 60 if (isset($_POST['get_token']) && $_POST['get_token'] == 1) {
37 61 self::redirectToOAuth();
@@ -71,9 +95,15 @@
71 95
72 96 // Mark this authorization as started by the current (authenticated) admin
73 97 // so the OAuth callback can reject forged requests. This runs only after
74 98 // the nonce-protected settings POST, so it cannot be triggered cross-site.
75 - OAuthManager::issueOauthState();
99 + if (! OAuthManager::issueOauthState()) {
100 + wp_die(
101 + esc_html__('امکان شروع فرایند دریافت دسترسی وجود ندارد. لطفاً دوباره تلاش کنید.', 'sync-basalam'),
102 + esc_html__('خطای دریافت دسترسی', 'sync-basalam'),
103 + ['response' => 500]
104 + );
105 + }
76 106
77 107 wp_redirect($oauthUrls['url_req_token']); // phpcs:ignore WordPress.Security.SafeRedirect.wp_redirect_wp_redirect -- Intentional external/user-provided redirect.
78 108 exit();
79 109 }