PluginProbe
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress / 11.0.3
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress v11.0.3
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
acymailing / back / Controllers / DynamicsController.php

DynamicsController.php in AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress 11.0.3, at back/Controllers/DynamicsController.php

97 lines 3.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace AcyMailing\Controllers;
4
5 use AcyMailing\Classes\UserClass;
6 use AcyMailing\Helpers\PluginHelper;
7 use AcyMailing\Core\AcymController;
8
9 class DynamicsController extends AcymController
10 {
11 public function replaceDummy(): void
12 {
13 wp_verify_nonce(acym_getVar('cmd', '_wpnonce'), 'acymnonce') || die('Invalid Token');
14
15 $mailId = acym_getVar('int', 'mailId', 0);
16 $code = acym_getVar('string', 'code', '', '', ACYM_ALLOWRAW);
17 $previewBody = base64_decode(acym_getVar('string', 'previewBody', '', '', ACYM_ALLOWRAW));
18
19 $pluginHelper = new PluginHelper();
20 $email = $pluginHelper->createDummyEmailObject($mailId, $code, $previewBody);
21
22 @acym_trigger('replaceContent', [&$email, false]);
23
24 $userClass = new UserClass();
25 $userEmail = acym_currentUserEmail();
26 $user = $userClass->getOneByEmail($userEmail);
27
28 if (empty($user)) {
29 $user = new \stdClass();
30 $user->email = $userEmail;
31 $user->name = acym_currentUserName();
32 $user->cms_id = acym_currentUserId();
33 $user->confirmed = 0;
34 $user->source = acym_isAdmin() ? 'Back-end' : 'Front-end';
35
36 $userClass->checkVisitor = false;
37 $user->id = $userClass->save($user);
38 }
39
40 @acym_trigger('replaceUserInformation', [&$email, &$user, false]);
41
42 acym_sendAjaxResponse(
43 '',
44 [
45 'content' => $email->body,
46 'custom_view' => !empty($email->custom_view),
47 ]
48 );
49 }
50
51 public function trigger(): void
52 {
53 wp_verify_nonce(acym_getVar('cmd', '_wpnonce'), 'acymnonce') || die('Invalid Token');
54
55 $plugin = acym_getVar('cmd', 'plugin', '');
56 $trigger = acym_getVar('cmd', 'trigger', '');
57 if (empty($plugin) || empty($trigger)) exit;
58
59 $triggerParams = $this->getTriggerParams($plugin, $trigger);
60 acym_trigger($trigger, $triggerParams, $plugin);
61 exit;
62 }
63
64 private function getTriggerParams(string $plugin, string $trigger): array
65 {
66 $shortcode = acym_getVar('string', 'shortcode', '');
67 $shortcode = trim($shortcode, '{}');
68
69 $separatorPosition = strpos($shortcode, ':');
70 if (false !== $separatorPosition) {
71 $pluginSubType = substr($shortcode, 0, $separatorPosition);
72 $shortcode = substr($shortcode, $separatorPosition + 1);
73 $pluginHelper = new PluginHelper();
74 $defaultValues = $pluginHelper->extractTag($shortcode);
75 $defaultValues->defaultPluginTab = $pluginSubType;
76
77 return [$defaultValues];
78 }
79
80 if ($trigger === 'insertionOptions') {
81 $rawDefaultValues = $this->config->get('dcontent_default_'.$plugin);
82
83 if (!empty($rawDefaultValues)) {
84 $defaultValues = is_string($rawDefaultValues) ? json_decode($rawDefaultValues, true) : $rawDefaultValues;
85 unset($defaultValues['id']);
86 unset($defaultValues['from']);
87 unset($defaultValues['to']);
88 $defaultValues = (object)$defaultValues;
89
90 return [$defaultValues];
91 }
92 }
93
94 return [];
95 }
96 }
97