| 1 |
<?php if (!defined('ABSPATH')) exit; // if accessed directly exit |
| 2 |
/** |
| 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) |
| 11 |
*/ |
| 12 |
|
| 13 |
$fluent_boards_is_subtask = !empty($task->parent_id); |
| 14 |
|
| 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; |
| 22 |
} |
| 23 |
} |
| 24 |
} |
| 25 |
|
| 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 |
} |
| 37 |
|
| 38 |
$badge = [ |
| 39 |
'label' => __('Reminder', 'fluent-boards'), |
| 40 |
'tone' => 'warn', |
| 41 |
]; |
| 42 |
|
| 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 |
} |
| 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 |
]; |
| 63 |
|
| 64 |
$cta = [ |
| 65 |
'label' => $fluent_boards_is_subtask ? __('Open subtask', 'fluent-boards') : __('Open task', 'fluent-boards'), |
| 66 |
'url' => $task_url, |
| 67 |
]; |
| 68 |
|
| 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'; |
| 77 |
|