PluginProbe
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress / 10.10.2
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress v10.10.2
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 / widgets / subscriptionform / elementor.php

elementor.php in AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress 10.10.2, at widgets/subscriptionform/elementor.php

283 lines 10.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 use AcyMailing\Classes\FieldClass;
4 use AcyMailing\Classes\ListClass;
5 use AcyMailing\Core\AcymParameter;
6
7 class acySubscriptionFormWidget extends \Elementor\Widget_Base
8 {
9 private array $displayMode;
10 private array $lists;
11 private array $listsPlacement;
12 private array $fields = [];
13 private array $displayTextMode;
14 private array $subscriberInfo;
15 private array $posts;
16 private array $replaceMessage;
17 private array $unsubButton;
18 private array $alignment;
19 private array $includeJavascript;
20 private array $borderTypes;
21
22 public function initParams()
23 {
24 $this->displayMode = [
25 'inline' => acym_translation('ACYM_MODE_HORIZONTAL'),
26 'vertical' => acym_translation('ACYM_MODE_VERTICAL'),
27 'tableless' => acym_translation('ACYM_MODE_TABLELESS'),
28 ];
29
30
31 $listClass = new ListClass();
32 $this->lists = $listClass->getAllForSelect(false);
33
34 $this->listsPlacement = [
35 'before' => acym_translation('ACYM_BEFORE_FIELDS'),
36 'after' => acym_translation('ACYM_AFTER_FIELDS'),
37 ];
38
39 $fieldClass = new FieldClass();
40 $allFields = $fieldClass->getAll();
41 foreach ($allFields as $field) {
42 if ($field->id == 2 || intval($field->active) === 0) continue;
43 $this->fields[$field->id] = acym_translation($field->name);
44 }
45
46 $this->displayTextMode = [
47 1 => acym_translation('ACYM_TEXT_INSIDE'),
48 0 => acym_translation('ACYM_TEXT_OUTSIDE'),
49 ];
50
51 $this->subscriberInfo = [
52 1 => acym_translation('ACYM_YES'),
53 0 => acym_translation('ACYM_NO'),
54 ];
55
56 $posts = acym_trigger('getPosts', [false, 0], 'plgAcymPost');
57 foreach ($posts[0] as $post) {
58 $this->posts[$post[0]] = $post[1];
59 }
60
61 $this->replaceMessage = [
62 'replace' => acym_translation('ACYM_SUCCESS_REPLACE'),
63 'replacetemp' => acym_translation('ACYM_SUCCESS_REPLACE_TEMP'),
64 'toptemp' => acym_translation('ACYM_SUCCESS_TOP_TEMP'),
65 'standard' => acym_translation('ACYM_SUCCESS_STANDARD'),
66 ];
67
68 $this->unsubButton = [
69 '0' => acym_translation('ACYM_NO'),
70 '1' => acym_translation('ACYM_CONNECTED_USER_SUBSCRIBED'),
71 '2' => acym_translation('ACYM_ALWAYS'),
72 ];
73
74 $this->alignment = [
75 'none' => acym_translation('ACYM_DEFAULT'),
76 'left' => acym_translation('ACYM_LEFT'),
77 'center' => acym_translation('ACYM_CENTER'),
78 'right' => acym_translation('ACYM_RIGHT'),
79 ];
80
81 $this->includeJavascript = [
82 'header' => acym_translation('ACYM_IN_HEADER'),
83 'module' => acym_translation('ACYM_ON_THE_MODULE'),
84 ];
85
86 $this->borderTypes = [
87 'solid' => acym_translation('ACYM_SOLID'),
88 'dotted' => acym_translation('ACYM_DOTTED'),
89 'dashed' => acym_translation('ACYM_DASHED'),
90 'double' => acym_translation('ACYM_DOUBLE'),
91 'groove' => acym_translation('ACYM_GROOVE'),
92 'ridge' => acym_translation('ACYM_RIDGE'),
93 'inset' => acym_translation('ACYM_INSET'),
94 'outset' => acym_translation('ACYM_OUTSET'),
95 ];
96 }
97
98 public function get_name()
99 {
100 return 'acy_sub_form';
101 }
102
103 public function get_title()
104 {
105 return acym_translation('ACYM_ACYMAILING_SUBSCRIPTION_FORM');
106 }
107
108 public function get_icon()
109 {
110 return 'fa fa-envelope';
111 }
112
113 public function get_categories()
114 {
115 return ['acymailing'];
116 }
117
118 protected function register_controls()
119 {
120 $this->initParams();
121
122 $this->startControlsSection('main_options', acym_translation('ACYM_MAIN_OPTIONS'));
123 $this->getText('title', acym_translation('ACYM_TITLE'), 'Receive our newsletters');
124 $this->getSimpleSelect('mode', acym_translation('ACYM_DISPLAY_MODE'), $this->displayMode, 'inline');
125 $this->getText('subtext', acym_translation('ACYM_SUBSCRIBE_TEXT'), 'Subscribe');
126 $this->getText('subtextlogged', acym_translation('ACYM_SUBSCRIBE_TEXT_LOGGED_IN'), 'Subscribe');
127 $this->end_controls_section();
128
129 $this->startControlsSection('lists_options', acym_translation('ACYM_LISTS_OPTIONS'));
130 $this->getSelect('hiddenlists', acym_translation('ACYM_AUTO_SUBSCRIBE_TO'), $this->lists, '', true);
131 $this->getSelect('displists', acym_translation('ACYM_DISPLAYED_LISTS'), $this->lists, '', true);
132 $this->getSelect('listschecked', acym_translation('ACYM_LISTS_CHECKED_DEFAULT'), $this->lists, '', true);
133 $this->getSelect('listposition', acym_translation('ACYM_DISPLAY_LISTS'), $this->listsPlacement, 'before');
134 $this->end_controls_section();
135
136 $this->startControlsSection('fields_options', acym_translation('ACYM_FIELDS_OPTIONS'));
137 $this->getSelect('fields', acym_translation('ACYM_FIELDS_TO_DISPLAY'), $this->fields, '', true);
138 $this->getSimpleSelect('textmode', acym_translation('ACYM_TEXT_MODE'), $this->displayTextMode, '1');
139 $this->getSimpleSelect('userinfo', acym_translation('ACYM_FORM_AUTOFILL_ID'), $this->subscriberInfo, '1');
140 $this->end_controls_section();
141
142 $this->startControlsSection('terms_condition_options', acym_translation('ACYM_TERMS_POLICY_OPTIONS'));
143 $this->getSimpleSelect('termscontent', acym_translation('ACYM_TERMS_CONDITIONS'), $this->posts, '');
144 $this->getSimpleSelect('privacypolicy', acym_translation('ACYM_PRIVACY_POLICY'), $this->posts, '');
145 $this->end_controls_section();
146
147 $this->startControlsSection('subscribe_options', acym_translation('ACYM_SUBSCRIBE_OPTIONS'));
148 $this->getSimpleSelect('successmode', acym_translation('ACYM_SUCCESS_MODE'), $this->replaceMessage, 'replace');
149 $this->getText('confirmation_message', acym_translation('ACYM_CONFIRMATION_MESSAGE'));
150 $this->getText('redirect', acym_translation('ACYM_REDIRECT_LINK'));
151 $this->end_controls_section();
152
153 $this->startControlsSection('unsubscribe_options', acym_translation('ACYM_UNSUBSCRIBE_OPTIONS'));
154 $this->getSimpleSelect('unsub', acym_translation('ACYM_DISPLAY_UNSUB_BUTTON'), $this->unsubButton, '0');
155 $this->getText('unsubtext', acym_translation('ACYM_UNSUBSCRIBE_TEXT'), 'Unsubscribe');
156 $this->getText('unsubredirect', acym_translation('ACYM_REDIRECT_LINK_UNSUB'));
157 $this->end_controls_section();
158
159 $this->startControlsSection('advanced_options', acym_translation('ACYM_ADVANCED_OPTIONS'));
160 $this->getText('introtext', acym_translation('ACYM_INTRO_TEXT'));
161 $this->getText('posttext', acym_translation('ACYM_POST_TEXT'));
162 $this->getSimpleSelect('alignment', acym_translation('ACYM_ALIGNMENT'), $this->alignment, 'none');
163 $this->getSimpleSelect('includejs', acym_translation('ACYM_MODULE_JS'), $this->includeJavascript, 'header');
164 $this->getText('source', acym_translation('ACYM_SOURCE'), 'elementor_subscription_form');
165 $this->end_controls_section();
166
167 $this->startControlsSection('global_options', acym_translation('ACYM_GLOBAL_OPTIONS'), \Elementor\Controls_Manager::TAB_STYLE);
168 $this->getColor('background_color', acym_translation('ACYM_BACKGROUND_COLOR'));
169 $this->getColor('text_color', acym_translation('ACYM_TEXT_COLOR'));
170 $this->end_controls_section();
171
172 $this->startControlsSection('button_options', acym_translation('ACYM_BUTTON'), \Elementor\Controls_Manager::TAB_STYLE);
173 $this->getColor('button_background_color', acym_translation('ACYM_BACKGROUND_COLOR'));
174 $this->getColor('button_text_color', acym_translation('ACYM_TEXT_COLOR'));
175 $this->getColor('button_border_color', acym_translation('ACYM_BORDER_COLOR'));
176 $this->getSimpleSelect('button_border_type', acym_translation('ACYM_BORDER_TYPE'), $this->borderTypes, 'solid');
177 $this->getNumber('button_border_size', acym_translation('ACYM_BORDER_SIZE'));
178 $this->getNumber('button_border_radius', acym_translation('ACYM_RADIUS'));
179 $this->end_controls_section();
180 }
181
182 private function startControlsSection($option, $label, $type = null)
183 {
184 $this->start_controls_section(
185 $option,
186 [
187 'label' => $label,
188 'tab' => empty($type) ? \Elementor\Controls_Manager::TAB_CONTENT : $type,
189 ]
190 );
191 }
192
193 private function getSelect($option, $label, $values, $default, $multiple = false)
194 {
195 $this->add_control(
196 $option,
197 [
198 'label' => $label,
199 'type' => \Elementor\Controls_Manager::SELECT2,
200 'options' => $values,
201 'default' => $default,
202 'multiple' => $multiple,
203 'label_block' => true,
204 ]
205 );
206 }
207
208 private function getSimpleSelect($option, $label, $values, $default)
209 {
210 $this->add_control(
211 $option,
212 [
213 'label' => $label,
214 'type' => \Elementor\Controls_Manager::SELECT,
215 'options' => $values,
216 'default' => $default,
217 'label_block' => true,
218 ]
219 );
220 }
221
222 private function getText($option, $label, $default = '')
223 {
224 $data = [
225 'label' => $label,
226 'type' => \Elementor\Controls_Manager::TEXT,
227 'input_type' => 'text',
228 'label_block' => true,
229 ];
230
231 if (!empty($default)) $data['default'] = $default;
232
233 $this->add_control(
234 $option,
235 $data
236 );
237 }
238
239 private function getColor($option, $label, $default = '')
240 {
241 $data = [
242 'label' => $label,
243 'type' => \Elementor\Controls_Manager::COLOR,
244 'global' => [
245 'active' => false,
246 ],
247 ];
248
249 if (!empty($default)) $data['default'] = $default;
250
251 $this->add_control(
252 $option,
253 $data
254 );
255 }
256
257 private function getNumber($option, $label, $default = '')
258 {
259 $data = [
260 'label' => $label,
261 'type' => \Elementor\Controls_Manager::NUMBER,
262 'label_block' => false,
263 'min' => 0,
264 ];
265
266 if (!empty($default)) $data['default'] = $default;
267
268 $this->add_control(
269 $option,
270 $data
271 );
272 }
273
274 protected function render()
275 {
276 $settings = $this->get_settings_for_display();
277 $params = new AcymParameter($settings);
278 $render = acym_renderForm($params);
279
280 echo $render;
281 }
282 }
283