From 3b5abc4ab44fb899b92ea0e40e0719454c057f52 Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Wed, 11 Feb 2026 01:38:22 +0000
Subject: [PATCH] =attempt to fix race condition that overrides image changes immediately after processing them
---
inc/managers/EmailManager.php | 24 ++++++++++++++++--------
1 files changed, 16 insertions(+), 8 deletions(-)
diff --git a/inc/managers/EmailManager.php b/inc/managers/EmailManager.php
index 106a387..2fdd0c6 100644
--- a/inc/managers/EmailManager.php
+++ b/inc/managers/EmailManager.php
@@ -82,13 +82,13 @@
* @param string $header Optional header text for the template
* @return bool Whether the email was sent successfully
*/
- public function sendEmail(string $to, string $subject, string $message, string $header = '', array $headers = [], array $attachments = []):bool
+ public function sendEmail(string $to, string $subject, string $message, string $header = '', string $preheader = '', array $headers = [], array $attachments = []):bool
{
// Make sure the content type is set to HTML
add_filter('wp_mail_content_type', [$this, 'setHtmlContentType']);
// Format the message with our template
- $formatted_message = $this->getEmailTemplate($message, $header);
+ $formatted_message = $this->getEmailTemplate($message, $header, $preheader);
// Send the email
$result = wp_mail($to, $subject, $formatted_message, $headers, $attachments);
@@ -105,7 +105,7 @@
*
* @return string
*/
- private function getEmailTemplate(string $content, string $headerText = ''):string
+ private function getEmailTemplate(string $content, string $headerText = '', string $preheader = ''):string
{
$custom_logo_id = get_theme_mod( 'custom_logo' );
$logo_thumbnail = wp_get_attachment_image_src( $custom_logo_id, 'custom-logo-thumbnail' );
@@ -118,6 +118,14 @@
$headerText = $this->title;
}
+ $preheaderHtml = '';
+ if (!empty($preheader)) {
+ $preheaderHtml = '
+ <div style="display:none;font-size:1px;color:#fefefe;line-height:1px;font-family:Helvetica,Arial,sans-serif;max-height:0px;max-width:0px;opacity:0;overflow:hidden;">
+ ' . esc_html($preheader) . '
+ </div>';
+ }
+
return '<!DOCTYPE html>
<html>
<head>
@@ -671,15 +679,15 @@
}
$content .= sprintf(
'<div style="padding:10px 0;border-bottom:1px solid %s;background-color:%s;">
- <span style="display:inline-block;vertical-align:top;font-weight:600;color:%s;width:%s;">%s</span>
- <div style="display:inline-block;vertical-align:top;width:%s;">%s</div>
- </div>',
+ <span style="display:inline-block;vertical-align:top;font-weight:600;color:%s;width:%s;">%s</span>
+ <div style="display:inline-block;vertical-align:top;width:%s;">%s</div>
+ </div>',
$this->colours['dark-200'],
($index%2 === 0) ? $this->colours['light-100'] : $this->colours['light-50'],
$this->colours['dark-200'],
- '19%',
+ '30%', // Changed from 19% to 30%
$item['label'],
- '80%',
+ '68%', // Changed from 80% to 68% (30% + 68% = 98%, leaving 2% for spacing)
$item['value']
);
}
--
Gitblit v1.10.0