Changeset 3088427
- Timestamp:
- 05/17/2024 03:33:02 PM (23 months ago)
- Location:
- gholab/trunk/src
- Files:
-
- 3 edited
-
Controllers/MenuAndPageController.php (modified) (1 diff)
-
Gholab.php (modified) (2 diffs)
-
Handlers/AdminHandler.php (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
gholab/trunk/src/Controllers/MenuAndPageController.php
r3088300 r3088427 134 134 update_option('gholab_api_key' , $gholabApiKey); 135 135 update_option('gholab_live_sync' , 1); 136 update_option('gholab_plugin_status' , 1); 136 137 137 138 wp_redirect(admin_url('admin.php?page=gholab')); -
gholab/trunk/src/Gholab.php
r3088300 r3088427 113 113 if (! empty($gholabApiKey)) { 114 114 $gholabService = $this->container->get(GholabService::class); 115 $gholabService->sendPluginStatusToGholab($gholabApiKey, true); 115 $result = $gholabService->sendPluginStatusToGholab($gholabApiKey, true); 116 if ($result) { 117 update_option('gholab_plugin_status', 1); 118 } else { 119 update_option('gholab_plugin_status', 0); 120 } 116 121 } 117 122 }); … … 133 138 $gholabService = $this->container->get(GholabService::class); 134 139 $gholabService->sendPluginStatusToGholab($gholabApiKey, false); 140 update_option('gholab_plugin_status', 0); 135 141 } 136 142 }); -
gholab/trunk/src/Handlers/AdminHandler.php
r3017916 r3088427 5 5 use Gholab\Gholab\Container; 6 6 use Gholab\Gholab\Controllers\MenuAndPageController; 7 use Gholab\Gholab\Data\SettingsRepo;8 7 use Gholab\Gholab\Services\GholabService; 9 8 … … 15 14 protected $container; 16 15 17 /**18 * @var SettingsRepo $settingsRepo19 */20 protected $settingsRepo;21 16 22 17 /** … … 40 35 { 41 36 $this->container = $container; 42 $this->settingsRepo = $container->get(SettingsRepo::class);43 37 $this->gholabService = $container->get(GholabService::class); 44 38 } … … 85 79 'همگام سازی آنی', 86 80 function () { 87 $status = $this->settingsRepo->getOption('gholab_live_sync');81 $status = get_option('gholab_live_sync'); 88 82 $checked = 1 == $status ? 'checked' : ''; 89 83 ?> … … 103 97 'همگام سازی زمانبندی', 104 98 function () { 105 $status = $this->settingsRepo->getOption('gholab_cron_sync');99 $status = get_option('gholab_cron_sync'); 106 100 $checked = 1 == $status ? 'checked' : ''; 107 $interval = $this->settingsRepo->getOption('gholab_cron_sync_interval', 'daily');101 $interval = get_option('gholab_cron_sync_interval', 'daily'); 108 102 ?> 109 103 … … 127 121 register_setting('gholab_settings', 'gholab_api_key', [ 128 122 'sanitize_callback' => function($apiKey) { 129 $oldApiKey = $this->settingsRepo->getOption('gholab_api_key'); 130 if (!$this->gholabService->checkGholabToken($apiKey)) { 123 $oldApiKey = get_option('gholab_api_key'); 124 125 $result = $this->gholabService->sendPluginStatusToGholab($apiKey, (bool) get_option('gholab_plugin_status', false)); 126 if (! $result) { 131 127 $apiKey = $oldApiKey; 132 128 add_settings_error('gholab_api_key', 'gholab_message', 'توکن سایت قلاب نامعتبر است !!!'); … … 139 135 'API Key', 140 136 function () { 141 $data = $this->settingsRepo->getOption('gholab_api_key');137 $data = get_option('gholab_api_key'); 142 138 ?> 143 139 <input type='text' name='gholab_api_key' value='<?php echo esc_attr($data); ?>' class="gholab-setting-text" maxlength='<?php echo esc_attr(GHOLAB_MAX_LEN_API_KEY); ?>' required/> … … 166 162 167 163 foreach ($menuList as $menu) { 168 if (! $this->settingsRepo->getOption('gholab_welcome_accept')) {164 if (! get_option('gholab_welcome_accept')) { 169 165 $menu[1] .= ' (فعالسازی) '; 170 166 }
Note: See TracChangeset
for help on using the changeset viewer.