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

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