/** * Class constructor * Sets plugin url and directory and adds hooks to <i>init</i>. <i>admin_menu</i> */ function __construct() { // get basic info self::$plugin_dir = plugin_dir_path(__FILE__); self::$plugin_url = plugins_url('', __FILE__); self::$plugin_name = plugin_basename(__FILE__); // api details for sendinblue $general_settings = get_option(self::main_option_name, array()); self::$access_key = $general_settings['access_key']; self::$secret_key = $general_settings['secret_key']; $access_token_settings = get_option(self::access_token_option_name, array()); self::$access_token = $access_token_settings['access_token']; // list id $home_options = get_option(self::home_option_name, array()); self::$list_id = $home_options['list_id']; self::$activate_email = $home_options['activate_email']; // get sign up parameters $signup_settings = get_option(self::form_signup_option_name, array()); self::$is_confirm_email = $signup_settings['is_confirm_email']; self::$is_double_optin = $signup_settings['is_double_optin']; self::$redirect_url = $signup_settings['redirect_url']; self::$redirect_url_click = $signup_settings['redirect_url_click']; self::$is_redirect_url_click = $signup_settings['is_redirect_url_click']; self::$template_id = $signup_settings['template_id']; self::$sender_id = $signup_settings['sender_id']; // get alert message parameters $alert_settings = get_option(self::form_confirmation_option_name, array()); self::$alert_success_message = $alert_settings['alert_success_message']; self::$alert_error_message = $alert_settings['alert_error_message']; self::$alert_exist_subscriber = $alert_settings['alert_exist_subscriber']; self::$alert_invalid_email = $alert_settings['alert_invalid_email']; // get sign up form html $form_settings = get_option(self::form_subscription_option_name, array()); self::$sib_form_html = $form_settings['sib_form_html']; // get account info $account_settings = get_option(self::account_option_name, array()); self::$account_email = $account_settings['account_email']; self::$account_user_name = $account_settings['account_user_name']; self::$account_data = $account_settings['account_data']; self::$instance = $this; add_action('admin_init', array(&$this, 'admin_init'), 9999); add_action('admin_menu', array(&$this, 'admin_menu'), 9999); add_action('wp_print_scripts', array(&$this, 'frontend_register_scripts'), 9999); add_action('wp_head', array(&$this, 'wp_head_ac'), 999); add_action('wp_ajax_sib_validate_process', array('SIB_Page_Home', 'ajax_validation_process')); add_action('wp_ajax_sib_change_list', array('SIB_Page_Home', 'ajax_change_list')); add_action('wp_ajax_sib_activate_email_change', array('SIB_Page_Home', 'ajax_activate_email_change')); add_action('wp_ajax_sib_send_email', array('SIB_Page_Home', 'ajax_send_email')); add_action('wp_ajax_sib_change_template', array('SIB_Page_Form', 'ajax_change_template')); if (self::is_done_validation() == true) { add_shortcode('sibwp_form', array(&$this, 'sibwp_form_shortcode')); // register widget add_action('widgets_init', array(&$this, 'sib_create_widget')); } add_action('init', array(&$this, 'init')); // check if updated into new configuration. $use_new_version = get_option('sib_use_new_version', '0'); if ($use_new_version == '0') { $sib_form_html = <<<EOD <p class="sib-email-area"> <label class="sib-email-area">Email Address</label> <input type="email" class="sib-email-area" name="email" required="required"> </p> <p class="sib-NAME-area"> <label class="sib-NAME-area">Name</label> <input type="text" class="sib-NAME-area" name="NAME" > </p> <p> <input type="submit" class="sib-default-btn" value="Subscribe"> </p> EOD; update_option('sib_use_new_version', '1'); $form_settings = array('sib_form_html' => stripcslashes($sib_form_html), 'available_attributes' => array('NAME')); update_option(self::form_subscription_option_name, $form_settings); } // smtp details self::$smtp_details = get_option(SIB_Manager::attribute_smtp_name, null); if (self::is_done_validation() && self::$smtp_details == null) { self::update_smtp_details(); } $home_settings = get_option(SIB_Manager::home_option_name, array()); if (self::is_done_validation() && self::$smtp_details['relay'] == false) { $home_settings['activate_email'] = 'no'; update_option(SIB_Manager::home_option_name, $home_settings); } add_action('phpmailer_init', array(&$this, 'smtp_hook')); }
/** * Get account info */ static function update_account_info() { $access_key = SIB_Manager::$access_key; $mailin = new Mailin(SIB_Manager::sendinblue_api_url, $access_key); $response = $mailin->get_account(); if (is_array($response) && $response['code'] == 'success') { $account_data = $response['data']; $count = count($account_data); SIB_Manager::$account_email = $account_data[$count - 1]['email']; SIB_Manager::$account_data = $account_data; SIB_Manager::$account_user_name = $account_data[$count - 1]['first_name'] . ' ' . $account_data[$count - 1]['last_name']; $account_settings = array('account_email' => SIB_Manager::$account_email, 'account_user_name' => SIB_Manager::$account_user_name, 'account_data' => SIB_Manager::$account_data); update_option(SIB_Manager::account_option_name, $account_settings); } }