| 1 |
<?php if (!defined('ABSPATH')) exit; // if accessed directly exit ?> |
| 2 |
<?php |
| 3 |
/** |
| 4 |
* Shared card body for event notifications. Every block is optional; senders pass only |
| 5 |
* what the event has. Output is buffered into $fluent_boards_email_content for template.php. |
| 6 |
* |
| 7 |
* @var array $badge ['label' => string, 'tone' => accent|neutral|warn|ok] |
| 8 |
* @var string $heading Plain-text headline |
| 9 |
* @var string $context HTML line under the headline (task / board links) |
| 10 |
* @var array $userData ['display_name', 'photo'] of the actor, used for comment blocks |
| 11 |
* @var string $comment Comment HTML |
| 12 |
* @var string $comment_time Human readable comment time |
| 13 |
* @var string $parent_comment HTML of the comment being replied to |
| 14 |
* @var array $task_card ['title', 'url', 'parent_title', 'parent_url', 'rows' => [[label, html]], 'muted', 'description'] |
| 15 |
* @var array $change ['from' => string, 'to' => string, 'strike' => bool] |
| 16 |
* @var string $note Plain-text note under the content |
| 17 |
* @var array $cta ['label', 'url', 'style' => primary|secondary] |
| 18 |
* @var string $fallback_url Raw URL printed under the button for clients that block it |
| 19 |
* @var string $body Legacy HTML sentence, rendered when no $heading is passed |
| 20 |
*/ |
| 21 |
|
| 22 |
$fluent_boards_tones = [ |
| 23 |
'accent' => ['#EEF2FF', '#2547D0'], |
| 24 |
'neutral' => ['#F2F5F8', '#3F4552'], |
| 25 |
'warn' => ['#FFF6DB', '#7A4D00'], |
| 26 |
'ok' => ['#E0FAEC', '#0B6B3A'], |
| 27 |
]; |
| 28 |
|
| 29 |
ob_start(); |
| 30 |
?> |
| 31 |
<?php if (!empty($badge['label'])): |
| 32 |
$fluent_boards_tone = isset($badge['tone'], $fluent_boards_tones[$badge['tone']]) ? $badge['tone'] : 'accent'; |
| 33 |
list($fluent_boards_pill_bg, $fluent_boards_pill_fg) = $fluent_boards_tones[$fluent_boards_tone]; |
| 34 |
?> |
| 35 |
<p style="margin: 0 0 16px;"> |
| 36 |
<span class="fbs_email_pill_<?php echo esc_attr($fluent_boards_tone); ?>" style="display: inline-block; padding: 4px 10px; border-radius: 999px; background: <?php echo esc_attr($fluent_boards_pill_bg); ?>; color: <?php echo esc_attr($fluent_boards_pill_fg); ?>; font-size: 12px; font-weight: 600; line-height: 18px;"><?php echo esc_html($badge['label']); ?></span> |
| 37 |
</p> |
| 38 |
<?php endif; ?> |
| 39 |
|
| 40 |
<?php if (!empty($heading)): ?> |
| 41 |
<h1 class="fbs_email_text fbs_email_heading" style="margin: 0; color: #0E121B; font-size: 22px; font-weight: 600; line-height: 30px;"><?php echo esc_html($heading); ?></h1> |
| 42 |
<?php if (!empty($context)): ?> |
| 43 |
<p class="fbs_email_text2" style="margin: 6px 0 0; color: #525866; font-size: 14px; line-height: 22px;"><?php echo wp_kses_post($context); ?></p> |
| 44 |
<?php endif; ?> |
| 45 |
<?php elseif (!empty($body)): ?> |
| 46 |
<?php // Legacy payload from senders that still pass a single body sentence. ?> |
| 47 |
<table role="presentation" cellpadding="0" cellspacing="0" border="0" width="100%"> |
| 48 |
<tr> |
| 49 |
<?php if (!empty($userData['photo'])): ?> |
| 50 |
<td width="44" valign="top" style="width: 44px; padding-right: 12px;"> |
| 51 |
<img src="<?php echo esc_url($userData['photo']); ?>" width="36" height="36" alt="<?php echo esc_attr($userData['display_name']); ?>" style="display: block; width: 36px; height: 36px; border-radius: 999px;"> |
| 52 |
</td> |
| 53 |
<?php endif; ?> |
| 54 |
<td valign="top" class="fbs_email_text2" style="color: #525866; font-size: 15px; line-height: 24px;"> |
| 55 |
<?php if (!empty($userData['display_name'])): ?> |
| 56 |
<strong class="fbs_email_text" style="color: #0E121B;"><?php echo esc_html($userData['display_name']); ?></strong> |
| 57 |
<?php endif; ?> |
| 58 |
<?php echo wp_kses_post($body); ?> |
| 59 |
</td> |
| 60 |
</tr> |
| 61 |
</table> |
| 62 |
<?php endif; ?> |
| 63 |
|
| 64 |
<?php if (!empty($comment)): ?> |
| 65 |
<table role="presentation" class="fbs_email_inset" cellpadding="0" cellspacing="0" border="0" width="100%" style="margin-top: 24px; background: #F5F7FA; border: 1px solid #E1E4EA; border-radius: 10px;"> |
| 66 |
<?php if (!empty($parent_comment)): ?> |
| 67 |
<tr> |
| 68 |
<td class="fbs_email_border" style="padding: 14px 16px; border-bottom: 1px solid #E1E4EA;"> |
| 69 |
<p class="fbs_email_text2" style="margin: 0 0 2px; color: #525866; font-size: 13px; line-height: 18px;"><?php esc_html_e('Your comment', 'fluent-boards'); ?></p> |
| 70 |
<div class="fbs_email_text2 fbs_email_comment_body" style="color: #525866; font-size: 14px; line-height: 22px;"><?php echo wp_kses_post($parent_comment); ?></div> |
| 71 |
</td> |
| 72 |
</tr> |
| 73 |
<?php endif; ?> |
| 74 |
<tr> |
| 75 |
<td style="padding: 16px;"> |
| 76 |
<table role="presentation" cellpadding="0" cellspacing="0" border="0" width="100%"> |
| 77 |
<tr> |
| 78 |
<?php if (!empty($userData['photo'])): ?> |
| 79 |
<td width="48" valign="top" style="width: 48px; padding-right: 12px;"> |
| 80 |
<img src="<?php echo esc_url($userData['photo']); ?>" width="36" height="36" alt="<?php echo esc_attr($userData['display_name']); ?>" style="display: block; width: 36px; height: 36px; border-radius: 999px;"> |
| 81 |
</td> |
| 82 |
<?php endif; ?> |
| 83 |
<td valign="top"> |
| 84 |
<p class="fbs_email_text2" style="margin: 0 0 4px; color: #525866; font-size: 14px; line-height: 20px;"> |
| 85 |
<strong class="fbs_email_text" style="color: #0E121B; font-weight: 600;"><?php echo esc_html(isset($userData['display_name']) ? $userData['display_name'] : ''); ?></strong> |
| 86 |
<?php if (!empty($comment_time)): ?> |
| 87 |
· <?php echo esc_html($comment_time); ?> |
| 88 |
<?php endif; ?> |
| 89 |
</p> |
| 90 |
<div class="fbs_email_text fbs_email_comment_body" style="color: #0E121B; font-size: 15px; line-height: 24px;"><?php echo wp_kses_post($comment); ?></div> |
| 91 |
</td> |
| 92 |
</tr> |
| 93 |
</table> |
| 94 |
</td> |
| 95 |
</tr> |
| 96 |
</table> |
| 97 |
<?php endif; ?> |
| 98 |
|
| 99 |
<?php if (!empty($task_card['title'])): |
| 100 |
$fluent_boards_title_color = !empty($task_card['muted']) ? '#525866' : '#0E121B'; |
| 101 |
$fluent_boards_title_class = !empty($task_card['muted']) ? 'fbs_email_text2' : 'fbs_email_text'; |
| 102 |
?> |
| 103 |
<table role="presentation" class="fbs_email_border" cellpadding="0" cellspacing="0" border="0" width="100%" style="margin-top: 24px; border: 1px solid #E1E4EA; border-radius: 10px;"> |
| 104 |
<tr> |
| 105 |
<td style="padding: 18px 20px;"> |
| 106 |
<?php if (!empty($task_card['parent_title'])): ?> |
| 107 |
<p class="fbs_email_text2" style="margin: 0 0 4px; color: #525866; font-size: 13px; line-height: 18px;"> |
| 108 |
<?php esc_html_e('Subtask of', 'fluent-boards'); ?> |
| 109 |
<?php if (!empty($task_card['parent_url'])): ?> |
| 110 |
<a class="fbs_email_link" href="<?php echo esc_url($task_card['parent_url']); ?>" target="_blank" style="color: #335CFF; font-weight: 600; text-decoration: none;"><?php echo esc_html($task_card['parent_title']); ?></a> |
| 111 |
<?php else: ?> |
| 112 |
<?php echo esc_html($task_card['parent_title']); ?> |
| 113 |
<?php endif; ?> |
| 114 |
</p> |
| 115 |
<?php endif; ?> |
| 116 |
<p class="<?php echo esc_attr($fluent_boards_title_class); ?>" style="margin: 0; color: <?php echo esc_attr($fluent_boards_title_color); ?>; font-size: 16px; font-weight: 600; line-height: 24px;"><?php echo esc_html($task_card['title']); ?></p> |
| 117 |
|
| 118 |
<?php if (!empty($task_card['rows'])): ?> |
| 119 |
<table role="presentation" cellpadding="0" cellspacing="0" border="0" width="100%" style="margin-top: 12px;"> |
| 120 |
<?php foreach ($task_card['rows'] as $fluent_boards_row): ?> |
| 121 |
<tr> |
| 122 |
<td class="fbs_email_text2 fbs_email_kv_label" width="96" valign="top" style="width: 96px; padding: 4px 12px 4px 0; color: #525866; font-size: 14px; line-height: 20px;"><?php echo esc_html($fluent_boards_row[0]); ?></td> |
| 123 |
<td class="fbs_email_text" valign="top" style="padding: 4px 0; color: #0E121B; font-size: 14px; line-height: 20px;"><?php echo wp_kses_post($fluent_boards_row[1]); ?></td> |
| 124 |
</tr> |
| 125 |
<?php endforeach; ?> |
| 126 |
</table> |
| 127 |
<?php endif; ?> |
| 128 |
|
| 129 |
<?php if (!empty($task_card['description'])): ?> |
| 130 |
<div class="fbs_email_text2 fbs_email_border fbs_email_comment_body" style="margin-top: 14px; padding-top: 14px; border-top: 1px solid #E1E4EA; color: #525866; font-size: 14px; line-height: 22px;"><?php echo wp_kses_post($task_card['description']); ?></div> |
| 131 |
<?php endif; ?> |
| 132 |
</td> |
| 133 |
</tr> |
| 134 |
</table> |
| 135 |
<?php endif; ?> |
| 136 |
|
| 137 |
<?php if (!empty($change['to'])): ?> |
| 138 |
<table role="presentation" class="fbs_email_inset" cellpadding="0" cellspacing="0" border="0" width="100%" style="margin-top: 24px; background: #F5F7FA; border: 1px solid #E1E4EA; border-radius: 10px;"> |
| 139 |
<tr> |
| 140 |
<td style="padding: 14px 16px; font-size: 13px; line-height: 20px;"> |
| 141 |
<?php if (!empty($change['from'])): ?> |
| 142 |
<span class="fbs_email_pill_neutral" style="display: inline-block; padding: 3px 10px; border-radius: 6px; background: #F2F5F8; color: #3F4552; font-weight: 600;<?php echo !empty($change['strike']) ? ' text-decoration: line-through;' : ''; ?>"><?php echo esc_html($change['from']); ?></span> |
| 143 |
<span class="fbs_email_text2" style="color: #525866; padding: 0 6px;">→</span> |
| 144 |
<?php elseif (!empty($change['label'])): ?> |
| 145 |
<span class="fbs_email_text2" style="color: #525866; padding-right: 8px;"><?php echo esc_html($change['label']); ?></span> |
| 146 |
<?php endif; ?> |
| 147 |
<span class="fbs_email_pill_accent" style="display: inline-block; padding: 3px 10px; border-radius: 6px; background: #EEF2FF; color: #2547D0; font-weight: 600;"><?php echo esc_html($change['to']); ?></span> |
| 148 |
</td> |
| 149 |
</tr> |
| 150 |
</table> |
| 151 |
<?php endif; ?> |
| 152 |
|
| 153 |
<?php if (!empty($note)): ?> |
| 154 |
<p class="fbs_email_text2" style="margin: 24px 0 0; color: #525866; font-size: 14px; line-height: 22px;"><?php echo esc_html($note); ?></p> |
| 155 |
<?php endif; ?> |
| 156 |
|
| 157 |
<?php if (!empty($cta['url']) && !empty($cta['label'])): ?> |
| 158 |
<p style="margin: 24px 0 0;"> |
| 159 |
<?php if (isset($cta['style']) && 'secondary' === $cta['style']): ?> |
| 160 |
<?php // Regular button: 32px tall including the 1px border. ?> |
| 161 |
<a class="fbs_email_btn_secondary" href="<?php echo esc_url($cta['url']); ?>" target="_blank" style="display: inline-block; padding: 5px 14px; border: 1px solid #E1E4EA; border-radius: 8px; color: #0E121B; font-size: 14px; font-weight: 500; line-height: 20px; text-decoration: none;"><?php echo esc_html($cta['label']); ?></a> |
| 162 |
<?php else: ?> |
| 163 |
<?php // Primary button: 36px tall, the product maximum. ?> |
| 164 |
<a class="fbs_email_btn" href="<?php echo esc_url($cta['url']); ?>" target="_blank" style="display: inline-block; padding: 8px 16px; border-radius: 8px; background: #222530; color: #FFFFFF; font-size: 14px; font-weight: 500; line-height: 20px; text-decoration: none;"><?php echo esc_html($cta['label']); ?></a> |
| 165 |
<?php endif; ?> |
| 166 |
</p> |
| 167 |
<?php endif; ?> |
| 168 |
|
| 169 |
<?php if (!empty($fallback_url)): ?> |
| 170 |
<div class="fbs_email_border" style="margin-top: 24px; padding-top: 20px; border-top: 1px solid #E1E4EA;"> |
| 171 |
<p class="fbs_email_text2" style="margin: 0 0 8px; color: #525866; font-size: 13px; line-height: 20px;"><?php esc_html_e('Button not working? Paste this link into your browser:', 'fluent-boards'); ?></p> |
| 172 |
<p class="fbs_email_inset fbs_email_link fbs_email_url" style="margin: 0; padding: 10px 12px; border-radius: 8px; background: #F5F7FA; color: #335CFF; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; line-height: 18px;"><?php echo esc_html($fallback_url); ?></p> |
| 173 |
</div> |
| 174 |
<?php endif; ?> |
| 175 |
<?php |
| 176 |
$fluent_boards_email_content = ob_get_clean(); |
| 177 |
include __DIR__ . '/template.php'; |
| 178 |
|