| 1 |
<?php |
| 2 |
|
| 3 |
trait TimeInsertion |
| 4 |
{ |
| 5 |
public function dynamicText(?int $mailId): ?object |
| 6 |
{ |
| 7 |
return $this->pluginDescription; |
| 8 |
} |
| 9 |
|
| 10 |
public function textPopup(): void |
| 11 |
{ |
| 12 |
$others = [ |
| 13 |
'{date:1}' => 'ACYM_DATE_FORMAT_LC1', |
| 14 |
'{date:2}' => 'ACYM_DATE_FORMAT_LC2', |
| 15 |
'{date:3}' => 'ACYM_DATE_FORMAT_LC3', |
| 16 |
'{date:4}' => 'ACYM_DATE_FORMAT_LC4', |
| 17 |
'{date:m/d/Y}' => 'm/d/Y', |
| 18 |
'{date:d/m/Y}' => 'd/m/Y', |
| 19 |
'{date:l}' => 'l', |
| 20 |
'{date:W}' => 'W', |
| 21 |
'{date:F}' => 'F', |
| 22 |
'{date:Y}' => 'Y', |
| 23 |
|
| 24 |
]; |
| 25 |
|
| 26 |
echo '<div class="acym__popup__listing text-center grid-x"> |
| 27 |
<h1 class="acym__title acym__title__secondary text-center cell">'.esc_html(acym_translation('ACYM_TIME_FORMAT')).'</h1>'; |
| 28 |
|
| 29 |
$k = 0; |
| 30 |
foreach ($others as $tagname => $tag) { |
| 31 |
echo '<div class="grid-x medium-12 cell acym__row__no-listing acym__listing__row__popup text-left" onclick="setTag(\''.esc_attr($tagname).'\', jQuery(this));" > |
| 32 |
<div class="cell medium-6 small-12 acym__listing__title acym__listing__title__dynamics">'.esc_html(acym_translation($tag)).'</div> |
| 33 |
<div class="cell medium-6 small-12 acym__listing__title acym__listing__title__dynamics">'.esc_html(acym_getDate(time(), acym_translation($tag))).'</div> |
| 34 |
</div>'; |
| 35 |
$k = 1 - $k; |
| 36 |
} |
| 37 |
|
| 38 |
echo '</div>'; |
| 39 |
} |
| 40 |
|
| 41 |
public function replaceContent(object &$email): void |
| 42 |
{ |
| 43 |
$extractedTags = $this->pluginHelper->extractTags($email, 'date'); |
| 44 |
if (empty($extractedTags)) { |
| 45 |
return; |
| 46 |
} |
| 47 |
|
| 48 |
$tags = []; |
| 49 |
foreach ($extractedTags as $i => $oneTag) { |
| 50 |
if (isset($tags[$i])) { |
| 51 |
continue; |
| 52 |
} |
| 53 |
|
| 54 |
$time = time(); |
| 55 |
if (!empty($oneTag->senddate) && !empty($email->sending_date)) { |
| 56 |
$time = strtotime($email->sending_date); |
| 57 |
} |
| 58 |
if (!empty($oneTag->add)) { |
| 59 |
$time += intval($oneTag->add); |
| 60 |
} |
| 61 |
if (!empty($oneTag->remove)) { |
| 62 |
$time -= intval($oneTag->remove); |
| 63 |
} |
| 64 |
|
| 65 |
if (empty($oneTag->id) || is_numeric($oneTag->id)) { |
| 66 |
$oneTag->id = acym_translation('ACYM_DATE_FORMAT_LC'.$oneTag->id); |
| 67 |
} |
| 68 |
$oneTag->id = str_replace( |
| 69 |
['%A', '%d', '%B', '%m', '%Y', '%y', '%H', '%M', '%S', '%a', '%I', '%p', '%w'], |
| 70 |
['l', 'd', 'F', 'm', 'Y', 'y', 'H', 'i', 's', 'D', 'h', 'a', 'w'], |
| 71 |
$oneTag->id |
| 72 |
); |
| 73 |
$tags[$i] = acym_date($time, $oneTag->id, true); |
| 74 |
} |
| 75 |
|
| 76 |
$this->pluginHelper->replaceTags($email, $tags); |
| 77 |
} |
| 78 |
} |
| 79 |
|