/** * Subscribes to Sendinblue list. Returns either "success" string or error message. * @return string */ function subscribe_sendinblue($api_key, $email, $list_id, $name, $last_name = '') { if (!function_exists('curl_init')) { return __('curl_init is not defined ', 'rapidology'); } if (!class_exists('Mailin')) { require_once RAD_RAPIDOLOGY_PLUGIN_DIR . 'subscription/sendinblue-v2.0/mailin.php'; } $mailin = new Mailin('https://api.sendinblue.com/v2.0', $api_key); $user = $mailin->get_user($email); if ('failure' == $user['code']) { $attributes = array("NAME" => $name, "SURNAME" => $last_name); $blacklisted = 0; $listid = array($list_id); $listid_unlink = array(); $blacklisted_sms = 0; $result = $mailin->create_update_user($email, $attributes, $blacklisted, $listid, $listid_unlink, $blacklisted_sms); if ('success' == $result['code']) { $error_message = 'success'; } else { if (!empty($result['message'])) { $error_message = $result['message']; } else { $error_message = __('Unknown error', 'rapidology'); } } } else { $error_message = __('Already subscribed', 'rapidology'); } return $error_message; }
/** * Subscribe process */ function subscribe() { $site_domain = str_replace('https://', '', home_url()); $site_domain = str_replace('http://', '', $site_domain); $mailin = new Mailin('https://api.sendinblue.com/v1.0', SIB_Manager::$access_key, SIB_Manager::$secret_key); $code = esc_attr($_GET['code']); $list_id = intval($_GET['li']); $contact_info = SIB_Model_Contact::get_data_by_code($code); if ($contact_info != false) { $email = $contact_info['email']; $response = $mailin->get_user($email); if ($response['code'] == 'success') { $listid = $response['data']['listid']; } else { $listid = array(); } if (SIB_Manager::$is_confirm_email == 'yes' && in_array($list_id, $listid) == false) { $this->send_email('confirm', $email, $code, $list_id); } array_push($listid, $list_id); $attribues = maybe_unserialize($contact_info['info']); $mailin->create_update_user($email, $attribues, 0, $listid, null); } if (SIB_Manager::$redirect_url != '') { wp_redirect(SIB_Manager::$redirect_url); exit; } ?> <body style="margin:0; padding:0;"> <table style="background-color:#ffffff" cellpadding="0" cellspacing="0" border="0" width="100%"> <tbody> <tr style="border-collapse:collapse;"> <td style="border-collapse:collapse;" align="center"> <table cellpadding="0" cellspacing="0" border="0" width="540"> <tbody> <tr> <td style="line-height:0; font-size:0;" height="20"></td> </tr> </tbody> </table> <table cellpadding="0" cellspacing="0" border="0" width="540"> <tbody> <tr> <td style="line-height:0; font-size:0;" height="20"> <div style="font-family:arial,sans-serif; color:#61a6f3; font-size:20px; font-weight:bold; line-height:28px;"> <?php _e('Thank you for subscribing', 'sib_lang'); ?> </div> </td> </tr> </tbody> </table> <table cellpadding="0" cellspacing="0" border="0" width="540"> <tbody> <tr> <td style="line-height:0; font-size:0;" height="20"></td> </tr> </tbody> </table> <table cellpadding="0" cellspacing="0" border="0" width="540"> <tbody> <tr> <td align="left"> <div style="font-family:arial,sans-serif; font-size:14px; margin:0; line-height:24px; color:#555555;"> <br> <?php echo __('You have just subscribed to the newsletter of ', 'sib_lang') . $site_domain . ' .'; ?> <br><br> <?php _e('-SendinBlue', 'sib_lang'); ?> </div> </td> </tr> </tbody> </table> <table cellpadding="0" cellspacing="0" border="0" width="540"> <tbody> <tr> <td style="line-height:0; font-size:0;" height="20"> </td> </tr> </tbody> </table> </td> </tr> </tbody> </table> </body> <?php exit; }
/** * Subscribes to Sendinblue list. Returns either "success" string or error message. * @return string */ function subscribe_sendinblue($api_key, $email, $list_id, $name, $last_name = '') { if (!function_exists('curl_init')) { return __('curl_init is not defined ', 'bloom'); } if (!class_exists('Mailin')) { require_once ET_BLOOM_PLUGIN_DIR . 'subscription/sendinblue-v2.0/mailin.php'; } $mailin = new Mailin('https://api.sendinblue.com/v2.0', $api_key); $user = $mailin->get_user($email); //check whether current email subscribed to current list if (!empty($user['data']['listid'])) { foreach ($user['data']['listid'] as $single_list_id) { if ((int) $list_id === (int) $single_list_id) { return __('Already subscribed', 'bloom'); } } } // subscribe current email to current list if not subscribed yet $attributes = array("NAME" => $name, "SURNAME" => $last_name); $blacklisted = 0; $listid = array($list_id); $listid_unlink = array(); $blacklisted_sms = 0; $result = $mailin->create_update_user($email, $attributes, $blacklisted, $listid, $listid_unlink, $blacklisted_sms); if ('success' == $result['code']) { $error_message = 'success'; } else { if (!empty($result['message'])) { $error_message = $result['message']; } else { $error_message = __('Unknown error', 'bloom'); } } return $error_message; }
/** * Subscribe process for submit on confirmation email */ public static function subscribe() { $site_domain = str_replace('https://', '', home_url()); $site_domain = str_replace('http://', '', $site_domain); $general_settings = get_option('ws_main_option', array()); if (!class_exists('Mailin')) { require_once 'mailin.php'; } $mailin = new Mailin(self::sendinblue_api_url, $general_settings['access_key']); $code = esc_attr($_GET['code']); $list_id = intval($_GET['li']); $contact_info = SIB_Model_Contact::get_data_by_code($code); if ($contact_info != false) { $email = $contact_info['email']; $data = array('email' => $email); $response = $mailin->get_user($data); if ($response['code'] == 'success') { $listid = $response['data']['listid']; if (!isset($listid) || !is_array($listid)) { $listid = array(); } } else { $listid = array(); } array_push($listid, $list_id); $attributes = maybe_unserialize($contact_info['info']); $data = array(); $attribute_key = implode('|', array_keys($attributes)); $attribute_val = implode('|', array_values($attributes)); $ip = self::get_the_user_ip(); $data['attributes_name'] = $attribute_key; $data['attributes_value'] = $attribute_val; $data['category'] = ''; $data['email'] = $email; $data['listid'] = $list_id; $data['blacklisted'] = 0; $data['blacklisted_sms'] = 0; $data['source'] = 'Wordpress Woocommerce'; $data['ip'] = $ip; $ret = $mailin->updateUser($data); } ?> <body style="margin:0; padding:0;"> <table style="background-color:#ffffff" cellpadding="0" cellspacing="0" border="0" width="100%"> <tbody> <tr style="border-collapse:collapse;"> <td style="border-collapse:collapse;" align="center"> <table cellpadding="0" cellspacing="0" border="0" width="540"> <tbody> <tr> <td style="line-height:0; font-size:0;" height="20"></td> </tr> </tbody> </table> <table cellpadding="0" cellspacing="0" border="0" width="540"> <tbody> <tr> <td style="line-height:0; font-size:0;" height="20"> <div style="font-family:arial,sans-serif; color:#61a6f3; font-size:20px; font-weight:bold; line-height:28px;"> <?php _e('Thank you for subscribing', 'wc_sendinblue'); ?> </div> </td> </tr> </tbody> </table> <table cellpadding="0" cellspacing="0" border="0" width="540"> <tbody> <tr> <td style="line-height:0; font-size:0;" height="20"></td> </tr> </tbody> </table> <table cellpadding="0" cellspacing="0" border="0" width="540"> <tbody> <tr> <td align="left"> <div style="font-family:arial,sans-serif; font-size:14px; margin:0; line-height:24px; color:#555555;"> <br> <?php echo __('You have just subscribed to the newsletter of ', 'wc_sendinblue') . $site_domain . ' .'; ?> <br><br> <?php _e('-SendinBlue', 'wc_sendinblue'); ?> </div> </td> </tr> </tbody> </table> <table cellpadding="0" cellspacing="0" border="0" width="540"> <tbody> <tr> <td style="line-height:0; font-size:0;" height="20"> </td> </tr> </tbody> </table> </td> </tr> </tbody> </table> </body> <?php exit; }
/** * Subscribe process */ function subscribe() { $site_domain = str_replace('https://', '', home_url()); $site_domain = str_replace('http://', '', $site_domain); $mailin = new Mailin(SIB_Manager::sendinblue_api_url, SIB_Manager::$access_key); $code = esc_attr($_GET['code']); $list_id = intval($_GET['li']); $contact_info = SIB_Model_Contact::get_data_by_code($code); if ($contact_info != false) { $email = $contact_info['email']; $data = array('email' => $email); $response = $mailin->get_user($data); if ($response['code'] == 'success') { $listid = $response['data']['listid']; if (!isset($listid) || !is_array($listid)) { $listid = array(); } } else { $listid = array(); } if (SIB_Manager::$is_confirm_email == 'yes' && in_array($list_id, $listid) == false) { $this->send_email('confirm', $email, $code, $list_id); } array_push($listid, $list_id); $info = maybe_unserialize($contact_info['info']); $data = array(); $attribute_key = implode('|', array_keys($info)); $attribute_val = implode('|', array_values($info)); $ip = $this->get_the_user_ip(); $data['attributes_name'] = $attribute_key; $data['attributes_value'] = $attribute_val; $data['category'] = ''; $data['email'] = $email; $data['listid'] = $list_id; $data['blacklisted'] = 0; $data['blacklisted_sms'] = 0; $data['source'] = 'Wordpress'; $data['ip'] = $ip; $response = $mailin->updateUser($data); } if (SIB_Manager::$redirect_url != '') { wp_redirect(SIB_Manager::$redirect_url); exit; } ?> <body style="margin:0; padding:0;"> <table style="background-color:#ffffff" cellpadding="0" cellspacing="0" border="0" width="100%"> <tbody> <tr style="border-collapse:collapse;"> <td style="border-collapse:collapse;" align="center"> <table cellpadding="0" cellspacing="0" border="0" width="540"> <tbody> <tr> <td style="line-height:0; font-size:0;" height="20"></td> </tr> </tbody> </table> <table cellpadding="0" cellspacing="0" border="0" width="540"> <tbody> <tr> <td style="line-height:0; font-size:0;" height="20"> <div style="font-family:arial,sans-serif; color:#61a6f3; font-size:20px; font-weight:bold; line-height:28px;"> <?php _e('Thank you for subscribing', 'sib_lang'); ?> </div> </td> </tr> </tbody> </table> <table cellpadding="0" cellspacing="0" border="0" width="540"> <tbody> <tr> <td style="line-height:0; font-size:0;" height="20"></td> </tr> </tbody> </table> <table cellpadding="0" cellspacing="0" border="0" width="540"> <tbody> <tr> <td align="left"> <div style="font-family:arial,sans-serif; font-size:14px; margin:0; line-height:24px; color:#555555;"> <br> <?php echo __('You have just subscribed to the newsletter of ', 'sib_lang') . $site_domain . ' .'; ?> <br><br> <?php _e('-SendinBlue', 'sib_lang'); ?> </div> </td> </tr> </tbody> </table> <table cellpadding="0" cellspacing="0" border="0" width="540"> <tbody> <tr> <td style="line-height:0; font-size:0;" height="20"> </td> </tr> </tbody> </table> </td> </tr> </tbody> </table> </body> <?php exit; }
/** * Validation email */ function validation_email($email, $list_id) { $general_settings = get_option('ws_main_option', array()); if (!class_exists('Mailin')) { require_once 'mailin.php'; } $mailin = new Mailin(WC_Sendinblue::sendinblue_api_url, $general_settings['access_key']); $data = array("email" => $email); $response = $mailin->get_user($data); if ($response['code'] == 'failure') { $ret = array('code' => 'success', 'listid' => array()); return $ret; } $listid = $response['data']['listid']; if (!isset($listid) || !is_array($listid)) { $listid = array(); } if ($response['data']['blacklisted'] == 1) { $ret = array('code' => 'update', 'listid' => $listid); } else { if (!in_array($list_id, $listid)) { $ret = array('code' => 'success', 'listid' => $listid); } else { $ret = array('code' => 'already_exist', 'listid' => $listid); } } return $ret; }