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 | widgets/subscriptionform/widget.php +0 -399 10.2.2 → 11.1.1 View file →
@@ -1,399 +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 -
8 -class acym_subscriptionform_widget extends WP_Widget
9 -{
10 - public function __construct()
11 - {
12 - $this->loadAcyMailing();
13 -
14 - parent::__construct(
15 - 'acym_subscriptionform_widget',
16 - acym_translationSprintf('ACYM_MENU', acym_translation('ACYM_MENU_FORM')),
17 - ['description' => acym_translation('ACYM_MENU_FORM_DESC')]
18 - );
19 - }
20 -
21 - public function form($instance)
22 - {
23 - $this->loadAcyMailing();
24 -
25 - wp_enqueue_style('select2lib', ACYM_CSS.'libraries/select2-original.min.css?v='.filemtime(ACYM_MEDIA.'css'.DS.'libraries'.DS.'select2-original.min.css'));
26 - wp_enqueue_script('select2lib', ACYM_JS.'libraries/select2-full.min.js?v='.filemtime(ACYM_MEDIA.'js'.DS.'libraries'.DS.'select2-full.min.js'), ['jquery']);
27 - wp_enqueue_script('acym_widget_article', ACYM_JS.'widget.min.js', ['select2lib']);
28 - acym_addStyle(false, ACYM_CSS.'widget.min.css?v='.filemtime(ACYM_MEDIA.'css'.DS.'widget.min.css'));
29 -
30 - $listClass = new ListClass();
31 - $fieldClass = new FieldClass();
32 - $allFields = $fieldClass->getAll();
33 - $fields = [];
34 - foreach ($allFields as $field) {
35 - if ($field->id == 2 || intval($field->active) === 0) continue;
36 - $fields[$field->id] = acym_translation($field->name);
37 - }
38 -
39 - $lists = $listClass->getAllWithoutManagement();
40 - foreach ($lists as $i => $oneList) {
41 - if ($oneList->active == 0) {
42 - unset($lists[$i]);
43 - }
44 - }
45 -
46 - $listIds = array_keys($lists);
47 - $params = [
48 - 'title' => 'Receive our newsletters',
49 - 'mode' => 'tableless',
50 - 'hiddenlists' => array_shift($listIds),
51 - 'displists' => '',
52 - 'listschecked' => '',
53 - 'listposition' => 'before',
54 - 'fields' => '1',
55 - 'textmode' => '1',
56 - 'subtext' => '',
57 - 'subtextlogged' => '',
58 - 'termscontent' => '0',
59 - 'privacypolicy' => '0',
60 - 'articlepopup' => '1',
61 - 'unsub' => '0',
62 - 'unsubtext' => '',
63 - 'unsubredirect' => '',
64 - 'successmode' => 'replace',
65 - 'confirmation_message' => '',
66 - 'redirect' => '',
67 - 'introtext' => '',
68 - 'posttext' => '',
69 - 'userinfo' => '1',
70 - 'formclass' => '',
71 - 'alignment' => 'none',
72 - 'source' => 'widget __i__',
73 - 'includejs' => 'header',
74 - ];
75 - foreach ($params as $oneParam => &$value) {
76 - if (!empty($instance)) {
77 - if (isset($instance[$oneParam])) {
78 - $value = $instance[$oneParam];
79 - } else {
80 - $value = '';
81 - }
82 - }
83 -
84 - if (is_array($value)) {
85 - $value = implode(',', $value);
86 - }
87 -
88 - $value = esc_attr($value);
89 - }
90 -
91 - if (!isset($instance['hiddenlists']) && !empty($params['displists'])) {
92 - $params['hiddenlists'] = '';
93 - }
94 -
95 - echo '<div class="acym_toggle_zone">
96 - <div class="acyblock" id="mainopt_acywidget">
97 - <div class="acym_toggle_div_title">
98 - <h3>'.acym_translation('ACYM_MAIN_OPTIONS').'</h3>
99 - </div>
100 - <div class="acym_toggle_div" style="display: none;">';
101 -
102 - echo '<p><label class="acyWPconfig" for="'.$this->get_field_id('title').'">'.acym_translation('ACYM_TITLE').'</label>
103 - <input type="text" class="widefat" id="'.$this->get_field_id('title').'" name="'.$this->get_field_name('title').'" value="'.$params['title'].'" /></p>';
104 -
105 - $options = [];
106 - $options[] = acym_selectOption('inline', 'ACYM_MODE_HORIZONTAL');
107 - $options[] = acym_selectOption('vertical', 'ACYM_MODE_VERTICAL');
108 - $options[] = acym_selectOption('tableless', 'ACYM_MODE_TABLELESS');
109 - echo '<p><label class="acyWPconfig" title="'.acym_translation('ACYM_DISPLAY_MODE_DESC').'">'.acym_translation('ACYM_DISPLAY_MODE').'</label>';
110 - echo acym_Select(
111 - $options,
112 - $this->get_field_name('mode'),
113 - $params['mode'],
114 - [
115 - 'class' => 'acym_simple_select2',
116 - ],
117 - 'value',
118 - 'text',
119 - $this->get_field_id('mode')
120 - ).'</p>';
121 -
122 - echo '<p><label class="acyWPconfig" title="'.acym_translation('ACYM_AUTO_SUBSCRIBE_TO_DESC').'">'.acym_translation('ACYM_AUTO_SUBSCRIBE_TO').'</label>';
123 - echo acym_selectMultiple(
124 - $lists,
125 - $this->get_field_name('hiddenlists'),
126 - explode(',', $params['hiddenlists']),
127 - [
128 - 'class' => 'acym_simple_select2',
129 - 'id' => $this->get_field_id('hiddenlists'),
130 - ],
131 - 'id',
132 - 'name'
133 - ).'</p>';
134 -
135 - echo '<p><label class="acyWPconfig" title="'.acym_translation('ACYM_DISPLAYED_LISTS_DESC').'">'.acym_translation('ACYM_DISPLAYED_LISTS').'</label>';
136 - echo acym_selectMultiple(
137 - $lists,
138 - $this->get_field_name('displists'),
139 - explode(',', $params['displists']),
140 - [
141 - 'class' => 'acym_simple_select2',
142 - 'id' => $this->get_field_id('displists'),
143 - ],
144 - 'id',
145 - 'name'
146 - ).'</p>';
147 -
148 - echo '<p><label class="acyWPconfig" title="'.acym_translation('ACYM_LISTS_CHECKED_DEFAULT_DESC').'">'.acym_translation('ACYM_LISTS_CHECKED_DEFAULT').'</label>';
149 - echo acym_selectMultiple(
150 - $lists,
151 - $this->get_field_name('listschecked'),
152 - explode(',', $params['listschecked']),
153 - [
154 - 'class' => 'acym_simple_select2',
155 - 'id' => $this->get_field_id('listschecked'),
156 - ],
157 - 'id',
158 - 'name'
159 - ).'</p>';
160 -
161 - $options = [];
162 - $options[] = acym_selectOption('before', 'ACYM_BEFORE_FIELDS');
163 - $options[] = acym_selectOption('after', 'ACYM_AFTER_FIELDS');
164 - echo '<p><label class="acyWPconfig">'.acym_translation('ACYM_LIST_POSITION').'</label>';
165 - echo acym_select(
166 - $options,
167 - $this->get_field_name('listposition'),
168 - $params['listposition'],
169 - [
170 - 'class' => 'acym_simple_select2',
171 - ],
172 - 'value',
173 - 'text',
174 - $this->get_field_id('listposition')
175 - ).'</p>';
176 -
177 - echo '<p><label class="acyWPconfig" title="'.acym_translation('ACYM_FIELDS_TO_DISPLAY_DESC').'">'.acym_translation('ACYM_FIELDS_TO_DISPLAY').'</label>';
178 - echo acym_selectMultiple(
179 - $fields,
180 - $this->get_field_name('fields'),
181 - explode(',', $params['fields']),
182 - [
183 - 'class' => 'acym_simple_select2',
184 - 'id' => $this->get_field_id('fields'),
185 - ]
186 - ).'</p>';
187 -
188 - $options = [];
189 - $options[] = acym_selectOption('1', 'ACYM_TEXT_INSIDE');
190 - $options[] = acym_selectOption('0', 'ACYM_TEXT_OUTSIDE');
191 - echo '<p><label class="acyWPconfig" title="'.acym_translation('ACYM_TEXT_MODE_DESC').'">'.acym_translation('ACYM_TEXT_MODE').'</label>';
192 - echo acym_select(
193 - $options,
194 - $this->get_field_name('textmode'),
195 - $params['textmode'],
196 - [
197 - 'class' => 'acym_simple_select2',
198 - ],
199 - 'value',
200 - 'text',
201 - $this->get_field_id('textmode')
202 - ).'</p>';
203 -
204 - echo '<p><label class="acyWPconfig" for="'.$this->get_field_id('subtext').'" title="'.acym_translation('ACYM_SUBSCRIBE_TEXT_DESC').'">'.acym_translation(
205 - 'ACYM_SUBSCRIBE_TEXT'
206 - ).'</label>
207 - <input type="text" class="widefat" id="'.$this->get_field_id('subtext').'" name="'.$this->get_field_name('subtext').'" value="'.$params['subtext'].'" /></p>';
208 -
209 - echo '<p><label class="acyWPconfig" for="'.$this->get_field_id('subtextlogged').'" title="'.acym_translation('ACYM_SUBSCRIBE_TEXT_LOGGED_IN_DESC').'">'.acym_translation(
210 - 'ACYM_SUBSCRIBE_TEXT_LOGGED_IN'
211 - ).'</label>
212 - <input type="text" class="widefat" id="'.$this->get_field_id('subtextlogged').'" name="'.$this->get_field_name(
213 - 'subtextlogged'
214 - ).'" value="'.$params['subtextlogged'].'" /></p>';
215 -
216 - $options = [];
217 - if (!empty($params['termscontent'])) {
218 - $options[] = acym_selectOption($params['termscontent'], get_the_title($params['termscontent']));
219 - }
220 - echo '<p><label class="acyWPconfig">'.acym_translation('ACYM_TERMS_CONDITIONS').'</label>';
221 - echo acym_select(
222 - $options,
223 - $this->get_field_name('termscontent'),
224 - $params['termscontent'],
225 - [
226 - 'class' => 'acym_post_select2',
227 - 'title' => acym_translation('ACYM_PRIVACY_POLICY'),
228 - ],
229 - 'value',
230 - 'text',
231 - $this->get_field_id('termscontent')
232 - ).'</p>';
233 -
234 - $options = [];
235 - if (!empty($params['privacypolicy'])) {
236 - $options[] = acym_selectOption($params['privacypolicy'], get_the_title($params['privacypolicy']));
237 - }
238 - echo '<p><label class="acyWPconfig">'.acym_translation('ACYM_PRIVACY_POLICY').'</label>';
239 - echo acym_select(
240 - $options,
241 - $this->get_field_name('privacypolicy'),
242 - $params['privacypolicy'],
243 - [
244 - 'class' => 'acym_post_select2',
245 - 'title' => acym_translation('ACYM_PRIVACY_POLICY'),
246 - ],
247 - 'value',
248 - 'text',
249 - $this->get_field_id('privacypolicy')
250 - ).'</p>';
251 -
252 -
253 - echo '</div>
254 - </div>
255 - <div class="acyblock" id="advopt_acywidget">
256 - <div class="acym_toggle_div_title">
257 - <h3>'.acym_translation('ACYM_ADVANCED_OPTIONS').'</h3>
258 - </div>
259 - <div class="acym_toggle_div" style="display: none;">';
260 -
261 - echo '<p><label class="acyWPconfig">'.acym_translation('ACYM_DISPLAY_UNSUB_BUTTON').'</label>';
262 - $onchange = "var disp = 'none';";
263 - $onchange .= "if(this.value != 0){disp = 'block';}";
264 - $onchange .= "var elements = document.getElementsByClassName('".$this->get_field_id('unsubtextrow')."');";
265 - $onchange .= "for(var i = 0 ; i < elements.length ; i++){elements[i].style.display = disp;}";
266 - echo acym_select(
267 - [
268 - '0' => 'ACYM_NO',
269 - '1' => 'ACYM_CONNECTED_USER_SUBSCRIBED',
270 - '2' => 'ACYM_ALWAYS',
271 - ],
272 - $this->get_field_name('unsub'),
273 - $params['unsub'],
274 - [
275 - 'onchange' => $onchange,
276 - 'class' => 'acym_simple_select2',
277 - ],
278 - 'value',
279 - 'text',
280 - $this->get_field_id('unsub'),
281 - true
282 - ).'</p>';
283 -
284 - echo '<p class="'.$this->get_field_id('unsubtextrow').'" '.($params['unsub'] == '0' ? 'style="display:none;"' : '').'>
285 - <label class="acyWPconfig" for="'.$this->get_field_id('unsubtext').'" title="'.acym_translation('ACYM_UNSUBSCRIBE_TEXT_DESC').'">'.acym_translation(
286 - 'ACYM_UNSUBSCRIBE_TEXT'
287 - ).'</label>
288 - <input type="text" class="widefat" id="'.$this->get_field_id('unsubtext').'" name="'.$this->get_field_name('unsubtext').'" value="'.$params['unsubtext'].'" /></p>';
289 -
290 - echo '<p class="'.$this->get_field_id('unsubtextrow').'" '.($params['unsub'] == '0' ? 'style="display:none;"' : '').'>
291 - <label class="acyWPconfig" for="'.$this->get_field_id('unsubredirect').'" title="'.acym_translation('ACYM_REDIRECT_LINK_UNSUB_DESC').'">'.acym_translation(
292 - 'ACYM_REDIRECT_LINK_UNSUB'
293 - ).'</label>
294 - <input type="text" class="widefat" id="'.$this->get_field_id('unsubredirect').'" name="'.$this->get_field_name(
295 - 'unsubredirect'
296 - ).'" value="'.$params['unsubredirect'].'" /></p>';
297 -
298 - $optionsSuccess = [];
299 - $optionsSuccess[] = acym_selectOption('replace', 'ACYM_SUCCESS_REPLACE');
300 - $optionsSuccess[] = acym_selectOption('replacetemp', 'ACYM_SUCCESS_REPLACE_TEMP');
301 - $optionsSuccess[] = acym_selectOption('toptemp', 'ACYM_SUCCESS_TOP_TEMP');
302 - $optionsSuccess[] = acym_selectOption('standard', 'ACYM_SUCCESS_STANDARD');
303 - echo '<p><label class="acyWPconfig" title="'.acym_translation('ACYM_SUCCESS_MODE_DESC').'">'.acym_translation('ACYM_SUCCESS_MODE').'</label>';
304 - echo acym_select(
305 - $optionsSuccess,
306 - $this->get_field_name('successmode'),
307 - $params['successmode'],
308 - [
309 - 'class' => 'acym_simple_select2',
310 - ],
311 - 'value',
312 - 'text',
313 - $this->get_field_id('successmode')
314 - ).'</p>';
315 -
316 - echo '<p>
317 - <label
318 - class="acyWPconfig"
319 - for="'.$this->get_field_id('confirmation_message').'"
320 - title="'.acym_translation('ACYM_CONFIRMATION_MESSAGE_DESC').'">'.acym_translation('ACYM_CONFIRMATION_MESSAGE').'</label>
321 - <input
322 - type="text" class="widefat"
323 - id="'.$this->get_field_id('confirmation_message').'"
324 - name="'.$this->get_field_name('confirmation_message').'"
325 - value="'.acym_escape($params['confirmation_message']).'" />
326 - </p>';
327 -
328 - echo '<p><label class="acyWPconfig" for="'.$this->get_field_id('redirect').'" title="'.acym_translation('ACYM_REDIRECT_LINK_DESC').'">'.acym_translation(
329 - 'ACYM_REDIRECT_LINK'
330 - ).'</label>
331 - <input type="text" class="widefat" id="'.$this->get_field_id('redirect').'" name="'.$this->get_field_name('redirect').'" value="'.$params['redirect'].'" /></p>';
332 -
333 - echo '<p><label class="acyWPconfig" for="'.$this->get_field_id('introtext').'" title="'.acym_translation('ACYM_INTRO_TEXT_DESC').'">'.acym_translation('ACYM_INTRO_TEXT').'</label>
334 - <textarea class="widefat" id="'.$this->get_field_id('introtext').'" name="'.$this->get_field_name('introtext').'" >'.$params['introtext'].'</textarea></p>';
335 -
336 - echo '<p><label class="acyWPconfig" for="'.$this->get_field_id('posttext').'" title="'.acym_translation('ACYM_POST_TEXT_DESC').'">'.acym_translation('ACYM_POST_TEXT').'</label>
337 - <textarea class="widefat" id="'.$this->get_field_id('posttext').'" name="'.$this->get_field_name('posttext').'" >'.$params['posttext'].'</textarea></p>';
338 -
339 - echo '<p><label class="acyWPconfig" title="'.acym_translation('ACYM_FORM_AUTOFILL_ID_DESC').'">'.acym_translation('ACYM_FORM_AUTOFILL_ID').'</label>';
340 - echo acym_boolean($this->get_field_name('userinfo'), $params['userinfo'], $this->get_field_id('userinfo')).'</p>';
341 -
342 - echo '<p><label class="acyWPconfig" for="'.$this->get_field_id('formclass').'" title="'.acym_translation('ACYM_FORM_CLASS_DESC').'">'.acym_translation('ACYM_FORM_CLASS').'</label>
343 - <input type="text" class="widefat" id="'.$this->get_field_id('formclass').'" name="'.$this->get_field_name('formclass').'" value="'.$params['formclass'].'" /></p>';
344 -
345 - $options = [];
346 - $options[] = acym_selectOption('header', 'ACYM_IN_HEADER');
347 - $options[] = acym_selectOption('module', 'ACYM_ON_THE_MODULE');
348 - echo '<p><label class="acyWPconfig" title="'.acym_translation('ACYM_MODULE_JS_DESC').'">'.acym_translation('ACYM_MODULE_JS').'</label>';
349 - echo acym_Select(
350 - $options,
351 - $this->get_field_name('includejs'),
352 - $params['includejs'],
353 - [
354 - 'class' => 'acym_simple_select2',
355 - ],
356 - 'value',
357 - 'text',
358 - $this->get_field_id('includejs')
359 - ).'</p>';
360 -
361 - $options = [];
362 - $options[] = acym_selectOption('none', 'ACYM_DEFAULT');
363 - $options[] = acym_selectOption('left', 'ACYM_LEFT');
364 - $options[] = acym_selectOption('center', 'ACYM_CENTER');
365 - $options[] = acym_selectOption('right', 'ACYM_RIGHT');
366 - echo '<p><label class="acyWPconfig" title="'.acym_translation('ACYM_ALIGNMENT_DESC').'">'.acym_translation('ACYM_ALIGNMENT').'</label>';
367 - echo acym_select(
368 - $options,
369 - $this->get_field_name('alignment'),
370 - $params['alignment'],
371 - [
372 - 'class' => 'acym_simple_select2',
373 - ],
374 - 'value',
375 - 'text',
376 - $this->get_field_id('alignment')
377 - ).'</p>';
378 -
379 - echo '<p><label class="acyWPconfig" for="'.$this->get_field_id('source').'" title="'.acym_translation('ACYM_SOURCE_DESC').'">'.acym_translation('ACYM_SOURCE').'</label>
380 - <input type="text" class="widefat" id="'.$this->get_field_id('source').'" name="'.$this->get_field_name('source').'" value="'.$params['source'].'" /></p>';
381 -
382 - echo '</div></div></div>';
383 - }
384 -
385 - public function widget($args, $instance)
386 - {
387 - $this->loadAcyMailing();
388 -
389 - $params = new AcymParameter($instance);
390 -
391 - echo acym_renderForm($params, $args);
392 - }
393 -
394 - private function loadAcyMailing(): void
395 - {
396 - $ds = DIRECTORY_SEPARATOR;
397 - require_once rtrim(dirname(dirname(__DIR__)), $ds).$ds.'back'.$ds.'Core'.$ds.'init.php';
398 - }
399 -}