← All changes
|
includes/Admin/Settings/SettingsPageHandler.php
+19
-6
1.10.14
→
1.10.22
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 |
| @@ -24,14 +25,20 @@ | ||
| 24 | 25 | } |
| 25 | 26 | |
| 26 | 27 | SettingsManager::updateSettings($data); |
| 27 | 28 | |
| 28 | - if (!empty($data[SettingsConfig::DEVELOPER_MODE]) && $data[SettingsConfig::DEVELOPER_MODE] === 'true') { | |
| 29 | - $debugTask = new Debug(); | |
| 30 | - $debugTask->schedule(); | |
| 31 | - } else { | |
| 32 | - (new CancelDebug())(); | |
| 29 | + if (array_key_exists(SettingsConfig::AUTO_FULL_UPDATE_INTERVAL, $data)) { | |
| 30 | + (new ScheduledProductSync())->ensureScheduled(); | |
| 33 | 31 | } |
| 32 | + | |
| 33 | + if (array_key_exists(SettingsConfig::DEVELOPER_MODE, $data)) { | |
| 34 | + if ($data[SettingsConfig::DEVELOPER_MODE] === 'true') { | |
| 35 | + $debugTask = new Debug(); | |
| 36 | + $debugTask->schedule(); | |
| 37 | + } else { | |
| 38 | + (new CancelDebug())(); | |
| 39 | + } | |
| 40 | + } | |
| 34 | 41 | } |
| 35 | 42 | |
| 36 | 43 | if (isset($_POST['get_token']) && $_POST['get_token'] == 1) { |
| 37 | 44 | self::redirectToOAuth(); |
| @@ -71,9 +78,15 @@ | ||
| 71 | 78 | |
| 72 | 79 | // Mark this authorization as started by the current (authenticated) admin |
| 73 | 80 | // so the OAuth callback can reject forged requests. This runs only after |
| 74 | 81 | // the nonce-protected settings POST, so it cannot be triggered cross-site. |
| 75 | - OAuthManager::issueOauthState(); | |
| 82 | + if (! OAuthManager::issueOauthState()) { | |
| 83 | + wp_die( | |
| 84 | + esc_html__('امکان شروع فرایند دریافت دسترسی وجود ندارد. لطفاً دوباره تلاش کنید.', 'sync-basalam'), | |
| 85 | + esc_html__('خطای دریافت دسترسی', 'sync-basalam'), | |
| 86 | + ['response' => 500] | |
| 87 | + ); | |
| 88 | + } | |
| 76 | 89 | |
| 77 | 90 | wp_redirect($oauthUrls['url_req_token']); // phpcs:ignore WordPress.Security.SafeRedirect.wp_redirect_wp_redirect -- Intentional external/user-provided redirect. |
| 78 | 91 | exit(); |
| 79 | 92 | } |