PluginProbe
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress / trunk
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress vtrunk
11.0.5 11.0.4 11.0.3 11.0.2 11.0.1 11.0.0 10.11.1 10.11.0 10.10.2 10.10.1 10.10.0 10.9.1 trunk 10.0.0 10.0.1 10.1.0 10.1.1 10.1.2 10.1.3 10.1.4 10.2.0 10.2.1 10.2.2 10.3.0 10.4.0 All 60 releases
acymailing / back / dynamics / time / TimeInsertion.php

TimeInsertion.php in AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress trunk, at back/dynamics/time/TimeInsertion.php

79 lines 2.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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