From 58dccc86754deda247eb49310c266f6cba86d36a Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Thu, 01 Jan 2026 23:40:35 +0000
Subject: [PATCH] Merge branch 'main' of https://github.com/jakevdwerf/jvb
---
inc/managers/NotificationManager.php | 136 +++++++++++++++++++++-----------------------
1 files changed, 65 insertions(+), 71 deletions(-)
diff --git a/inc/managers/NotificationManager.php b/inc/managers/NotificationManager.php
index db4a598..5656303 100644
--- a/inc/managers/NotificationManager.php
+++ b/inc/managers/NotificationManager.php
@@ -1030,7 +1030,7 @@
};
// Send the email
- return jvbMail($user->user_email, $subject, $content, $header);
+ return JVB()->email()->sendEmail($user->user_email, $subject, $content, $header);
}
/**
@@ -1043,46 +1043,47 @@
*
* @return string HTML email content
*/
- protected function generateDigestContent(WP_User $user, string $frequency, array $notifications, array $content_updates):string
- {
- $content = sprintf('<p>Hey %s,</p>', $user->first_name ?: $user->display_name);
+ protected function generateDigestContent(WP_User $user, string $frequency, array $notifications, array $content_updates):string
+ {
+ $content = sprintf('<p>Hey %s,</p>', $user->first_name ?: $user->display_name);
- // Intro text based on frequency
- switch ($frequency) {
- case 'daily':
- $content .= '<p>Here\'s what happened in Edmonton\'s tattoo scene today:</p>';
- break;
- case 'weekly':
- $content .= '<p>Here\'s what you missed in Edmonton\'s tattoo scene this week:</p>';
- break;
- case 'monthly':
- $content .= sprintf('<p>Here\'s your monthly roundup of what happened in %s in Edmonton\'s tattoo scene:</p>', date('F'));
- break;
- }
+ // Intro text based on frequency
+ switch ($frequency) {
+ case 'daily':
+ $content .= '<p>Here\'s what happened in Edmonton\'s tattoo scene today:</p>';
+ break;
+ case 'weekly':
+ $content .= '<p>Here\'s what you missed in Edmonton\'s tattoo scene this week:</p>';
+ break;
+ case 'monthly':
+ $content .= sprintf('<p>Here\'s your monthly roundup of what happened in %s in Edmonton\'s tattoo scene:</p>', date('F'));
+ break;
+ }
- // Process artist content updates - the most visually interesting part
- $content .= $this->generateContentUpdatesSection($content_updates);
+ // Process artist content updates - the most visually interesting part
+ $content .= $this->generateContentUpdatesSection($content_updates);
- // Process regular notifications
- if (!empty($notifications)) {
- $content .= $this->generateNotificationsSection($notifications);
- }
+ // Process regular notifications
+ if (!empty($notifications)) {
+ $content .= $this->generateNotificationsSection($notifications);
+ }
- // Add footer content
- $content .= '<div class="divider"></div>';
- $content .= sprintf(
- '<p>You\'re receiving this %s digest because you follow artists on edmonton.ink. ' .
- 'You can <a href="%s" class="text-link">adjust your notification settings</a> at any time.</p>',
- $frequency,
- esc_url(add_query_arg([
- 'utm_source' => 'email',
- 'utm_medium' => 'digest',
- 'utm_campaign' => $this->campaign
- ], site_url('/dash/settings/')))
- );
+ // Add footer content
+ $content .= JVB()->email()->divider();
+ $settings_url = add_query_arg([
+ 'utm_source' => 'email',
+ 'utm_medium' => 'digest',
+ 'utm_campaign' => $this->campaign
+ ], site_url('/dash/settings/'));
- return $content;
- }
+ $content .= sprintf(
+ '<p>You\'re receiving this %s digest because you follow artists on edmonton.ink. You can %s at any time.</p>',
+ $frequency,
+ '<a href="' . esc_url($settings_url) . '">adjust your notification settings</a>'
+ );
+
+ return $content;
+ }
/**
* Generate HTML section for content updates
@@ -1234,46 +1235,39 @@
*
* @return string HTML content
*/
- protected function generateNotificationsSection(array $notifications):string
- {
- if (empty($notifications)) {
- return '';
- }
+ protected function generateNotificationsSection(array $notifications):string
+ {
+ if (empty($notifications)) {
+ return '';
+ }
- $content = '<h3>Other Updates</h3>';
- $content .= '<ul style="padding-left: 20px;">';
+ $items = [];
- // Group notifications by type
- $by_type = [];
- foreach ($notifications as $notification) {
- if (!isset($by_type[$notification->type])) {
- $by_type[ $notification->type ] = [];
- }
- $by_type[ $notification->type ][] = $notification;
- }
+ // Group notifications by type
+ $by_type = [];
+ foreach ($notifications as $notification) {
+ if (!isset($by_type[$notification->type])) {
+ $by_type[$notification->type] = [];
+ }
+ $by_type[$notification->type][] = $notification;
+ }
- // Process each type
- foreach ($by_type as $type => $type_notifications) {
- $config = $this->notification_types[ $type ] ?? [];
- $icon = $config['icon'] ?? 'info';
+ // Process each type
+ foreach ($by_type as $type => $type_notifications) {
+ foreach ($type_notifications as $notification) {
+ $message = $notification->message;
+ if (empty($message)) {
+ $message = $this->generateNotificationMessage($notification);
+ }
- foreach ($type_notifications as $notification) {
- $message = $notification->message;
- if (empty($message)) {
- $message = $this->generateNotificationMessage($notification);
- }
+ if (!empty($message)) {
+ $items[] = ['label' => '', 'value' => $message];
+ }
+ }
+ }
- if (!empty($message)) {
- $content .= sprintf('<li>%s</li>', $message);
- }
- }
- }
-
- $content .= '</ul>';
- $content .= '<div class="divider"></div>';
-
- return $content;
- }
+ return JVB()->email()->table($items, 'Other Updates');
+ }
/**
* Generate a message for a notification when none is provided
--
Gitblit v1.10.0