From 2329482aa18628d91747cd326cd157576cc30603 Mon Sep 17 00:00:00 2001 From: asus Date: Tue, 2 Apr 2024 19:12:16 +0200 Subject: [PATCH] wip filter email subject and sender, in addition to message --- plugins/cipf_plugin/cipf_plugin.php | 2 +- plugins/cipf_plugin/php/emails.php | 1 + plugins/custer/filter_mail.php | 24 +++++++++++++++++++++--- plugins/custer/user_infos.php | 2 +- 4 files changed, 24 insertions(+), 5 deletions(-) diff --git a/plugins/cipf_plugin/cipf_plugin.php b/plugins/cipf_plugin/cipf_plugin.php index 9e7a7fc..06684c7 100644 --- a/plugins/cipf_plugin/cipf_plugin.php +++ b/plugins/cipf_plugin/cipf_plugin.php @@ -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, diff --git a/plugins/cipf_plugin/php/emails.php b/plugins/cipf_plugin/php/emails.php index 2415991..dcdd019 100644 --- a/plugins/cipf_plugin/php/emails.php +++ b/plugins/cipf_plugin/php/emails.php @@ -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; diff --git a/plugins/custer/filter_mail.php b/plugins/custer/filter_mail.php index c8eb726..a41cf10 100644 --- a/plugins/custer/filter_mail.php +++ b/plugins/custer/filter_mail.php @@ -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; } diff --git a/plugins/custer/user_infos.php b/plugins/custer/user_infos.php index eb2f9aa..fd0c81f 100644 --- a/plugins/custer/user_infos.php +++ b/plugins/custer/user_infos.php @@ -45,7 +45,7 @@ function merge_arrays(...$arrays) { $new_array[$key.'('.$i.')'] = $value; } } - ksort($new_array, 'strnatcasecmp'); + uksort($new_array, 'strnatcasecmp'); return $new_array; }