| @@ -1,106 +1,76 @@ | ||
| 1 | -<?php | |
| 1 | +<?php if (!defined('ABSPATH')) exit; // if accessed directly exit | |
| 2 | 2 | /** |
| 3 | - * @var $body string | |
| 4 | - * @var $pre_header string | |
| 5 | - * @var $show_footer bool | |
| 6 | - * @var $task object | |
| 7 | - * @var $parent_task object | |
| 8 | - * @var $board object | |
| 9 | - * @var $task_url string | |
| 10 | - * @var $site_url string | |
| 11 | - * @var $site_title string | |
| 12 | - * @var $site_logo string | |
| 3 | + * Task and subtask reminder email (sent by Fluent Boards Pro). | |
| 4 | + * | |
| 5 | + * @var object $task Task or subtask being reminded about | |
| 6 | + * @var object $parent_task Parent task (the task itself for top-level tasks) | |
| 7 | + * @var object $board | |
| 8 | + * @var string $stage Stage title | |
| 9 | + * @var string $task_url | |
| 10 | + * @var object $user Recipient (optional; older senders omit it) | |
| 13 | 11 | */ |
| 14 | 12 | |
| 15 | -ob_start(); // Start output buffering | |
| 16 | -?> | |
| 13 | +$fluent_boards_is_subtask = !empty($task->parent_id); | |
| 17 | 14 | |
| 18 | - | |
| 19 | -<div style="font-family: Arial, sans-serif; color:#333; line-height:1.5; background: #ffff !important;"> | |
| 20 | - <?php | |
| 21 | - // Resolve a safe recipient name to avoid broken greeting when $user is missing | |
| 22 | - $fluent_boards_recipient_name = ''; | |
| 23 | - if (isset($user) && is_object($user)) { | |
| 24 | - $fluent_boards_recipient_name = $user->display_name ?? ''; | |
| 25 | - if (!$fluent_boards_recipient_name && !empty($user->user_nicename)) { | |
| 26 | - $fluent_boards_recipient_name = $user->user_nicename; | |
| 15 | +// Resolve a safe recipient name to avoid a broken greeting when $user is missing. | |
| 16 | +$fluent_boards_recipient_name = ''; | |
| 17 | +if (isset($user) && is_object($user)) { | |
| 18 | + foreach (['display_name', 'user_nicename', 'user_login'] as $fluent_boards_name_field) { | |
| 19 | + if (!empty($user->{$fluent_boards_name_field})) { | |
| 20 | + $fluent_boards_recipient_name = $user->{$fluent_boards_name_field}; | |
| 21 | + break; | |
| 27 | 22 | } |
| 28 | - if (!$fluent_boards_recipient_name && !empty($user->user_login)) { | |
| 29 | - $fluent_boards_recipient_name = $user->user_login; | |
| 30 | - } | |
| 31 | 23 | } |
| 32 | - if (!$fluent_boards_recipient_name) { | |
| 33 | - $fluent_boards_recipient_name = __('there', 'fluent-boards'); | |
| 34 | - } | |
| 35 | - ?> | |
| 36 | - <p style="font-size:16px; font-weight:600; margin:0 0 10px 0;background: #fff !important;"> | |
| 37 | - <?php | |
| 38 | - // translators: %s is the recipient's name | |
| 39 | - printf(esc_html__('Hey %s,', 'fluent-boards'), esc_html($fluent_boards_recipient_name)); | |
| 40 | - ?> | |
| 41 | - </p> | |
| 24 | +} | |
| 42 | 25 | |
| 43 | - <p style="margin:0 0 15px 0; font-size:14px; color:#555; background: #fff !important;"> | |
| 44 | - <?php echo wp_kses_post($body); ?> | |
| 45 | - </p> | |
| 26 | +if ($fluent_boards_recipient_name) { | |
| 27 | + $heading = $fluent_boards_is_subtask | |
| 28 | + /* translators: %s is the recipient's name */ | |
| 29 | + ? sprintf(__('Hi %s, a subtask is due soon', 'fluent-boards'), $fluent_boards_recipient_name) | |
| 30 | + /* translators: %s is the recipient's name */ | |
| 31 | + : sprintf(__('Hi %s, a task is due soon', 'fluent-boards'), $fluent_boards_recipient_name); | |
| 32 | +} else { | |
| 33 | + $heading = $fluent_boards_is_subtask | |
| 34 | + ? __('A subtask is due soon', 'fluent-boards') | |
| 35 | + : __('A task is due soon', 'fluent-boards'); | |
| 36 | +} | |
| 46 | 37 | |
| 47 | - <div style="margin: 15px 0; padding: 15px; border:1px solid #eee; border-radius: 8px;"> | |
| 48 | - <h4 style="margin: 0 0 10px 0; color: #333; font-size: 16px;"> | |
| 49 | - <?php echo $task->parent_id ? esc_html__('Subtask Details:', 'fluent-boards') : esc_html__('Task Details:', 'fluent-boards'); ?> | |
| 50 | - </h4> | |
| 51 | - | |
| 52 | - <p style="margin: 5px 0; font-size:14px;"> | |
| 53 | - <strong><?php echo $task->parent_id ? esc_html__('Subtask:', 'fluent-boards') : esc_html__('Task:', 'fluent-boards'); ?></strong> | |
| 54 | - <?php echo esc_html($task->title); ?> | |
| 55 | - </p> | |
| 56 | - | |
| 57 | - <?php if ($task->parent_id && $parent_task): ?> | |
| 58 | - <p style="margin: 5px 0; font-size:14px;"> | |
| 59 | - <strong><?php echo esc_html__('Parent Task:', 'fluent-boards'); ?></strong> | |
| 60 | - <?php echo esc_html($parent_task->title); ?> | |
| 61 | - </p> | |
| 62 | - <?php endif; ?> | |
| 63 | - | |
| 64 | - <p style="margin: 5px 0; font-size:14px;"> | |
| 65 | - <strong><?php echo esc_html__('Board:', 'fluent-boards'); ?></strong> | |
| 66 | - <?php echo esc_html($board->title); ?> | |
| 67 | - </p> | |
| 38 | +$badge = [ | |
| 39 | + 'label' => __('Reminder', 'fluent-boards'), | |
| 40 | + 'tone' => 'warn', | |
| 41 | +]; | |
| 68 | 42 | |
| 69 | - <p style="margin: 5px 0; font-size:14px;"> | |
| 70 | - <strong><?php echo esc_html__('Stage:', 'fluent-boards'); ?></strong> | |
| 71 | - <?php echo esc_html($stage); ?> | |
| 72 | - </p> | |
| 73 | - | |
| 74 | - <?php if ($task->due_at): ?> | |
| 75 | - <p style="margin: 5px 0; font-size:14px;"> | |
| 76 | - <strong><?php echo esc_html__('Due Date:', 'fluent-boards'); ?></strong> | |
| 77 | - <?php echo esc_html(gmdate('M j, Y g:i A', strtotime($task->due_at))); ?> | |
| 78 | - </p> | |
| 79 | - <?php endif; ?> | |
| 80 | - | |
| 81 | - <?php if ($task->description): ?> | |
| 82 | - <p style="margin: 10px 0 5px 0; font-size:14px;"> | |
| 83 | - <strong><?php echo esc_html__('Description:', 'fluent-boards'); ?></strong> | |
| 84 | - </p> | |
| 85 | - <div style="margin: 5px 0; padding: 10px; border-radius: 4px; font-size: 14px;"> | |
| 86 | - <?php echo wp_kses_post(wp_trim_words($task->description, 30)); ?> | |
| 87 | - </div> | |
| 88 | - <?php endif; ?> | |
| 89 | - </div> | |
| 90 | - | |
| 91 | - <div style="margin-top:20px; background: #fff !important;"> | |
| 92 | - <a href="<?php echo esc_url($task_url); ?>" | |
| 93 | - target="_blank" | |
| 94 | - style="background: #6268F1; color: #FFF; padding:7px 12px; text-decoration: none; border-radius: 6px; display: inline-block; font-weight: 500; font-size:14px;"> | |
| 95 | - <?php echo $task->parent_id ? esc_html__('View Subtask', 'fluent-boards') : esc_html__('View Task', 'fluent-boards'); ?> | |
| 96 | - </a> | |
| 97 | - </div> | |
| 98 | -</div> | |
| 43 | +$fluent_boards_rows = [ | |
| 44 | + [__('Board', 'fluent-boards'), esc_html($board->title)], | |
| 45 | +]; | |
| 46 | +if (!empty($stage)) { | |
| 47 | + $fluent_boards_rows[] = [__('Stage', 'fluent-boards'), esc_html($stage)]; | |
| 48 | +} | |
| 49 | +if (!empty($task->due_at)) { | |
| 50 | + $fluent_boards_rows[] = [ | |
| 51 | + __('Due', 'fluent-boards'), | |
| 52 | + '<strong class="fbs_email_warn_text" style="color: #7A4D00;">' . esc_html(date_i18n(get_option('date_format') . ' ' . get_option('time_format'), strtotime($task->due_at))) . '</strong>', | |
| 53 | + ]; | |
| 54 | +} | |
| 99 | 55 | |
| 56 | +$task_card = [ | |
| 57 | + 'title' => $task->title, | |
| 58 | + 'parent_title' => ($fluent_boards_is_subtask && !empty($parent_task)) ? $parent_task->title : '', | |
| 59 | + 'parent_url' => $fluent_boards_is_subtask ? $task_url : '', | |
| 60 | + 'rows' => $fluent_boards_rows, | |
| 61 | + 'description' => !empty($task->description) ? wp_trim_words($task->description, 30) : '', | |
| 62 | +]; | |
| 100 | 63 | |
| 101 | -<!--end your code here --> | |
| 64 | +$cta = [ | |
| 65 | + 'label' => $fluent_boards_is_subtask ? __('Open subtask', 'fluent-boards') : __('Open task', 'fluent-boards'), | |
| 66 | + 'url' => $task_url, | |
| 67 | +]; | |
| 102 | 68 | |
| 103 | -<?php | |
| 104 | -$fluent_boards_email_content = ob_get_clean(); | |
| 105 | -include 'template.php'; | |
| 106 | -?> | |
| 69 | +if (empty($email_reason)) { | |
| 70 | + $email_reason = __('You’re getting this because you’re assigned and reminders are on.', 'fluent-boards'); | |
| 71 | +} | |
| 72 | + | |
| 73 | +// The sender's $body repeats the heading; the structured card replaces it. | |
| 74 | +$body = ''; | |
| 75 | + | |
| 76 | +include __DIR__ . '/notification.php'; | |