wip filter email subject and sender, in addition to message

This commit is contained in:
asus
2024-04-02 19:12:16 +02:00
parent 7a5b1f63d3
commit 2329482aa1
4 changed files with 24 additions and 5 deletions

View File

@@ -156,7 +156,7 @@ vous allez être redirigés vers votre espace',
[
'action'=>'success_payment',
'notification_send'=>true,
'notification_to'=>'test',
'notification_to'=>'$$__admin_email__$$',
'notification_subject'=>"paiement réussi",
'notification_message'=>"par ici la monnaie",
'confirmation_send'=>true,

View File

@@ -12,6 +12,7 @@ if (!defined('ABSPATH')) {
function email_success_payment_CIPF($user_id) {
Plgntls::debug_infos();
error_log("in email success");
$user = get_user_by('id', $user_id);
$to = $user->user_email;

View File

@@ -89,10 +89,28 @@ function replace_words($matches, $user_id = null) {
function filter_email_wp($args) {
// pattern : anything surrounded by '$$', ex : $$value$$
$pattern = '/\$\$(.*?)\$\$/';
error_log("email args: " . json_encode($args));
/*
email args: {
"to":"ruknafetri@gufum.com",
"subject":"My Custom Email Subject",
"message":"Hello, This is a test email sent from my WordPress plugin!",
"headers":["Content-Type: text\/html; charset=UTF-8"],
"attachments":[]
}
*/
$old_body = $args['message'];
$new_body = preg_replace_callback($pattern, __NAMESPACE__.'\replace_words', $old_body);
$args['message'] = $new_body;
$old_to = $args['to'];
$new_to = preg_replace_callback($pattern, __NAMESPACE__.'\replace_words', $old_to);
$args['to'] = $new_to;
$old_subject = $args['subject'];
$new_subject = preg_replace_callback($pattern, __NAMESPACE__.'\replace_words', $old_subject);
$args['subject'] = $new_subject;
$old_message = $args['message'];
$new_message = preg_replace_callback($pattern, __NAMESPACE__.'\replace_words', $old_message);
$args['message'] = $new_message;
return $args;
}

View File

@@ -45,7 +45,7 @@ function merge_arrays(...$arrays) {
$new_array[$key.'('.$i.')'] = $value;
}
}
ksort($new_array, 'strnatcasecmp');
uksort($new_array, 'strnatcasecmp');
return $new_array;
}