| 1 |
<?php |
| 2 |
// phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- View file, its variables are local to the include scope, not true globals. |
| 3 |
defined('ABSPATH') || die('Restricted Access'); |
| 4 |
$anonymousStats = !empty($data['anonymousStats']); |
| 5 |
|
| 6 |
// In anonymous mode opens/clicks are counted globally (totals, not unique subscribers): each campaign shows an average number of opens/clicks per email sent (e.g. 3.25×) instead of a percentage of recipients, so the average we compare it against must be expressed in the same "per sent" unit. |
| 7 |
if ($anonymousStats) { |
| 8 |
$sentTotal = $data['mail']->sent ?? 0; |
| 9 |
$openRate = empty($sentTotal) ? 0 : ($data['mail']->openCount ?? 0) / $sentTotal; |
| 10 |
$clickRate = empty($sentTotal) ? 0 : ($data['mail']->clickCount ?? 0) / $sentTotal; |
| 11 |
$rateSuffix = '×'; |
| 12 |
$rateTooltipKey = 'ACYM_RATE_AVERAGE_COMPARE_ANONYMOUS_TOOLTIP'; |
| 13 |
} else { |
| 14 |
$openRate = $data['stats']['ACYM_OPEN_RATE']['value']; |
| 15 |
$clickRate = $data['stats']['ACYM_CLICK_RATE']['value']; |
| 16 |
$rateSuffix = '%'; |
| 17 |
$rateTooltipKey = 'ACYM_RATE_AVERAGE_COMPARE_TOOLTIP'; |
| 18 |
} |
| 19 |
?> |
| 20 |
|
| 21 |
<div class="acym__content cell"> |
| 22 |
<div class="cell acym__title acym__dashboard__title"><?php echo esc_html(acym_translation('ACYM_RECENT_CAMPAIGNS')); ?></div> |
| 23 |
<span class="separator"></span> |
| 24 |
<?php if ($data['recent_campaigns']) { ?> |
| 25 |
<div class="grid-x acym__listing cell"> |
| 26 |
<div class="grid-x cell acym__listing__header"> |
| 27 |
<div class="grid-x medium-auto small-12"> |
| 28 |
<div class="cell small-6 acym__listing__header__title"> |
| 29 |
<?php echo esc_html(acym_translation('ACYM_CAMPAIGN')); ?> |
| 30 |
</div> |
| 31 |
<div class="cell small-2 acym__listing__header__title"> |
| 32 |
<?php echo esc_html(acym_translation('ACYM_TOTAL_SUBSCRIBERS_COLUMN_STAT')); ?> |
| 33 |
</div> |
| 34 |
<div class="cell small-2 acym__listing__header__title"> |
| 35 |
<?php echo esc_html(acym_translation('ACYM_OPEN').' / '.acym_translation('ACYM_AVERAGE_COMPARE')); |
| 36 |
acym_info(['textShownInTooltip' => $rateTooltipKey]); ?> |
| 37 |
</div> |
| 38 |
<div class="cell small-2 acym__listing__header__title"> |
| 39 |
<?php echo esc_html(acym_translation('ACYM_CLICK').' / '.acym_translation('ACYM_AVERAGE_COMPARE')); |
| 40 |
acym_info(['textShownInTooltip' => $rateTooltipKey]); ?> |
| 41 |
</div> |
| 42 |
</div> |
| 43 |
</div> |
| 44 |
|
| 45 |
<?php |
| 46 |
foreach ($data['recent_campaigns'] as $campaign) { ?> |
| 47 |
<div class="grid-x cell align-middle acym__listing__row"> |
| 48 |
<div class="cell small-6"> |
| 49 |
<?php echo esc_html($campaign->name); ?><br> |
| 50 |
<?php echo esc_html(acym_date($campaign->sending_date, acym_getDateTimeFormat())); ?> |
| 51 |
</div> |
| 52 |
<div class="cell small-2 large"> |
| 53 |
<?php echo esc_html($campaign->subscribers ?? 0); ?> |
| 54 |
</div> |
| 55 |
<div class="cell small-2 "> |
| 56 |
<?php echo esc_html($campaign->open.$rateSuffix ?? ''); ?> |
| 57 |
<i class="acymicon-<?php echo ($campaign->open > $openRate) ? 'arrow-up-thin acym__color__green' : 'arrow-down-thin acym__color__red'; ?>"></i> |
| 58 |
</div> |
| 59 |
<div class="cell small-2 "> |
| 60 |
<?php echo esc_html($campaign->click.$rateSuffix ?? ''); ?> |
| 61 |
<i class="acymicon-<?php echo ($campaign->click > $clickRate) ? 'arrow-up-thin acym__color__green' : 'arrow-down-thin acym__color__red'; ?>"></i> |
| 62 |
</div> |
| 63 |
</div> |
| 64 |
<?php } ?> |
| 65 |
</div> |
| 66 |
<?php } else { ?> |
| 67 |
<div class="cell grid-x"> |
| 68 |
<div class="cell text-center acym__dashboard__empty"> |
| 69 |
<?php echo esc_html(acym_translation('ACYM_NO_RECENT_CAMPAIGNS')); ?> |
| 70 |
</div> |
| 71 |
</div> |
| 72 |
<?php } ?> |
| 73 |
</div> |
| 74 |
|