added email from
This commit is contained in:
@@ -38,7 +38,7 @@ function prepare_emails_CIPF($email_name, $user_id) {
|
||||
}
|
||||
$user = get_user_by('id', $user_id);
|
||||
$user_email = $user->user_email;
|
||||
$headers = array('Content-Type: text/html; charset=UTF-8');
|
||||
$header_content_type = 'Content-Type: text/html; charset=UTF-8';
|
||||
|
||||
|
||||
$emails_option = Plgntls::get_option_safe($emails_option_object);
|
||||
@@ -57,7 +57,15 @@ function prepare_emails_CIPF($email_name, $user_id) {
|
||||
$tmp_email['to'] = $email['notification_to'];
|
||||
$tmp_email['subject'] = $email['notification_subject'];
|
||||
$tmp_email['message'] = $email['notification_message'];
|
||||
$tmp_email['headers'] = $headers;
|
||||
$tmp_email['headers'] = array();
|
||||
$tmp_email['headers'][] = $header_content_type;
|
||||
$from = $email['notification_from'];
|
||||
if (empty($from)) {
|
||||
$from = get_option('admin_email');
|
||||
}
|
||||
if (!empty($from)) {
|
||||
$tmp_email['headers'][] = 'From:'.$from;
|
||||
}
|
||||
$emails[] = $tmp_email;
|
||||
}
|
||||
if ($email['confirmation_send']) {
|
||||
@@ -65,7 +73,15 @@ function prepare_emails_CIPF($email_name, $user_id) {
|
||||
$tmp_email['to'] = $user_email;
|
||||
$tmp_email['subject'] = $email['confirmation_subject'];
|
||||
$tmp_email['message'] = $email['confirmation_message'];
|
||||
$tmp_email['headers'] = $headers;
|
||||
$tmp_email['headers'] = array();
|
||||
$tmp_email['headers'][] = $header_content_type;
|
||||
$from = $email['confirmation_from'];
|
||||
if (empty($from)) {
|
||||
$from = get_option('admin_email');
|
||||
}
|
||||
if (!empty($from)) {
|
||||
$tmp_email['headers'][] = 'From:'.$from;
|
||||
}
|
||||
$emails[] = $tmp_email;
|
||||
}
|
||||
return $emails;
|
||||
@@ -82,6 +98,7 @@ function send_emails_CIPF($email_name, $user_id = null) {
|
||||
}
|
||||
|
||||
foreach ($emails as $email) {
|
||||
error_log('Email: ' . json_encode($email));
|
||||
$sent = wp_mail($email['to'], $email['subject'], $email['message'], $email['headers']);
|
||||
}
|
||||
if (!$sent) {
|
||||
|
||||
@@ -168,8 +168,14 @@ function update_paypal_credentials_CIPF($request, $option_name, $option_data, $o
|
||||
function update_emails_settings_option_CIPF($request, $option_name, $option_data, $option_default) {
|
||||
Plgntls::debug_infos();
|
||||
|
||||
/*
|
||||
* loop through saved data option
|
||||
* update them
|
||||
* add them to the option that will be saved
|
||||
*
|
||||
*/
|
||||
foreach ($option_data as $email_type => $email_options) {
|
||||
$ret_update = update_email_by_type_CIPF($email_type, $email_options, $request);
|
||||
$ret_update = update_email_by_type_CIPF($email_type, $email_options, $option_default[$email_type], $request);
|
||||
if ($ret_update !== false) {
|
||||
$option_data[$email_type] = $ret_update;
|
||||
}
|
||||
@@ -178,7 +184,6 @@ function update_emails_settings_option_CIPF($request, $option_name, $option_data
|
||||
/*
|
||||
* to reorder and add new data with the default data
|
||||
* also take the name of the default
|
||||
* not really good :p
|
||||
*
|
||||
*/
|
||||
$new_option = array();
|
||||
@@ -208,7 +213,7 @@ function update_emails_settings_option_CIPF($request, $option_name, $option_data
|
||||
* utility function to update the emails
|
||||
*
|
||||
*/
|
||||
function update_email_by_type_CIPF($email_type, $email_options, $request) {
|
||||
function update_email_by_type_CIPF($email_type, $email_options, $email_default_options, $request) {
|
||||
Plgntls::debug_infos();
|
||||
$is_new = false;
|
||||
|
||||
@@ -224,20 +229,26 @@ function update_email_by_type_CIPF($email_type, $email_options, $request) {
|
||||
* loop through all options to update them
|
||||
*
|
||||
*/
|
||||
foreach ($email_options as $option => $value) {
|
||||
if (!isset($request[$email_type.'_'.$option])) {
|
||||
foreach ($email_default_options as $default_option => $default_value) {
|
||||
if (!isset($request[$email_type.'_'.$default_option])) {
|
||||
if (isset($email_options[$default_option])) {
|
||||
continue;
|
||||
}
|
||||
$is_new = true;
|
||||
$email_options[$default_option] = $default_value;
|
||||
continue;
|
||||
}
|
||||
$new_value = $request[$email_type.'_'.$option];
|
||||
$new_value = $request[$email_type.'_'.$default_option];
|
||||
$value = $email_options[$default_option];
|
||||
if ($new_value === $value) {
|
||||
continue;
|
||||
}
|
||||
$is_new = true;
|
||||
if ($option === 'notification_send' || $option === 'confirmation_send') {
|
||||
$email_options[$option] = true;
|
||||
if ($default_option === 'notification_send' || $default_option === 'confirmation_send') {
|
||||
$email_options[$default_option] = true;
|
||||
}
|
||||
else {
|
||||
$email_options[$option] = $new_value;
|
||||
$email_options[$default_option] = $new_value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user