wip filter email subject and sender, in addition to message
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ function merge_arrays(...$arrays) {
|
||||
$new_array[$key.'('.$i.')'] = $value;
|
||||
}
|
||||
}
|
||||
ksort($new_array, 'strnatcasecmp');
|
||||
uksort($new_array, 'strnatcasecmp');
|
||||
return $new_array;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user