Plugin Directory

Changeset 3224019


Ignore:
Timestamp:
01/17/2025 08:28:40 AM (14 months ago)
Author:
dashamail
Message:

Update to v.1.0.8

Location:
dashamail
Files:
21 added
5 edited

Legend:

Unmodified
Added
Removed
  • dashamail/trunk/README.txt

    r3146503 r3224019  
    55Tags: email, subsciption, dashamail, mail, dasha
    66Requires at least: 6.2.2
    7 Tested up to: 6.6.1
     7Tested up to: 6.7.1
    88Requires PHP: 7.4
    9 Stable tag: 1.0.8
     9Stable tag: 1.0.9
    1010License: GPLv2 or later
    1111License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    4646
    4747== Changelog ==
     48= 1.0.9 - 2025-01-17 =
     49FIX Увеличено время выполнения закпроса к API Dashamail
     50
    4851= 1.0.8 - 2024-09-04 =
    4952FIX Оптимизированы запросы к API Dashamail
  • dashamail/trunk/dashamail.php

    r3146503 r3224019  
    33 * Plugin Name:       DashaMail
    44 * Description:       Плагин интеграции с DashaMail
    5  * Version:           1.0.8
     5 * Version:           1.0.9
    66 * Requires at least: 6.2.2
    77 * Requires PHP:      7.4
  • dashamail/trunk/dshm_app/Infrastructure/dshm_DashaMailAPI.php

    r3037701 r3224019  
    2222    {
    2323        $url = self::dshm_getURL('lists.get', $apiKey, $param);
    24 
    25         $response = \wp_remote_get($url);
    26        
     24        $response = \wp_remote_get($url, ['timeout' => 30]);
     25
    2726        if (!is_wp_error($response) && is_array($response) && isset($response['body'])){
    2827            $json = json_decode($response['body'], true);
     
    3332    }
    3433
    35     public static function dshm_isApiKeyCorrect($apiKey):bool
    36     {
    37         if (empty($apiKey) || $apiKey === false){
    38             return false;
    39         }
    40 
     34    public static function dshm_getBalanceAccount($apiKey): ?array
     35    {
     36        $url = self::dshm_getURL('account.get_balance', $apiKey);
     37        $response = \wp_remote_get($url, ['timeout' => 30]);
     38
     39        if (!is_wp_error($response) && is_array($response) && isset($response['body'])){
     40            $json = json_decode($response['body'], true);
     41            return $json['response'];
     42        }
     43
     44        return null;
     45    }
     46
     47    public static function dshm_isApiKeyCorrect($apiKey): bool
     48    {
     49        if (empty($apiKey) || $apiKey === false) return false;
     50       
     51        $response = self::dshm_getBalanceAccount($apiKey);
     52
     53        if  (!$response || !isset($response['msg']) || !isset($response['msg']['err_code']))
     54            return false;
     55
     56        return $response['msg']['err_code'] === 0;
     57    }
     58
     59    public static function dshm_getDashaMailLists(string $apiKey):array
     60    {
    4161        $response = self::dshm_getResponseDashaMailLists($apiKey);
    42         if ($response) {
    43             return $response['msg']['err_code'] === 0;
    44         }
    45 
    46         return false;
    47     }
    48 
    49     public static function dshm_getDashaMailLists(string $apiKey):array
    50     {
    51         $response = self::dshm_getResponseDashaMailLists($apiKey);
    52         if ($response) {
    53             return $response['data'];
    54         }
    55 
    56         return false;
     62       
     63        return ($response && isset($response['data']))
     64            ? $response['data']
     65            : [];
    5766    }
    5867
     
    6574        $url = self::dshm_getURL('lists.add_member_batch', $apiKey, $param);
    6675
    67         $response = \wp_remote_get($url);
     76        $response = \wp_remote_get($url, ['timeout' => 30]);
    6877        if (isset($response['body'])){
    6978            $json = json_decode($response['body'], true);
  • dashamail/trunk/dshm_app/Infrastructure/dshm_PluginActivator.php

    r3037701 r3224019  
    112112    {
    113113        $this->dshm_PrintShortcode($post->ID);
    114 
     114        $html = '';
    115115        $html .= \wp_nonce_field('save-post-'.$post->ID, 'dshm_nonce_sp', false);
    116116
  • dashamail/trunk/dshm_app/Infrastructure/dshm_SettingsPage.php

    r3146503 r3224019  
    6363        $url = $_POST['_wp_http_referer'] ?? $_SERVER['REQUEST_URI'];
    6464        if (!stripos($url, strval(self::$DSHM_PAGE_SLUG))) return;
    65        
     65
    6666        $this->isApiKeyCorrect = dshm_DashaMailAPI::dshm_isApiKeyCorrect($apiKey);
    6767    }
Note: See TracChangeset for help on using the changeset viewer.