| 1 |
<?php if ( ! defined( 'ABSPATH' ) ) exit; ?> |
| 2 |
<?php |
| 3 |
/** |
| 4 |
* To the reviewer: the store has replied to their review. |
| 5 |
* |
| 6 |
* @var \FluentCart\App\Models\ProductReview $reply the store's reply |
| 7 |
* @var \FluentCart\App\Models\ProductReview $review the review it answers — its author is the recipient |
| 8 |
* @var \FluentCart\App\Models\Product|object|null $product |
| 9 |
*/ |
| 10 |
$productTitle = $product && !empty($product->post_title) |
| 11 |
? (string) $product->post_title |
| 12 |
: __('the product', 'fluent-cart'); |
| 13 |
|
| 14 |
// The item the review names, when it does — on a copy, for the reason the |
| 15 |
// approval template gives: the helper sets item_label as an attribute, and |
| 16 |
// this can render on a model the caller goes on to save(). |
| 17 |
$reviewWithItemLabel = clone $review; |
| 18 |
\FluentCart\App\Services\ProductReviewService::attachItemLabels([$reviewWithItemLabel]); |
| 19 |
$itemLabel = trim((string) $reviewWithItemLabel->getAttribute('item_label')); |
| 20 |
if ($itemLabel !== '') { |
| 21 |
/* translators: 1: product title, 2: item (variation) label */ |
| 22 |
$productTitle = sprintf(__('%1$s (%2$s)', 'fluent-cart'), $productTitle, $itemLabel); |
| 23 |
} |
| 24 |
|
| 25 |
$productId = $product && !empty($product->ID) ? (int) $product->ID : (int) $review->post_id; |
| 26 |
$productUrl = $productId ? get_permalink($productId) : ''; |
| 27 |
|
| 28 |
$storeName = trim((string) (new \FluentCart\Api\StoreSettings())->get('store_name')); |
| 29 |
if ($storeName === '') { |
| 30 |
$storeName = (string) get_bloginfo('name'); |
| 31 |
} |
| 32 |
|
| 33 |
$reviewerName = trim((string) $review->reviewer_name); |
| 34 |
$rating = max(0, min(5, (int) $review->rating)); |
| 35 |
?> |
| 36 |
|
| 37 |
<div class="space_bottom_30"> |
| 38 |
<p> |
| 39 |
<?php |
| 40 |
if ($reviewerName !== '') { |
| 41 |
/* translators: 1: the reviewer's name */ |
| 42 |
printf(esc_html__('Hello %1$s,', 'fluent-cart'), esc_html($reviewerName)); |
| 43 |
} else { |
| 44 |
esc_html_e('Hello,', 'fluent-cart'); |
| 45 |
} |
| 46 |
?> |
| 47 |
</p> |
| 48 |
<p> |
| 49 |
<?php |
| 50 |
printf( |
| 51 |
/* translators: 1: the store name, 2: the product title */ |
| 52 |
esc_html__('%1$s has replied to your review of %2$s.', 'fluent-cart'), |
| 53 |
'<strong>' . esc_html($storeName) . '</strong>', |
| 54 |
'<strong>' . esc_html($productTitle) . '</strong>' |
| 55 |
); |
| 56 |
?> |
| 57 |
</p> |
| 58 |
</div> |
| 59 |
|
| 60 |
<?php // What they wrote, so the reply has its context. ?> |
| 61 |
<table width="100%" border="0" cellpadding="0" cellspacing="0" role="presentation" style="margin-bottom:16px;background-color:#f8fafc;border:1px solid #e5e7eb;border-radius:8px;border-collapse:separate;"> |
| 62 |
<tbody> |
| 63 |
<tr> |
| 64 |
<td style="padding:20px 24px;"> |
| 65 |
<p style="margin:0 0 8px;font-size:12px;font-weight:600;letter-spacing:.04em;text-transform:uppercase;color:#6b7280;"><?php esc_html_e('Your review', 'fluent-cart'); ?></p> |
| 66 |
<?php if ($rating > 0) : ?> |
| 67 |
<?php // Filled and hollow glyphs, and the number in words, so the rating reads without colour. ?> |
| 68 |
<p style="margin:0 0 10px;font-size:18px;line-height:1;letter-spacing:2px;"> |
| 69 |
<span style="color:<?php echo esc_attr(\FluentCart\App\Services\Renderer\ProductReviewRenderer::starColors()['filled']); ?>;"><?php echo str_repeat('★', $rating); ?></span><span style="color:<?php echo esc_attr(\FluentCart\App\Services\Renderer\ProductReviewRenderer::starColors()['empty']); ?>;"><?php echo str_repeat('☆', 5 - $rating); ?></span> |
| 70 |
<span style="font-size:13px;letter-spacing:0;color:#6b7280;vertical-align:middle;"> |
| 71 |
<?php |
| 72 |
printf( |
| 73 |
/* translators: 1: the rating given, out of five */ |
| 74 |
esc_html__('%1$d out of 5', 'fluent-cart'), |
| 75 |
$rating |
| 76 |
); |
| 77 |
?> |
| 78 |
</span> |
| 79 |
</p> |
| 80 |
<?php endif; ?> |
| 81 |
<?php if (!empty($review->title)) : ?> |
| 82 |
<p style="margin:0 0 8px;font-size:16px;font-weight:700;line-height:1.4;color:#111827;"><?php echo esc_html($review->title); ?></p> |
| 83 |
<?php endif; ?> |
| 84 |
<p style="margin:0;font-size:15px;line-height:1.7;color:#374151;"><?php echo nl2br(esc_html($review->content)); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- escaped by esc_html() before nl2br() ?></p> |
| 85 |
</td> |
| 86 |
</tr> |
| 87 |
</tbody> |
| 88 |
</table> |
| 89 |
|
| 90 |
<?php // The reply. ?> |
| 91 |
<table width="100%" border="0" cellpadding="0" cellspacing="0" role="presentation" style="margin-bottom:28px;background-color:#ffffff;border:1px solid #e5e7eb;border-left:4px solid #0f172a;border-radius:8px;border-collapse:separate;"> |
| 92 |
<tbody> |
| 93 |
<tr> |
| 94 |
<td style="padding:20px 24px;"> |
| 95 |
<p style="margin:0 0 8px;font-size:12px;font-weight:600;letter-spacing:.04em;text-transform:uppercase;color:#6b7280;"> |
| 96 |
<?php |
| 97 |
printf( |
| 98 |
/* translators: 1: the store name */ |
| 99 |
esc_html__('Reply from %1$s', 'fluent-cart'), |
| 100 |
esc_html($storeName) |
| 101 |
); |
| 102 |
?> |
| 103 |
</p> |
| 104 |
<p style="margin:0;font-size:15px;line-height:1.7;color:#111827;"><?php echo nl2br(esc_html($reply->content)); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- escaped by esc_html() before nl2br() ?></p> |
| 105 |
</td> |
| 106 |
</tr> |
| 107 |
</tbody> |
| 108 |
</table> |
| 109 |
|
| 110 |
<?php if ($productUrl) : ?> |
| 111 |
<table border="0" cellpadding="0" cellspacing="0" role="presentation" style="margin-bottom:28px;"> |
| 112 |
<tbody> |
| 113 |
<tr> |
| 114 |
<td> |
| 115 |
<a href="<?php echo esc_url($productUrl); ?>" target="_blank" style="display:inline-block;background-color:#0f172a;color:#ffffff;padding:14px 28px;border-radius:8px;font-size:16px;font-weight:600;text-decoration:none;"> |
| 116 |
<?php esc_html_e('See the reply', 'fluent-cart'); ?> → |
| 117 |
</a> |
| 118 |
</td> |
| 119 |
</tr> |
| 120 |
</tbody> |
| 121 |
</table> |
| 122 |
<?php endif; ?> |
| 123 |
|
| 124 |
<div class="space_bottom_30"> |
| 125 |
<p style="margin:0;font-size:15px;line-height:1.6;color:#9ca3af;"> |
| 126 |
<?php esc_html_e('Thank you again for taking the time to share your experience.', 'fluent-cart'); ?> |
| 127 |
</p> |
| 128 |
</div> |
| 129 |
|