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/Core/wordpress/form.php +0 -418 10.0.1 → 11.1.1 View file →
@@ -1,418 +1,0 @@
1 -<?php
2 -
3 -use AcyMailing\Classes\FieldClass;
4 -use AcyMailing\Classes\ListClass;
5 -use AcyMailing\Classes\UserClass;
6 -use AcyMailing\Core\AcymParameter;
7 -use AcyMailing\FrontControllers\FrontusersController;
8 -use AcyMailing\FrontControllers\ArchiveController;
9 -
10 -function acym_formToken()
11 -{
12 - return '<input type="hidden" name="_wpnonce" value="'.wp_create_nonce('acymnonce').'">';
13 -}
14 -
15 -function acym_checkToken()
16 -{
17 - $token = acym_getVar('cmd', '_wpnonce');
18 - if (!wp_verify_nonce($token, 'acymnonce')) {
19 - die('Invalid Token');
20 - }
21 -}
22 -
23 -function acym_getFormToken()
24 -{
25 - $token = acym_getVar('cmd', '_wpnonce', '');
26 - if (empty($token)) {
27 - $token = wp_create_nonce('acymnonce');
28 - acym_setVar('_wpnonce', $token);
29 - }
30 -
31 - return '_wpnonce='.$token;
32 -}
33 -
34 -function acym_noTemplate(): string
35 -{
36 - return 'noheader=1';
37 -}
38 -
39 -function acym_isNoTemplate(): bool
40 -{
41 - return acym_getVar('cmd', 'noheader') == '1';
42 -}
43 -
44 -function acym_setNoTemplate(bool $status = true)
45 -{
46 - if ($status) {
47 - acym_setVar('noheader', '1');
48 - } else {
49 - unset($_REQUEST['noheader']);
50 - }
51 -}
52 -
53 -
54 -function acym_formOptions(bool $token = true, string $task = '', string $currentStep = '', string $currentCtrl = '', bool $addPage = true)
55 -{
56 - if (!empty($currentStep)) {
57 - echo '<input type="hidden" name="step" value="'.acym_escape($currentStep).'"/>';
58 - }
59 - echo '<input type="hidden" name="nextstep" value=""/>';
60 - echo '<input type="hidden" name="task" value="'.acym_escape($task).'"/>';
61 - if ($addPage) {
62 - echo '<input type="hidden" name="page" value="'.acym_escape(acym_getVar('cmd', 'page', '')).'"/>';
63 - }
64 - echo '<input type="hidden" name="ctrl" value="'.acym_escape(empty($currentCtrl) ? acym_getVar('cmd', 'ctrl', '') : $currentCtrl).'"/>';
65 - if ($token) {
66 - echo acym_formToken();
67 - }
68 - echo '<button type="submit" class="is-hidden" id="formSubmit"></button>';
69 -}
70 -
71 -global $acymMetaData;
72 -function acym_addMetadata($meta, $data, $name = 'name')
73 -{
74 - global $acymMetaData;
75 -
76 - $tag = new stdClass();
77 - $tag->meta = $meta;
78 - $tag->data = $data;
79 - $tag->name = $name;
80 -
81 - $acymMetaData[] = $tag;
82 -}
83 -
84 -add_action('wp_head', 'acym_head_wp');
85 -add_action('admin_head', 'acym_head_wp');
86 -add_action('acym_head', 'acym_head_wp');
87 -function acym_head_wp()
88 -{
89 - global $acymMetaData;
90 -
91 - if (!empty($acymMetaData)) {
92 - foreach ($acymMetaData as $metadata) {
93 - if (empty($metadata->data)) {
94 - echo '<meta '.$metadata->name.'="'.acym_escape($metadata->meta).'"/>';
95 - } else {
96 - echo '<meta '.$metadata->name.'="'.acym_escape($metadata->meta).'" content="'.acym_escape($metadata->data).'"/>';
97 - }
98 - }
99 - }
100 -
101 - $acymMetaData = [];
102 -}
103 -
104 -function acym_includeHeaders()
105 -{
106 - do_action('acym_head');
107 -}
108 -
109 -function acym_getOptionRegacyPosition()
110 -{
111 -}
112 -
113 -function acym_renderForm(AcymParameter $params, $args = [])
114 -{
115 - acym_initModule($params);
116 -
117 - $return = !empty($args['before_widget']) ? $args['before_widget'] : '';
118 -
119 - $title = apply_filters('widget_title', $params->get('title'));
120 - if (!empty($title)) {
121 - if (!empty($args['before_title'])) $return .= $args['before_title'];
122 - $return .= $title;
123 - if (!empty($args['after_title'])) $return .= $args['after_title'];
124 - }
125 -
126 - $identifiedUser = null;
127 - $currentUserEmail = acym_currentUserEmail();
128 - $userClass = new UserClass();
129 - if ($params->get('userinfo', '1') == '1' && !empty($currentUserEmail)) {
130 - $identifiedUser = $userClass->getOneByEmail($currentUserEmail);
131 - }
132 -
133 - $visibleLists = $params->get('displists', []);
134 - $hiddenLists = $params->get('hiddenlists', []);
135 - $allFields = $params->get('fields', []);
136 - acym_arrayToInteger($visibleLists);
137 - acym_arrayToInteger($hiddenLists);
138 - acym_arrayToInteger($allFields);
139 -
140 - if (!in_array(2, $allFields)) {
141 - $allFields[] = 2;
142 - }
143 -
144 - $listClass = new ListClass();
145 - $fieldClass = new FieldClass();
146 -
147 - $allLists = $listClass->getAllWithoutManagement(true);
148 - $visibleLists = array_intersect($visibleLists, array_keys($allLists));
149 - $hiddenLists = array_intersect($hiddenLists, array_keys($allLists));
150 -
151 - $allFields = $fieldClass->getFieldsByID($allFields);
152 - $fields = [];
153 - foreach ($allFields as $field) {
154 - if (intval($field->active) === 0) continue;
155 - $fields[$field->id] = $field;
156 - }
157 -
158 - if (empty($visibleLists) && empty($hiddenLists)) {
159 - $hiddenLists = array_keys($allLists);
160 - }
161 -
162 - if (!empty($visibleLists) && !empty($hiddenLists)) {
163 - $visibleLists = array_diff($visibleLists, $hiddenLists);
164 - }
165 -
166 - if (empty($identifiedUser->id)) {
167 - $checkedLists = $params->get('listschecked', []);
168 - if (!is_array($checkedLists)) {
169 - if (strtolower($checkedLists) == 'all') {
170 - $checkedLists = $visibleLists;
171 - } elseif (strpos($checkedLists, ',') || is_numeric($checkedLists)) {
172 - $checkedLists = explode(',', $checkedLists);
173 - } else {
174 - $checkedLists = [];
175 - }
176 - }
177 - } else {
178 - $checkedLists = [];
179 - $userLists = $userClass->getUserSubscriptionById($identifiedUser->id);
180 -
181 - $countSub = 0;
182 - $countUnsub = 0;
183 - $formLists = array_merge($visibleLists, $hiddenLists);
184 - foreach ($formLists as $idOneList) {
185 - if (empty($userLists[$idOneList]) || $userLists[$idOneList]->status == 0) {
186 - $countSub++;
187 - } else {
188 - $countUnsub++;
189 - $checkedLists[] = $idOneList;
190 - }
191 - }
192 - }
193 - acym_arrayToInteger($checkedLists);
194 -
195 -
196 - $config = acym_config();
197 -
198 - $subscribeText = $params->get('subtext', 'ACYM_SUBSCRIBE');
199 - if (!empty($identifiedUser->id)) $subscribeText = $params->get('subtextlogged', 'ACYM_SUBSCRIBE');
200 - $unsubscribeText = $params->get('unsubtext', 'ACYM_UNSUBSCRIBE');
201 - $unsubButton = $params->get('unsub', '0');
202 -
203 - $disableButtons = !empty($args['disableButtons']) || acym_isAdmin();
204 -
205 - $listPosition = $params->get('listposition', 'before');
206 - $displayOutside = $params->get('textmode') == '0';
207 -
208 - $successMode = $params->get('successmode', 'replace');
209 -
210 - $redirectURL = $params->get('redirect', '');
211 - $unsubRedirectURL = $params->get('unsubredirect', '');
212 - $ajax = empty($redirectURL) && empty($unsubRedirectURL) && $successMode != 'standard' ? '1' : '0';
213 -
214 - $formClass = $params->get('formclass', '');
215 - $alignment = $params->get('alignment', 'none');
216 - $style = $alignment == 'none' ? '' : 'style="text-align: '.$alignment.'"';
217 -
218 - $displayInAPopup = 0;
219 - $termsURL = acym_getArticleURL($params->get('termscontent', 0), $displayInAPopup, 'ACYM_TERMS_CONDITIONS');
220 - $privacyURL = acym_getArticleURL($params->get('privacypolicy', 0), $displayInAPopup, 'ACYM_PRIVACY_POLICY');
221 -
222 - if (empty($termsURL) && empty($privacyURL)) {
223 - $termslink = '';
224 - } elseif (empty($privacyURL)) {
225 - $termslink = acym_translationSprintf('ACYM_I_AGREE_TERMS', $termsURL);
226 - } elseif (empty($termsURL)) {
227 - $termslink = acym_translationSprintf('ACYM_I_AGREE_PRIVACY', $privacyURL);
228 - } else {
229 - $termslink = acym_translationSprintf('ACYM_I_AGREE_BOTH', $termsURL, $privacyURL);
230 - }
231 -
232 - $formName = acym_getModuleFormName();
233 - $formAction = htmlspecialchars_decode(acym_frontendLink('frontusers'));
234 -
235 - $js = "window.addEventListener('DOMContentLoaded', (event) => {";
236 - $js .= "\n"."acymModule['excludeValues".$formName."'] = [];";
237 - $fieldsToDisplay = [];
238 - foreach ($fields as $field) {
239 - $fieldsToDisplay[$field->id] = $field->name;
240 - $js .= "\n".'acymModule["excludeValues'.$formName.'"]["'.$field->id.'"] = "'.acym_translation($field->name, true).'";';
241 - }
242 - $js .= " });";
243 - $return .= '<script type="text/javascript">
244 - '.$js.'
245 - </script>';
246 -
247 - $buttonStyle = '';
248 - if (!empty($params->get('button_background_color', ''))) $buttonStyle .= 'background-color: '.$params->get('button_background_color', '').';';
249 - if (!empty($params->get('button_text_color', ''))) $buttonStyle .= 'color: '.$params->get('button_text_color', '').';';
250 - if (strlen($params->get('button_border_size', '')) > 0) $buttonStyle .= 'border-width: '.$params->get('button_border_size', '').'px;';
251 - if (!empty($params->get('button_border_type', ''))) $buttonStyle .= 'border-style: '.$params->get('button_border_type', '').';';
252 - if (!empty($params->get('button_border_color', ''))) $buttonStyle .= 'border-color: '.$params->get('button_border_color', '').';';
253 - if (strlen($params->get('button_border_radius', '')) > 0) $buttonStyle .= 'border-radius: '.$params->get('button_border_radius', '').'px;';
254 -
255 - if (!empty($buttonStyle)) {
256 - acym_addStyle(true, '#acym_module_'.$formName.' .acysubbuttons .subbutton {'.$buttonStyle.'}');
257 - }
258 -
259 - $globalStyle = '';
260 - if (!empty($params->get('background_color', ''))) $globalStyle .= 'background-color: '.$params->get('background_color', '').';';
261 - if (!empty($params->get('text_color', ''))) $globalStyle .= 'color: '.$params->get('text_color', '').';';
262 -
263 - if (!empty($globalStyle)) {
264 - acym_addStyle(true, '#acym_module_'.$formName.', #acym_module_'.$formName.' td {'.$globalStyle.'}');
265 - }
266 -
267 - ob_start();
268 - ?>
269 - <div class="acym_module <?php echo acym_escape($formClass); ?>" id="acym_module_<?php echo $formName; ?>">
270 - <div class="acym_fulldiv" id="acym_fulldiv_<?php echo $formName; ?>" <?php echo $style; ?>>
271 - <form enctype="multipart/form-data"
272 - id="<?php echo acym_escape($formName); ?>"
273 - name="<?php echo acym_escape($formName); ?>"
274 - method="POST"
275 - action="<?php echo acym_escape($formAction); ?>"
276 - onsubmit="return submitAcymForm('subscribe','<?php echo $formName; ?>', 'acymSubmitSubForm')">
277 - <div class="acym_module_form">
278 - <?php
279 - $introText = $params->get('introtext', '');
280 - if (!empty($introText)) {
281 - echo '<div class="acym_introtext">'.$introText.'</div>';
282 - }
283 - if ($params->get('mode', 'tableless') == 'tableless') {
284 - include ACYM_FOLDER.'widgets'.DS.'subscriptionform'.DS.'tmpl'.DS.'tableless.php';
285 - } else {
286 - $displayInline = $params->get('mode', 'tableless') != 'vertical';
287 - include ACYM_FOLDER.'widgets'.DS.'subscriptionform'.DS.'tmpl'.DS.'default.php';
288 - }
289 - ?>
290 - </div>
291 -
292 - <input type="hidden" name="ctrl" value="frontusers" />
293 - <input type="hidden" name="task" value="notask" />
294 - <input type="hidden" name="option" value="<?php echo acym_escape(ACYM_COMPONENT); ?>" />
295 -
296 - <?php
297 - if (!empty($redirectURL)) echo '<input type="hidden" name="redirect" value="'.acym_escape($redirectURL).'"/>';
298 - if (!empty($unsubRedirectURL)) echo '<input type="hidden" name="redirectunsub" value="'.acym_escape($unsubRedirectURL).'"/>';
299 - ?>
300 - <input type="hidden" name="ajax" value="<?php echo acym_escape($ajax); ?>" />
301 - <input type="hidden" name="successmode" value="<?php echo acym_escape($successMode); ?>" />
302 - <input type="hidden" name="acy_source" value="<?php echo acym_escape($params->get('source', '')); ?>" />
303 - <input type="hidden" name="hiddenlists" value="<?php echo implode(',', $hiddenLists); ?>" />
304 - <input type="hidden" name="acyformname" value="<?php echo acym_escape($formName); ?>" />
305 - <input type="hidden" name="acysubmode" value="widget_acym" />
306 - <input type="hidden" name="confirmation_message" value="<?php echo acym_escape($params->get('confirmation_message', '')); ?>" />
307 -
308 - <?php
309 - $postText = $params->get('posttext', '');
310 - if (!empty($postText)) {
311 - echo '<div class="acym_posttext">'.$postText.'</div>';
312 - }
313 - ?>
314 - </form>
315 - </div>
316 - </div>
317 - <?php
318 - $return .= ob_get_clean();
319 -
320 - if (!empty($args['after_widget'])) $return .= $args['after_widget'];
321 -
322 - return $return;
323 -}
324 -
325 -function acym_renderFormProfile(AcymParameter $params, $args = [])
326 -{
327 - acym_initModule($params);
328 -
329 - if (!is_array($params->get('listsdropdown', '0'))) {
330 - $listDropdown = $params->get('listsdropdown', '0');
331 - } else {
332 - $listDropdown = $params->get('listsdropdown')[0];
333 - }
334 -
335 - $instance = [
336 - 'title' => $params->get('title', ''),
337 - 'lists' => $params->get('lists'),
338 - 'listschecked' => $params->get('listschecked'),
339 - 'dropdown' => $listDropdown,
340 - 'hiddenlists' => $params->get('hiddenlists'),
341 - 'fields' => $params->get('fields'),
342 - 'introtext' => $params->get('introtext', ''),
343 - 'posttext' => $params->get('posttext', ''),
344 - 'source' => $params->get('source', ''),
345 - ];
346 -
347 - $title = apply_filters('widget_title', $instance['title']);
348 - if (!empty($title)) $title = '<span class="gamma widget-title">'.$title.'</span>';
349 - $return = $title;
350 -
351 - ob_start();
352 - acym_setVar('page', ACYM_COMPONENT.'_front');
353 -
354 - $userController = new FrontusersController();
355 - $data = $userController->prepareParams((object)$instance);
356 - $data['disableButtons'] = !empty($args['disableButtons']) || acym_isAdmin();
357 -
358 - if (empty($data['user']->language)) {
359 - $cmsUserLanguage = acym_getCmsUserLanguage();
360 - $data['user']->language = empty($cmsUserLanguage) ? acym_getLanguageTag() : $cmsUserLanguage;
361 - }
362 -
363 - acym_setVar('layout', 'profile');
364 - $userController->display($data);
365 - $return .= ob_get_clean();
366 -
367 - return $return;
368 -}
369 -
370 -function acym_renderFormArchive(AcymParameter $params, $args = [])
371 -{
372 - acym_initModule($params);
373 -
374 - if (!is_array($params->get('popup', '1'))) {
375 - $popup = $params->get('popup', '1');
376 - } else {
377 - $popup = $params->get('popup')[0];
378 - }
379 - if (!is_array($params->get('displayUserListOnly', '1'))) {
380 - $displayUserListOnly = $params->get('displayUserListOnly', '1');
381 - } else {
382 - $displayUserListOnly = $params->get('displayUserListOnly')[0];
383 - }
384 -
385 - $instance = [
386 - 'title' => $params->get('title', ''),
387 - 'archiveNbNewslettersPerPage' => $params->get('archiveNbNewslettersPerPage', 20),
388 - 'lists' => $params->get('lists'),
389 - 'popup' => $popup,
390 - 'displayUserListOnly' => $displayUserListOnly,
391 - ];
392 -
393 - $title = apply_filters('widget_title', $instance['title']);
394 - if (!empty($title)) $title = '<span class="gamma widget-title">'.$title.'</span>';
395 - $return = $title;
396 - ob_start();
397 - acym_setVar('page', 'front');
398 - $searchs = acym_getVar('array', 'acym_search', []);
399 - $search = '';
400 - if (!empty($searchs[0])) $search = $searchs[0];
401 - $disableButtons = !empty($args['disableButtons']) || acym_isAdmin();
402 - $viewParams = [
403 - 'listsSent' => isset($instance['lists']) ? $instance['lists'] : [],
404 - 'popup' => isset($instance['popup']) ? $instance['popup'] : '1',
405 - 'displayUserListOnly' => isset($instance['displayUserListOnly']) ? $instance['displayUserListOnly'] : '1',
406 - 'paramsCMS' => ['widget_id' => 0, 'suffix' => ''],
407 - 'search' => $search,
408 - 'disableButtons' => $disableButtons,
409 - 'nbNewslettersPerPage' => $instance['archiveNbNewslettersPerPage'],
410 - ];
411 -
412 - $archiveController = new ArchiveController();
413 - $archiveController->showArchive($viewParams);
414 -
415 - $return .= ob_get_clean();
416 -
417 - return $return;
418 -}