PluginProbe
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder / 3.3.1
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder v3.3.1
3.3.1 V-3.3.0 3.2.2 3.2.1 3.2.0 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 V3.0.3 V3.0.2 -3.0.1 V_3.0.0 1.1.1 1.1.8 1.2 1.3 1.4 1.4.18 1.5.2 1.9 2.0 2.10.0 2.10.1 All 138 releases
← All changes | includes/Core/Util/MailNotifier.php +26 -4 3.2.03.3.1 View file →
@@ -20,9 +20,8 @@
20 20 $entryDetails = ['formId' => $formID, 'entryId' => $entryID, 'fieldValues' => $fieldValue];
21 21 $emailTemplateHandler = new EmailTemplateHandler($formID);
22 22 $attachments = [];
23 23 $tempPdfLinks = [];
24 -
25 24 if (is_string($notifyDetails->id)) {
26 25 $mailTemplateID = Utilities::jsonObj($notifyDetails->id)->id ?? null;
27 26 $mailTemplate = $emailTemplateHandler->getATemplate($mailTemplateID);
28 27 if (!is_wp_error($mailTemplate)) {
@@ -44,14 +43,22 @@
44 43 ];
45 44 $from_mail = '';
46 45 if (!empty($notifyDetails->from)) {
47 46 $fromMail = FieldValueHandler::validateMailArry($notifyDetails->from, $fieldValue);
48 - $headerFromName = !empty($notifyDetails->fromName) ? $notifyDetails->fromName : explode('@', $fromMail[0])[0];
47 + $headerFromName = !empty($notifyDetails->from_name) ? $notifyDetails->from_name : explode('@', $fromMail[0])[0];
49 48 $mailHeaders[] = "FROM: $headerFromName " . '<' . sanitize_email($fromMail[0]) . '>';
50 49 $from_mail = $fromMail[0];
51 50 }
52 51 (new MailConfig())->sendMail(['from_name' => $from_name, 'from_email' => $from_mail]);
53 - $mailSubject = FieldValueHandler::replaceFieldWithValue($mailTemplate[0]->sub, $fieldValue, $formID);
52 + // Translate before smart-tag replacement. One language per submission,
53 + // shared by the admin and submitter emails.
54 + $mailSubjectTemplate = (string) apply_filters(
55 + 'bitform_translate_form_string',
56 + (string) $mailTemplate[0]->sub,
57 + 'mail-sub-' . $mailTemplateID,
58 + $formID
59 + );
60 + $mailSubject = FieldValueHandler::replaceFieldWithValue($mailSubjectTemplate, $fieldValue, $formID);
54 61
55 62 // allow developers to modify email subject
56 63 $mailSubject = apply_filters(
57 64 'bitform_filter_email_subject',
@@ -64,9 +71,14 @@
64 71 'is_double_optin' => (bool) $isDblOptin,
65 72 ]
66 73 );
67 74
68 - $mailBody = $mailTemplate[0]->body;
75 + $mailBody = (string) apply_filters(
76 + 'bitform_translate_form_string',
77 + (string) $mailTemplate[0]->body,
78 + 'mail-body-' . $mailTemplateID,
79 + $formID
80 + );
69 81 if (class_exists('\BitCode\BitFormPro\Admin\DownloadFile')) {
70 82 $downloadFile = new \BitCode\BitFormPro\Admin\DownloadFile();
71 83 $mailBody = $downloadFile->replacePdfShortCodeToLink($mailBody, $formID, $entryID);
72 84 $mailBody = $downloadFile->replaceShortCodeToPdfPassword($mailBody, $formID, $entryID);
@@ -197,8 +209,15 @@
197 209 if (!empty($cidMap)) {
198 210 add_action('phpmailer_init', $embedCb);
199 211 }
200 212 add_filter('wp_mail_content_type', [self::class, 'filterMailContentType']);
213 + $fromNameCb = null;
214 + if (!empty($from_name)) {
215 + $fromNameCb = static function () use ($from_name) {
216 + return $from_name;
217 + };
218 + add_filter('wp_mail_from_name', $fromNameCb);
219 + }
201 220 $status = wp_mail($mailTo, $mailSubject, $mailBody, $mailHeaders, $attachments);
202 221
203 222 if (!$status) {
204 223 Log::debug_log([
@@ -253,8 +272,11 @@
253 272 ]
254 273 );
255 274 }
256 275 remove_filter('wp_mail_content_type', [self::class, 'filterMailContentType']);
276 + if (null !== $fromNameCb) {
277 + remove_filter('wp_mail_from_name', $fromNameCb);
278 + }
257 279 if (!empty($cidMap)) {
258 280 remove_action('phpmailer_init', $embedCb);
259 281 }
260 282 }