PluginProbe
ووسلام – همگام سازی ووکامرس و باسلام / 1.8.6
ووسلام – همگام سازی ووکامرس و باسلام v1.8.6
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 1.10.1 1.10.0 1.9.2 1.9.1 1.9.0 1.8.8 1.8.5 1.8.6 All 53 releases
sync-basalam / includes / Admin / Settings / SettingsPageHandler.php

SettingsPageHandler.php in ووسلام – همگام سازی ووکامرس و باسلام 1.8.6, at includes/Admin/Settings/SettingsPageHandler.php

64 lines 1.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace SyncBasalam\Admin\Settings;
4
5 use SyncBasalam\Queue\Tasks\Debug;
6 use SyncBasalam\Actions\Controller\ProductActions\CancelDebug;
7 use SyncBasalam\Services\WebhookService;
8 use SyncBasalam\Services\VendorInfoService;
9
10 defined('ABSPATH') || exit;
11
12 class SettingsPageHandler
13 {
14 public static function saveSettings()
15 {
16 $data = isset($_POST['sync_basalam_settings']) ? array_map('sanitize_text_field', wp_unslash($_POST['sync_basalam_settings'])) : [];
17
18 if ($data) {
19 SettingsManager::updateSettings($data);
20
21 if (!empty($data[SettingsConfig::DEVELOPER_MODE]) && $data[SettingsConfig::DEVELOPER_MODE] === 'true') {
22 $debugTask = new Debug();
23 $debugTask->schedule();
24 } else {
25 (new CancelDebug())();
26 }
27 }
28
29 if (isset($_POST['get_token']) && $_POST['get_token'] == 1) {
30 self::redirectToOAuth();
31 }
32 }
33
34 private static function redirectToOAuth()
35 {
36 $OAuthManger = new OAuthManager();
37 $oauthUrls = $OAuthManger->getOAuthUrls();
38
39 wp_redirect($oauthUrls['url_req_token']);
40 exit();
41 }
42
43 public static function handleOauthCallback()
44 {
45 $oauthSaved = OAuthManager::saveOauthData();
46
47 if ($oauthSaved) {
48 $webhookService = new WebhookService();
49 $webhookService->setupWebhook();
50 $vendorInfoService = new VendorInfoService();
51 $vendorInfoService->FetchVendorInfo();
52 }
53
54 $onboardingCompleted = get_option('sync_basalam_onboarding_completed');
55
56 if (!$onboardingCompleted) {
57 wp_redirect(admin_url('admin.php?page=basalam-onboarding&step=3'));
58 } else {
59 wp_redirect(admin_url('admin.php?page=sync_basalam'));
60 }
61 exit();
62 }
63 }
64