/**
  * Initialize of setting values for admin user
  */
 public static function init()
 {
     self::$customizations = get_option('wc_sendinblue_settings', array());
     $general_settings = get_option('ws_main_option');
     self::$access_key = isset($general_settings['access_key']) ? $general_settings['access_key'] : '';
     $error_settings = get_option('ws_error_type', array());
     self::$ws_error_type = isset($error_settings['error_type']) ? $error_settings['error_type'] : '';
     delete_option('ws_error_type');
     if (!class_exists('Mailin')) {
         require_once 'mailin.php';
     }
     //to connect and get account details and lists
     if (self::$access_key != '') {
         try {
             $account = new Mailin(self::sendinblue_api_url, self::$access_key);
         } catch (Exception $e) {
             $account = null;
             self::$access_key = null;
             update_option('ws_main_option', self::$access_key);
         }
         // get lists
         self::$lists = get_transient('wswcsblist_' . md5(self::$access_key));
         if (!self::$lists) {
             $data = array();
             self::$lists = $account->get_lists($data);
             $list_data = array();
             foreach (self::$lists['data'] as $list) {
                 $list_data[$list['id']] = $list['name'];
             }
             self::$lists = $list_data;
             if (sizeof(self::$lists) > 0) {
                 set_transient('wswcsblist_' . md5(self::$access_key), self::$lists, 60 * 60 * 1);
             }
         }
         // get templates
         self::$templates = get_transient('wstemplate_' . md5(self::$access_key));
         if (!self::$templates) {
             $data = array('type' => 'template', 'status' => 'temp_active');
             $templates = $account->get_campaigns_v2($data);
             $template_data = array();
             if ($templates['code'] == 'success') {
                 foreach ($templates['data']['campaign_records'] as $template) {
                     $template_data[$template['id']] = array('name' => $template['campaign_name'], 'content' => $template['html_content']);
                 }
             }
             self::$templates = $template_data;
             if (sizeof(self::$templates) > 0) {
                 set_transient('wstemplate_' . md5(self::$access_key), self::$templates, 60 * 60 * 1);
             }
             update_option('ws_templates', $template_data);
         }
         self::$dopt_templates = get_transient('wsdopttemplate_' . md5(self::$access_key));
         if (!self::$dopt_templates) {
             $dopt_template = array('0' => 'Default');
             // for double opt-in
             foreach (self::$templates as $id => $template) {
                 if (strpos($template['content'], '[DOUBLEOPTIN]') !== false) {
                     $dopt_template[$id] = $template['name'];
                 }
             }
             self::$dopt_templates = $dopt_template;
             if (sizeof(self::$dopt_templates) > 0) {
                 set_transient('wsdopttemplate_' . md5(self::$access_key), self::$dopt_templates, 60 * 60 * 1);
             }
         }
         // get account's info
         self::$account_info = get_transient('wswcsbcredit_' . md5(self::$access_key));
         if (!self::$account_info) {
             self::$account_info = array();
             $account_info = $account->get_account();
             $count = count($account_info['data']);
             $account_data = array();
             foreach ($account_info['data'] as $key => $info) {
                 if (isset($info['plan_type']) && isset($info['credits'])) {
                     $account_data[$key]['plan_type'] = $info['plan_type'];
                     $account_data[$key]['credits'] = $info['credits'];
                 }
             }
             self::$account_info['SMS_credits'] = $account_data[1];
             self::$account_info['email_credits'] = $account_data[0];
             self::$account_info['user_name'] = $account_info['data'][$count - 1]['first_name'] . ' ' . $account_info['data'][$count - 1]['last_name'];
             self::$account_info['email'] = $account_info['data'][$count - 1]['email'];
             $settings = array('access_key' => self::$access_key, 'account_email' => self::$account_info['email']);
             update_option('ws_main_option', $settings);
             if (sizeof(self::$lists) > 0) {
                 set_transient('wswcsbcredit_' . md5(self::$access_key), self::$account_info, 60 * 60 * 1);
             }
         }
         // get statistics
         self::get_templates();
         // option - ws_email_templates
         self::$statistics = array();
         $startDate = $endDate = date("Y-m-d");
         // format: "Y-m-d";
         if (isset($_GET['section']) && $_GET['section'] == '' || !isset($_GET['section'])) {
             self::get_statistics($account, $startDate, $endDate);
         }
         // get senders from wp
         $blogusers = get_users('role=Administrator');
         $senders = array('-1' => '- Select a sender -');
         foreach ($blogusers as $user) {
             $senders[$user->user_nicename] = $user->user_email;
         }
         self::$senders = $senders;
     }
 }