PluginProbe
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress / 11.1.1
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress v11.1.1
11.1.1 11.1.0 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 All 62 releases
← All changes | back/dynamics/online/OnlineInsertion.php +0 -215 trunk → 11.1.1 View file →
@@ -1,215 +1,0 @@
1 -<?php
2 -
3 -trait OnlineInsertion
4 -{
5 - public function dynamicText(?int $mailId): ?object
6 - {
7 - return $this->pluginDescription;
8 - }
9 -
10 - public function textPopup(): void
11 - {
12 - $links = [
13 - 'readonline' => [
14 - 'default' => acym_translation('ACYM_VIEW_ONLINE', true),
15 - 'desc' => acym_translation('ACYM_VIEW_ONLINE_DESC'),
16 - ],
17 - 'modify_profile' => [
18 - 'default' => acym_translation('ACYM_MODIFY_MY_PROFILE', true),
19 - 'desc' => acym_translation('ACYM_MODIFY_PROFILE_DESC'),
20 - 'disabled' => (ACYM_CMS === 'joomla' && empty(acym_getPageLink('view=frontusers&layout=profile'))),
21 - 'tooltip' => acym_translation('ACYM_NO_PROFILE_MENU'),
22 - ],
23 - ];
24 -
25 - $information = [];
26 - if (ACYM_CMS === 'joomla') {
27 - $baseUrlValue = ACYM_J50 ? \Joomla\CMS\Uri\Uri::root() : JURI::root();
28 - $information = [
29 - 'site_name' => [
30 - 'label' => acym_translation('ACYM_SITE_NAME'),
31 - 'value' => acym_getCMSConfig('sitename'),
32 - ],
33 - 'base_url' => [
34 - 'label' => ucfirst(acym_translationSprintf('ACYM_X_URL', ACYM_CMS)),
35 - 'value' => $baseUrlValue,
36 - ],
37 - ];
38 - } elseif (ACYM_CMS === 'wordpress') {
39 - $information = [
40 - 'site_name' => [
41 - 'label' => acym_translation('ACYM_SITE_NAME'),
42 - 'value' => acym_getCMSConfig('sitename'),
43 - ],
44 - 'wp_address' => [
45 - 'label' => ucfirst(acym_translationSprintf('ACYM_X_ADDRESS', ACYM_CMS)),
46 - 'value' => acym_getCMSConfig('siteurl'),
47 - ],
48 - 'site_address' => [
49 - 'label' => acym_translation('ACYM_SITE_URL'),
50 - 'value' => acym_getCMSConfig('home'),
51 - ],
52 - 'tagline' => [
53 - 'label' => acym_translation('ACYM_TAGLINE'),
54 - 'value' => acym_getCMSConfig('blogdescription'),
55 - ],
56 - 'site_icon' => [
57 - 'label' => acym_translation('ACYM_SITE_ICON'),
58 - 'value' => get_site_icon_url(),
59 - ],
60 - 'admin_email' => [
61 - 'label' => acym_translation('ACYM_ADMIN_EMAIL'),
62 - 'value' => acym_getCMSConfig('admin_email'),
63 - ],
64 - ];
65 - }
66 - ?>
67 - <script type="text/javascript">
68 - let selectedOnlineDText = '';
69 - let selectedInfoKey = '';
70 -
71 - function changeOnlineTag(tagName, infoKey = '', disableInput = false) {
72 - selectedOnlineDText = tagName;
73 - selectedInfoKey = infoKey;
74 - const defaultText = [];
75 - <?php
76 - foreach ($links as $tagname => $tag) {
77 - echo 'defaultText['.json_encode($tagname).'] = '.json_encode($tag['default']).';';
78 - }
79 - foreach ($information as $infoKey => $info) {
80 - echo 'defaultText['.json_encode('info_'.$infoKey).'] = '.json_encode($info['value']).';';
81 - }
82 - ?>
83 - jQuery('.selected_row').removeClass('selected_row');
84 - jQuery('#tr_' + tagName).addClass('selected_row');
85 -
86 - if (infoKey === '') {
87 - document.getElementById('acym__popup__online__tagtext').value = defaultText[tagName];
88 - } else {
89 - document.getElementById('acym__popup__online__tagtext').value = '';
90 - document.getElementById('acym__popup__online__tagtext').setAttribute('data-value', defaultText['info_' + infoKey]);
91 - }
92 -
93 - if (disableInput) {
94 - document.getElementById('acym__popup__online__tagtext').setAttribute('readonly', 'readonly');
95 - } else {
96 - document.getElementById('acym__popup__online__tagtext').removeAttribute('readonly');
97 - }
98 -
99 - setOnlineTag();
100 - }
101 -
102 - function getTagText() {
103 - const tagText = document.getElementById('acym__popup__online__tagtext');
104 - return tagText.value != '' ? tagText.value : tagText.getAttribute('data-value') || '';
105 - }
106 -
107 - function setOnlineTag() {
108 - setTimeout(function () {
109 - let tag = '{';
110 -
111 - if (selectedOnlineDText === 'info') {
112 - tag += 'info:' + selectedInfoKey;
113 - } else {
114 - tag += selectedOnlineDText;
115 - }
116 -
117 - if (selectedOnlineDText === 'readonline') {
118 - const themeInput = document.querySelector('input[name="acym__popup__online__theme"]');
119 - tag += '|theme:';
120 - if (themeInput && themeInput.value === '1') {
121 - tag += '1';
122 - } else {
123 - tag += '0';
124 - }
125 - }
126 -
127 - tag += `}${getTagText()}{/${selectedOnlineDText}}`;
128 -
129 - setTag(tag, jQuery('#tr_' + selectedOnlineDText));
130 - }, 50);
131 - }
132 - </script>
133 -
134 - <?php
135 - include acym_getPartial('editor', 'website_content');
136 - }
137 -
138 - public function replaceContent(object &$email): void
139 - {
140 - if (empty($email->body)) return;
141 -
142 - $tags = $this->replaceInformationTags($email);
143 -
144 - $match = '#(?:{|%7B)(modify_profile|readonline(?:\|[^}]+)?)(?:}|%7D)(.*)(?:{|%7B)/(readonline|modify_profile)(?:}|%7D)#Uis';
145 - $results = [];
146 - $found = preg_match_all($match, $email->body, $results);
147 -
148 - if (!$found && empty($tags)) {
149 - return;
150 - };
151 -
152 - foreach ($results[0] as $i => $oneTag) {
153 - if (isset($tags[$oneTag])) continue;
154 -
155 - if (ACYM_CMS == 'joomla' && strpos($oneTag, 'modify_profile') !== false) {
156 - $link = acym_getPageLink('view=frontusers&layout=profile');
157 - $link .= strpos($link, '?') ? '&' : '?';
158 - $link .= 'id={subscriber:id}&key={subscriber:key}';
159 - $link .= $this->getLanguage($email->links_language);
160 - } else {
161 - $link = 'archive&task=view&id='.$email->id.'&userid={subscriber:id}-{subscriber:key}';
162 - if (strpos($results[1][$i], 'theme:1') === false) {
163 - $link .= '&'.acym_noTemplate();
164 - }
165 - if (!empty($email->key)) {
166 - $link .= '&key='.$email->key;
167 - }
168 - $link .= $this->getLanguage($email->links_language);
169 - $link = acym_frontendLink($link);
170 - }
171 -
172 - if (empty($results[2][$i])) {
173 - $tags[$oneTag] = $link;
174 - } else {
175 - $tags[$oneTag] = '<a style="text-decoration:none;" href="'.$link.'" target="_blank"><span class="acym_online acym_link">'.$results[2][$i].'</span></a>';
176 - }
177 - }
178 - $this->pluginHelper->replaceTags($email, $tags);
179 - }
180 -
181 - private function replaceInformationTags(&$email): array
182 - {
183 - $match = '#\{info:([a-z_]+)\}(.*?)\{\/info\}#is';
184 - $extractedTags = [];
185 - $found = preg_match_all($match, $email->body, $extractedTags);
186 - $tags = [];
187 -
188 - if (!$found) {
189 - return $tags;
190 - }
191 -
192 - foreach ($extractedTags[0] as $i => $fullMatch) {
193 - $content = $extractedTags[2][$i];
194 -
195 - if (acym_isValidEmail($content)) {
196 - $fieldValue = '<a style="text-decoration:none;" href="mailto:'.esc_attr($content).'"><span class="acym_online acym_link">'.esc_html($content).'</span></a>';
197 - } elseif (acym_isValidUrl($content)) {
198 - if (acym_isImageUrl($content)) {
199 - $fieldValue = '<img src="'.esc_url(
200 - $content
201 - ).'" alt="Image" style="display: inline-block; max-width: 25px; max-height: 25px; vertical-align: middle;" />';
202 - } else {
203 - $fieldValue = '<a style="text-decoration:none;" href="'.esc_url($content).'" target="_blank"><span class="acym_online acym_link">'.esc_html(
204 - $content
205 - ).'</span></a>';
206 - }
207 - } else {
208 - $fieldValue = $content;
209 - }
210 - $tags[$fullMatch] = $fieldValue;
211 - }
212 -
213 - return $tags;
214 - }
215 -}