Plugin Directory

Changeset 3088427


Ignore:
Timestamp:
05/17/2024 03:33:02 PM (23 months ago)
Author:
weboneco
Message:

notify to gholab api plugin status when active, deactive and update plugin

Location:
gholab/trunk/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • gholab/trunk/src/Controllers/MenuAndPageController.php

    r3088300 r3088427  
    134134                update_option('gholab_api_key'       , $gholabApiKey);
    135135                update_option('gholab_live_sync'     , 1);
     136                update_option('gholab_plugin_status' , 1);
    136137
    137138                wp_redirect(admin_url('admin.php?page=gholab'));
  • gholab/trunk/src/Gholab.php

    r3088300 r3088427  
    113113            if (! empty($gholabApiKey)) {
    114114                $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                }
    116121            }
    117122        });
     
    133138                $gholabService = $this->container->get(GholabService::class);
    134139                $gholabService->sendPluginStatusToGholab($gholabApiKey, false);
     140                update_option('gholab_plugin_status', 0);
    135141            }
    136142        });
  • gholab/trunk/src/Handlers/AdminHandler.php

    r3017916 r3088427  
    55use Gholab\Gholab\Container;
    66use Gholab\Gholab\Controllers\MenuAndPageController;
    7 use Gholab\Gholab\Data\SettingsRepo;
    87use Gholab\Gholab\Services\GholabService;
    98
     
    1514    protected $container;
    1615
    17     /**
    18      * @var SettingsRepo $settingsRepo
    19      */
    20     protected $settingsRepo;
    2116
    2217    /**
     
    4035    {
    4136        $this->container    = $container;
    42         $this->settingsRepo = $container->get(SettingsRepo::class);
    4337        $this->gholabService = $container->get(GholabService::class);
    4438    }
     
    8579            'همگام سازی آنی',
    8680            function () {
    87                 $status = $this->settingsRepo->getOption('gholab_live_sync');
     81                $status = get_option('gholab_live_sync');
    8882                $checked = 1 == $status ? 'checked' : '';
    8983                ?>
     
    10397            'همگام سازی زمانبندی',
    10498            function () {
    105                 $status = $this->settingsRepo->getOption('gholab_cron_sync');
     99                $status = get_option('gholab_cron_sync');
    106100                $checked = 1 == $status ? 'checked' : '';
    107                 $interval = $this->settingsRepo->getOption('gholab_cron_sync_interval', 'daily');
     101                $interval = get_option('gholab_cron_sync_interval', 'daily');
    108102                ?>
    109103
     
    127121        register_setting('gholab_settings', 'gholab_api_key', [
    128122            '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) {
    131127                    $apiKey = $oldApiKey;
    132128                    add_settings_error('gholab_api_key', 'gholab_message', 'توکن سایت قلاب نامعتبر است !!!');
     
    139135            'API Key',
    140136            function () {
    141                 $data = $this->settingsRepo->getOption('gholab_api_key');
     137                $data = get_option('gholab_api_key');
    142138                ?>
    143139                <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/>
     
    166162
    167163        foreach ($menuList as $menu) {
    168             if (!$this->settingsRepo->getOption('gholab_welcome_accept')) {
     164            if (! get_option('gholab_welcome_accept')) {
    169165                $menu[1] .= ' (فعالسازی) ';
    170166            }
Note: See TracChangeset for help on using the changeset viewer.