| @@ -1,0 +1,559 @@ | ||
| 1 | +<?php | |
| 2 | + | |
| 3 | +defined('ABSPATH') || die('Restricted Access'); | |
| 4 | + | |
| 5 | +use AcyMailing\Classes\FieldClass; | |
| 6 | +use AcyMailing\Classes\ListClass; | |
| 7 | +use AcyMailing\Core\AcymParameter; | |
| 8 | + | |
| 9 | +class acym_subscriptionform_widget extends WP_Widget | |
| 10 | +{ | |
| 11 | + public function __construct() | |
| 12 | + { | |
| 13 | + $this->loadAcyMailing(); | |
| 14 | + | |
| 15 | + parent::__construct( | |
| 16 | + 'acym_subscriptionform_widget', | |
| 17 | + acym_translationSprintf('ACYM_MENU', acym_translation('ACYM_MENU_FORM')), | |
| 18 | + ['description' => acym_translation('ACYM_MENU_FORM_DESC')] | |
| 19 | + ); | |
| 20 | + } | |
| 21 | + | |
| 22 | + // Configuration | |
| 23 | + public function form($instance) | |
| 24 | + { | |
| 25 | + $this->loadAcyMailing(); | |
| 26 | + | |
| 27 | + wp_enqueue_style( | |
| 28 | + 'select2lib', | |
| 29 | + ACYM_CSS.'libraries/select2-original.min.css?v='.filemtime(ACYM_MEDIA.'css'.DS.'libraries'.DS.'select2-original.min.css'), | |
| 30 | + [], | |
| 31 | + '11.1.0' | |
| 32 | + ); | |
| 33 | + wp_enqueue_script( | |
| 34 | + 'select2lib', | |
| 35 | + ACYM_JS.'libraries/select2-full.min.js?v='.filemtime(ACYM_MEDIA.'js'.DS.'libraries'.DS.'select2-full.min.js'), | |
| 36 | + ['jquery'], | |
| 37 | + '11.1.0', | |
| 38 | + [ | |
| 39 | + 'in_footer' => false, | |
| 40 | + ] | |
| 41 | + ); | |
| 42 | + wp_enqueue_script( | |
| 43 | + 'acym_widget_article', | |
| 44 | + ACYM_JS.'widget.min.js', | |
| 45 | + ['select2lib'], | |
| 46 | + '11.1.0', | |
| 47 | + [ | |
| 48 | + 'in_footer' => false, | |
| 49 | + ] | |
| 50 | + ); | |
| 51 | + // CSRF token for the article-search AJAX (dynamics/trigger requires acym_checkToken) | |
| 52 | + wp_add_inline_script( | |
| 53 | + 'acym_widget_article', | |
| 54 | + 'var acym_widget_nonce = '.json_encode(wp_create_nonce('acymnonce')).';', | |
| 55 | + 'before' | |
| 56 | + ); | |
| 57 | + acym_addStyle(false, ACYM_CSS.'widget.min.css?v='.filemtime(ACYM_MEDIA.'css'.DS.'widget.min.css')); | |
| 58 | + | |
| 59 | + $listClass = new ListClass(); | |
| 60 | + $fieldClass = new FieldClass(); | |
| 61 | + $allFields = $fieldClass->getAll(); | |
| 62 | + $fields = []; | |
| 63 | + foreach ($allFields as $field) { | |
| 64 | + if ($field->id == 2 || intval($field->active) === 0) continue; | |
| 65 | + $fields[$field->id] = acym_translation($field->name); | |
| 66 | + } | |
| 67 | + | |
| 68 | + $lists = $listClass->getAllWithoutManagement(); | |
| 69 | + foreach ($lists as $i => $oneList) { | |
| 70 | + if ($oneList->active == 0) { | |
| 71 | + unset($lists[$i]); | |
| 72 | + } | |
| 73 | + } | |
| 74 | + | |
| 75 | + $listIds = array_keys($lists); | |
| 76 | + $params = [ | |
| 77 | + 'title' => 'Receive our newsletters', | |
| 78 | + 'mode' => 'tableless', | |
| 79 | + 'hiddenlists' => array_shift($listIds), | |
| 80 | + 'displists' => '', | |
| 81 | + 'listschecked' => '', | |
| 82 | + 'listposition' => 'before', | |
| 83 | + 'fields' => '1', | |
| 84 | + 'textmode' => '1', | |
| 85 | + 'subtext' => '', | |
| 86 | + 'subtextlogged' => '', | |
| 87 | + 'termscontent' => '0', | |
| 88 | + 'privacypolicy' => '0', | |
| 89 | + 'termscontentURL' => '', | |
| 90 | + 'privacypolicyURL' => '', | |
| 91 | + 'trackingconsent' => '0', | |
| 92 | + 'articlepopup' => '1', | |
| 93 | + 'unsub' => '0', | |
| 94 | + 'unsubtext' => '', | |
| 95 | + 'unsubredirect' => '', | |
| 96 | + 'successmode' => 'replace', | |
| 97 | + 'confirmation_message' => '', | |
| 98 | + 'redirect' => '', | |
| 99 | + 'introtext' => '', | |
| 100 | + 'posttext' => '', | |
| 101 | + 'userinfo' => true, | |
| 102 | + 'formclass' => '', | |
| 103 | + 'alignment' => 'none', | |
| 104 | + 'source' => 'widget __i__', | |
| 105 | + 'includejs' => 'header', | |
| 106 | + ]; | |
| 107 | + foreach ($params as $oneParam => &$value) { | |
| 108 | + if (!empty($instance)) { | |
| 109 | + $value = $instance[$oneParam] ?? ''; | |
| 110 | + } | |
| 111 | + | |
| 112 | + if (is_array($value)) { | |
| 113 | + $value = implode(',', $value); | |
| 114 | + } | |
| 115 | + | |
| 116 | + if ($oneParam === 'userinfo') { | |
| 117 | + $value = (bool)$value; | |
| 118 | + } else { | |
| 119 | + $value = esc_attr($value); | |
| 120 | + } | |
| 121 | + } | |
| 122 | + | |
| 123 | + if (!isset($instance['hiddenlists']) && !empty($params['displists'])) { | |
| 124 | + $params['hiddenlists'] = ''; | |
| 125 | + } | |
| 126 | + | |
| 127 | + echo '<div class="acym_toggle_zone"> | |
| 128 | + <div class="acyblock" id="mainopt_acywidget"> | |
| 129 | + <div class="acym_toggle_div_title"> | |
| 130 | + <h3>'.esc_html(acym_translation('ACYM_MAIN_OPTIONS')).'</h3> | |
| 131 | + </div> | |
| 132 | + <div class="acym_toggle_div" style="display: none;">'; | |
| 133 | + | |
| 134 | + echo '<p><label class="acyWPconfig" for="'.esc_attr($this->get_field_id('title')).'">'.esc_html(acym_translation('ACYM_TITLE')).'</label> | |
| 135 | + <input type="text" class="widefat" id="'.esc_attr($this->get_field_id('title')).'" name="'.esc_attr($this->get_field_name('title')).'" value="'.esc_attr( | |
| 136 | + $params['title'] | |
| 137 | + ).'" /></p>'; | |
| 138 | + | |
| 139 | + $options = []; | |
| 140 | + $options[] = acym_selectOption('inline', 'ACYM_MODE_HORIZONTAL'); | |
| 141 | + $options[] = acym_selectOption('vertical', 'ACYM_MODE_VERTICAL'); | |
| 142 | + $options[] = acym_selectOption('tableless', 'ACYM_MODE_TABLELESS'); | |
| 143 | + echo '<p><label class="acyWPconfig" title="'.esc_attr(acym_translation('ACYM_DISPLAY_MODE_DESC')).'">'.esc_html(acym_translation('ACYM_DISPLAY_MODE')).'</label>'; | |
| 144 | + acym_select( | |
| 145 | + $options, | |
| 146 | + $this->get_field_name('mode'), | |
| 147 | + $params['mode'], | |
| 148 | + [ | |
| 149 | + 'class' => 'acym_simple_select2', | |
| 150 | + ], | |
| 151 | + 'value', | |
| 152 | + 'text', | |
| 153 | + $this->get_field_id('mode'), | |
| 154 | + false, | |
| 155 | + true | |
| 156 | + ); | |
| 157 | + echo '</p>'; | |
| 158 | + | |
| 159 | + echo '<p><label class="acyWPconfig" title="'.esc_attr(acym_translation('ACYM_AUTO_SUBSCRIBE_TO_DESC')).'">'.esc_html(acym_translation('ACYM_AUTO_SUBSCRIBE_TO')).'</label>'; | |
| 160 | + acym_selectMultiple( | |
| 161 | + $lists, | |
| 162 | + $this->get_field_name('hiddenlists'), | |
| 163 | + explode(',', $params['hiddenlists']), | |
| 164 | + [ | |
| 165 | + 'class' => 'acym_simple_select2', | |
| 166 | + 'id' => $this->get_field_id('hiddenlists'), | |
| 167 | + ], | |
| 168 | + 'id', | |
| 169 | + 'name', | |
| 170 | + true | |
| 171 | + ); | |
| 172 | + echo '</p>'; | |
| 173 | + | |
| 174 | + echo '<p><label class="acyWPconfig" title="'.esc_attr(acym_translation('ACYM_DISPLAYED_LISTS_DESC')).'">'.esc_html(acym_translation('ACYM_DISPLAYED_LISTS')).'</label>'; | |
| 175 | + acym_selectMultiple( | |
| 176 | + $lists, | |
| 177 | + $this->get_field_name('displists'), | |
| 178 | + explode(',', $params['displists']), | |
| 179 | + [ | |
| 180 | + 'class' => 'acym_simple_select2', | |
| 181 | + 'id' => $this->get_field_id('displists'), | |
| 182 | + ], | |
| 183 | + 'id', | |
| 184 | + 'name', | |
| 185 | + true | |
| 186 | + ); | |
| 187 | + echo '</p>'; | |
| 188 | + | |
| 189 | + echo '<p><label class="acyWPconfig" title="'.esc_attr(acym_translation('ACYM_LISTS_CHECKED_DEFAULT_DESC')).'">'.esc_html( | |
| 190 | + acym_translation('ACYM_LISTS_CHECKED_DEFAULT') | |
| 191 | + ).'</label>'; | |
| 192 | + acym_selectMultiple( | |
| 193 | + $lists, | |
| 194 | + $this->get_field_name('listschecked'), | |
| 195 | + explode(',', $params['listschecked']), | |
| 196 | + [ | |
| 197 | + 'class' => 'acym_simple_select2', | |
| 198 | + 'id' => $this->get_field_id('listschecked'), | |
| 199 | + ], | |
| 200 | + 'id', | |
| 201 | + 'name', | |
| 202 | + true | |
| 203 | + ); | |
| 204 | + echo '</p>'; | |
| 205 | + | |
| 206 | + $options = []; | |
| 207 | + $options[] = acym_selectOption('before', 'ACYM_BEFORE_FIELDS'); | |
| 208 | + $options[] = acym_selectOption('after', 'ACYM_AFTER_FIELDS'); | |
| 209 | + echo '<p><label class="acyWPconfig">'.esc_html(acym_translation('ACYM_LIST_POSITION')).'</label>'; | |
| 210 | + acym_select( | |
| 211 | + $options, | |
| 212 | + $this->get_field_name('listposition'), | |
| 213 | + $params['listposition'], | |
| 214 | + [ | |
| 215 | + 'class' => 'acym_simple_select2', | |
| 216 | + ], | |
| 217 | + 'value', | |
| 218 | + 'text', | |
| 219 | + $this->get_field_id('listposition'), | |
| 220 | + false, | |
| 221 | + true | |
| 222 | + ); | |
| 223 | + echo '</p>'; | |
| 224 | + | |
| 225 | + echo '<p><label class="acyWPconfig" title="'.esc_attr(acym_translation('ACYM_FIELDS_TO_DISPLAY_DESC')).'">'.esc_html(acym_translation('ACYM_FIELDS_TO_DISPLAY')).'</label>'; | |
| 226 | + acym_selectMultiple( | |
| 227 | + $fields, | |
| 228 | + $this->get_field_name('fields'), | |
| 229 | + explode(',', $params['fields']), | |
| 230 | + [ | |
| 231 | + 'class' => 'acym_simple_select2', | |
| 232 | + 'id' => $this->get_field_id('fields'), | |
| 233 | + ], | |
| 234 | + 'value', | |
| 235 | + 'text', | |
| 236 | + true | |
| 237 | + ); | |
| 238 | + echo '</p>'; | |
| 239 | + | |
| 240 | + $options = []; | |
| 241 | + $options[] = acym_selectOption('1', 'ACYM_TEXT_INSIDE'); | |
| 242 | + $options[] = acym_selectOption('0', 'ACYM_TEXT_OUTSIDE'); | |
| 243 | + echo '<p><label class="acyWPconfig" title="'.esc_attr(acym_translation('ACYM_TEXT_MODE_DESC')).'">'.esc_html(acym_translation('ACYM_TEXT_MODE')).'</label>'; | |
| 244 | + acym_select( | |
| 245 | + $options, | |
| 246 | + $this->get_field_name('textmode'), | |
| 247 | + $params['textmode'], | |
| 248 | + [ | |
| 249 | + 'class' => 'acym_simple_select2', | |
| 250 | + ], | |
| 251 | + 'value', | |
| 252 | + 'text', | |
| 253 | + $this->get_field_id('textmode'), | |
| 254 | + false, | |
| 255 | + true | |
| 256 | + ); | |
| 257 | + echo '</p>'; | |
| 258 | + | |
| 259 | + echo '<p><label class="acyWPconfig" for="'.esc_attr($this->get_field_id('subtext')).'" title="'.esc_attr(acym_translation('ACYM_SUBSCRIBE_TEXT_DESC')).'">'.esc_html( | |
| 260 | + acym_translation( | |
| 261 | + 'ACYM_SUBSCRIBE_TEXT' | |
| 262 | + ) | |
| 263 | + ).'</label> | |
| 264 | + <input type="text" class="widefat" id="'.esc_attr($this->get_field_id('subtext')).'" name="'.esc_attr($this->get_field_name('subtext')).'" value="'.esc_attr( | |
| 265 | + $params['subtext'] | |
| 266 | + ).'" /></p>'; | |
| 267 | + | |
| 268 | + echo '<p><label class="acyWPconfig" for="'.esc_attr($this->get_field_id('subtextlogged')).'" title="'.esc_attr( | |
| 269 | + acym_translation('ACYM_SUBSCRIBE_TEXT_LOGGED_IN_DESC') | |
| 270 | + ).'">'.esc_html( | |
| 271 | + acym_translation( | |
| 272 | + 'ACYM_SUBSCRIBE_TEXT_LOGGED_IN' | |
| 273 | + ) | |
| 274 | + ).'</label> | |
| 275 | + <input type="text" class="widefat" id="'.esc_attr($this->get_field_id('subtextlogged')).'" name="'.esc_attr( | |
| 276 | + $this->get_field_name( | |
| 277 | + 'subtextlogged' | |
| 278 | + ) | |
| 279 | + ).'" value="'.esc_attr($params['subtextlogged']).'" /></p>'; | |
| 280 | + | |
| 281 | + $options = []; | |
| 282 | + if (!empty($params['termscontent'])) { | |
| 283 | + $options[] = acym_selectOption($params['termscontent'], get_the_title($params['termscontent'])); | |
| 284 | + } | |
| 285 | + echo '<p><label class="acyWPconfig">'.esc_html(acym_translation('ACYM_TERMS_CONDITIONS')).'</label>'; | |
| 286 | + acym_select( | |
| 287 | + $options, | |
| 288 | + $this->get_field_name('termscontent'), | |
| 289 | + $params['termscontent'], | |
| 290 | + [ | |
| 291 | + 'class' => 'acym_post_select2', | |
| 292 | + 'title' => acym_translation('ACYM_PRIVACY_POLICY'), | |
| 293 | + ], | |
| 294 | + 'value', | |
| 295 | + 'text', | |
| 296 | + $this->get_field_id('termscontent'), | |
| 297 | + false, | |
| 298 | + true | |
| 299 | + ); | |
| 300 | + echo '</p>'; | |
| 301 | + | |
| 302 | + $options = []; | |
| 303 | + if (!empty($params['privacypolicy'])) { | |
| 304 | + $options[] = acym_selectOption($params['privacypolicy'], get_the_title($params['privacypolicy'])); | |
| 305 | + } | |
| 306 | + echo '<p><label class="acyWPconfig">'.esc_html(acym_translation('ACYM_PRIVACY_POLICY')).'</label>'; | |
| 307 | + acym_select( | |
| 308 | + $options, | |
| 309 | + $this->get_field_name('privacypolicy'), | |
| 310 | + $params['privacypolicy'], | |
| 311 | + [ | |
| 312 | + 'class' => 'acym_post_select2', | |
| 313 | + 'title' => acym_translation('ACYM_PRIVACY_POLICY'), | |
| 314 | + ], | |
| 315 | + 'value', | |
| 316 | + 'text', | |
| 317 | + $this->get_field_id('privacypolicy'), | |
| 318 | + false, | |
| 319 | + true | |
| 320 | + ); | |
| 321 | + echo '</p>'; | |
| 322 | + | |
| 323 | + echo '<p> | |
| 324 | + <label class="acyWPconfig" for="'.esc_attr($this->get_field_id('termscontentURL')).'"> | |
| 325 | + '.esc_html(acym_translation('ACYM_TERMS_CONDITIONS_URL')).' | |
| 326 | + </label> | |
| 327 | + <input | |
| 328 | + type="text" class="widefat" | |
| 329 | + id="'.esc_attr($this->get_field_id('termscontentURL')).'" | |
| 330 | + name="'.esc_attr($this->get_field_name('termscontentURL')).'" | |
| 331 | + value="'.esc_url($params['termscontentURL']).'" | |
| 332 | + /> | |
| 333 | + </p>'; | |
| 334 | + | |
| 335 | + echo '<p> | |
| 336 | + <label class="acyWPconfig" for="'.esc_attr($this->get_field_id('privacypolicyURL')).'"> | |
| 337 | + '.esc_html(acym_translation('ACYM_PRIVACY_POLICY_URL')).' | |
| 338 | + </label> | |
| 339 | + <input | |
| 340 | + type="text" class="widefat" | |
| 341 | + id="'.esc_attr($this->get_field_id('privacypolicyURL')).'" | |
| 342 | + name="'.esc_attr($this->get_field_name('privacypolicyURL')).'" | |
| 343 | + value="'.esc_url($params['privacypolicyURL']).'" | |
| 344 | + /> | |
| 345 | + </p>'; | |
| 346 | + | |
| 347 | + $options = []; | |
| 348 | + $options[] = acym_selectOption('0', 'ACYM_NO'); | |
| 349 | + $options[] = acym_selectOption('1', 'ACYM_YES'); | |
| 350 | + echo '<p><label class="acyWPconfig" title="'.esc_attr(acym_translation('ACYM_DISPLAY_TRACKING_CONSENT_DESC')).'">'.esc_html(acym_translation('ACYM_DISPLAY_TRACKING_CONSENT')).'</label>'; | |
| 351 | + acym_select( | |
| 352 | + $options, | |
| 353 | + $this->get_field_name('trackingconsent'), | |
| 354 | + $params['trackingconsent'], | |
| 355 | + [ | |
| 356 | + 'class' => 'acym_simple_select2', | |
| 357 | + ], | |
| 358 | + 'value', | |
| 359 | + 'text', | |
| 360 | + $this->get_field_id('trackingconsent'), | |
| 361 | + false, | |
| 362 | + true | |
| 363 | + ); | |
| 364 | + echo '</p>'; | |
| 365 | + | |
| 366 | + //echo '<p><label class="acyWPconfig">'.esc_html(acym_translation('ACYM_DISPLAY_ARTICLE_POPUP')).'</label>'; | |
| 367 | + //acym_boolean($this->get_field_name('articlepopup'), $params['articlepopup'], $this->get_field_id('articlepopup'), array()).'</p>'; | |
| 368 | + | |
| 369 | + echo '</div> | |
| 370 | + </div> | |
| 371 | + <div class="acyblock" id="advopt_acywidget"> | |
| 372 | + <div class="acym_toggle_div_title"> | |
| 373 | + <h3>'.esc_html(acym_translation('ACYM_ADVANCED_OPTIONS')).'</h3> | |
| 374 | + </div> | |
| 375 | + <div class="acym_toggle_div" style="display: none;">'; | |
| 376 | + | |
| 377 | + echo '<p><label class="acyWPconfig">'.esc_html(acym_translation('ACYM_DISPLAY_UNSUB_BUTTON')).'</label>'; | |
| 378 | + $onchange = "var disp = 'none';"; | |
| 379 | + $onchange .= "if(this.value != 0){disp = 'block';}"; | |
| 380 | + $onchange .= "var elements = document.getElementsByClassName('".esc_js($this->get_field_id('unsubtextrow'))."');"; | |
| 381 | + $onchange .= "for(var i = 0 ; i < elements.length ; i++){elements[i].style.display = disp;}"; | |
| 382 | + acym_select( | |
| 383 | + [ | |
| 384 | + '0' => 'ACYM_NO', | |
| 385 | + '1' => 'ACYM_CONNECTED_USER_SUBSCRIBED', | |
| 386 | + '2' => 'ACYM_ALWAYS', | |
| 387 | + ], | |
| 388 | + $this->get_field_name('unsub'), | |
| 389 | + $params['unsub'], | |
| 390 | + [ | |
| 391 | + 'onchange' => $onchange, | |
| 392 | + 'class' => 'acym_simple_select2', | |
| 393 | + ], | |
| 394 | + 'value', | |
| 395 | + 'text', | |
| 396 | + $this->get_field_id('unsub'), | |
| 397 | + true, | |
| 398 | + true | |
| 399 | + ); | |
| 400 | + echo '</p>'; | |
| 401 | + | |
| 402 | + echo '<p class="'.esc_attr($this->get_field_id('unsubtextrow')).'" '.($params['unsub'] == '0' ? 'style="display:none;"' : '').'> | |
| 403 | + <label class="acyWPconfig" for="'.esc_attr($this->get_field_id('unsubtext')).'" title="'.esc_attr(acym_translation('ACYM_UNSUBSCRIBE_TEXT_DESC')).'">'.esc_html( | |
| 404 | + acym_translation( | |
| 405 | + 'ACYM_UNSUBSCRIBE_TEXT' | |
| 406 | + ) | |
| 407 | + ).'</label> | |
| 408 | + <input type="text" class="widefat" id="'.esc_attr($this->get_field_id('unsubtext')).'" name="'.esc_attr($this->get_field_name('unsubtext')).'" value="'.esc_attr( | |
| 409 | + $params['unsubtext'] | |
| 410 | + ).'" /></p>'; | |
| 411 | + | |
| 412 | + echo '<p class="'.esc_attr($this->get_field_id('unsubtextrow')).'" '.($params['unsub'] == '0' ? 'style="display:none;"' : '').'> | |
| 413 | + <label class="acyWPconfig" for="'.esc_attr($this->get_field_id('unsubredirect')).'" title="'.esc_attr(acym_translation('ACYM_REDIRECT_LINK_UNSUB_DESC')).'">'.esc_html( | |
| 414 | + acym_translation( | |
| 415 | + 'ACYM_REDIRECT_LINK_UNSUB' | |
| 416 | + ) | |
| 417 | + ).'</label> | |
| 418 | + <input type="text" class="widefat" id="'.esc_attr($this->get_field_id('unsubredirect')).'" name="'.esc_attr( | |
| 419 | + $this->get_field_name( | |
| 420 | + 'unsubredirect' | |
| 421 | + ) | |
| 422 | + ).'" value="'.esc_url($params['unsubredirect']).'" /></p>'; | |
| 423 | + | |
| 424 | + $optionsSuccess = []; | |
| 425 | + $optionsSuccess[] = acym_selectOption('replace', 'ACYM_SUCCESS_REPLACE'); | |
| 426 | + $optionsSuccess[] = acym_selectOption('replacetemp', 'ACYM_SUCCESS_REPLACE_TEMP'); | |
| 427 | + $optionsSuccess[] = acym_selectOption('toptemp', 'ACYM_SUCCESS_TOP_TEMP'); | |
| 428 | + $optionsSuccess[] = acym_selectOption('standard', 'ACYM_SUCCESS_STANDARD'); | |
| 429 | + echo '<p><label class="acyWPconfig" title="'.esc_attr(acym_translation('ACYM_SUCCESS_MODE_DESC')).'">'.esc_html(acym_translation('ACYM_SUCCESS_MODE')).'</label>'; | |
| 430 | + acym_select( | |
| 431 | + $optionsSuccess, | |
| 432 | + $this->get_field_name('successmode'), | |
| 433 | + $params['successmode'], | |
| 434 | + [ | |
| 435 | + 'class' => 'acym_simple_select2', | |
| 436 | + ], | |
| 437 | + 'value', | |
| 438 | + 'text', | |
| 439 | + $this->get_field_id('successmode'), | |
| 440 | + false, | |
| 441 | + true | |
| 442 | + ); | |
| 443 | + echo '</p>'; | |
| 444 | + | |
| 445 | + echo '<p> | |
| 446 | + <label | |
| 447 | + class="acyWPconfig" | |
| 448 | + for="'.esc_attr($this->get_field_id('confirmation_message')).'" | |
| 449 | + title="'.esc_attr(acym_translation('ACYM_CONFIRMATION_MESSAGE_DESC')).'">'.esc_html(acym_translation('ACYM_CONFIRMATION_MESSAGE')).'</label> | |
| 450 | + <input | |
| 451 | + type="text" class="widefat" | |
| 452 | + id="'.esc_attr($this->get_field_id('confirmation_message')).'" | |
| 453 | + name="'.esc_attr($this->get_field_name('confirmation_message')).'" | |
| 454 | + value="'.esc_attr($params['confirmation_message']).'" /> | |
| 455 | + </p>'; | |
| 456 | + | |
| 457 | + echo '<p><label class="acyWPconfig" for="'.esc_attr($this->get_field_id('redirect')).'" title="'.esc_attr(acym_translation('ACYM_REDIRECT_LINK_DESC')).'">'.esc_html( | |
| 458 | + acym_translation( | |
| 459 | + 'ACYM_REDIRECT_LINK' | |
| 460 | + ) | |
| 461 | + ).'</label> | |
| 462 | + <input type="text" class="widefat" id="'.esc_attr($this->get_field_id('redirect')).'" name="'.esc_attr($this->get_field_name('redirect')).'" value="'.esc_url( | |
| 463 | + $params['redirect'] | |
| 464 | + ).'" /></p>'; | |
| 465 | + | |
| 466 | + echo '<p><label class="acyWPconfig" for="'.esc_attr($this->get_field_id('introtext')).'" title="'.esc_attr(acym_translation('ACYM_INTRO_TEXT_DESC')).'">'.esc_html( | |
| 467 | + acym_translation( | |
| 468 | + 'ACYM_INTRO_TEXT' | |
| 469 | + ) | |
| 470 | + ).'</label> | |
| 471 | + <textarea class="widefat" id="'.esc_attr($this->get_field_id('introtext')).'" name="'.esc_attr($this->get_field_name('introtext')).'" >'.esc_html( | |
| 472 | + $params['introtext'] | |
| 473 | + ).'</textarea></p>'; | |
| 474 | + | |
| 475 | + echo '<p><label class="acyWPconfig" for="'.esc_attr($this->get_field_id('posttext')).'" title="'.esc_attr(acym_translation('ACYM_POST_TEXT_DESC')).'">'.esc_html( | |
| 476 | + acym_translation( | |
| 477 | + 'ACYM_POST_TEXT' | |
| 478 | + ) | |
| 479 | + ).'</label> | |
| 480 | + <textarea class="widefat" id="'.esc_attr($this->get_field_id('posttext')).'" name="'.esc_attr($this->get_field_name('posttext')).'" >'.esc_html( | |
| 481 | + $params['posttext'] | |
| 482 | + ).'</textarea></p>'; | |
| 483 | + | |
| 484 | + echo '<p><label class="acyWPconfig" title="'.esc_attr(acym_translation('ACYM_FORM_AUTOFILL_ID_DESC')).'">'.esc_html(acym_translation('ACYM_FORM_AUTOFILL_ID')).'</label>'; | |
| 485 | + acym_boolean($this->get_field_name('userinfo'), $params['userinfo'], $this->get_field_id('userinfo')).'</p>'; | |
| 486 | + | |
| 487 | + echo '<p><label class="acyWPconfig" for="'.esc_attr($this->get_field_id('formclass')).'" title="'.esc_attr(acym_translation('ACYM_FORM_CLASS_DESC')).'">'.esc_html( | |
| 488 | + acym_translation('ACYM_FORM_CLASS') | |
| 489 | + ).'</label> | |
| 490 | + <input type="text" class="widefat" id="'.esc_attr($this->get_field_id('formclass')).'" name="'.esc_attr($this->get_field_name('formclass')).'" value="'.esc_attr( | |
| 491 | + $params['formclass'] | |
| 492 | + ).'" /></p>'; | |
| 493 | + | |
| 494 | + $options = []; | |
| 495 | + $options[] = acym_selectOption('header', 'ACYM_IN_HEADER'); | |
| 496 | + $options[] = acym_selectOption('module', 'ACYM_ON_THE_MODULE'); | |
| 497 | + echo '<p><label class="acyWPconfig" title="'.esc_attr(acym_translation('ACYM_MODULE_JS_DESC')).'">'.esc_html(acym_translation('ACYM_MODULE_JS')).'</label>'; | |
| 498 | + acym_select( | |
| 499 | + $options, | |
| 500 | + $this->get_field_name('includejs'), | |
| 501 | + $params['includejs'], | |
| 502 | + [ | |
| 503 | + 'class' => 'acym_simple_select2', | |
| 504 | + ], | |
| 505 | + 'value', | |
| 506 | + 'text', | |
| 507 | + $this->get_field_id('includejs'), | |
| 508 | + false, | |
| 509 | + true | |
| 510 | + ); | |
| 511 | + echo '</p>'; | |
| 512 | + | |
| 513 | + $options = []; | |
| 514 | + $options[] = acym_selectOption('none', 'ACYM_DEFAULT'); | |
| 515 | + $options[] = acym_selectOption('left', 'ACYM_LEFT'); | |
| 516 | + $options[] = acym_selectOption('center', 'ACYM_CENTER'); | |
| 517 | + $options[] = acym_selectOption('right', 'ACYM_RIGHT'); | |
| 518 | + echo '<p><label class="acyWPconfig" title="'.esc_attr(acym_translation('ACYM_ALIGNMENT_DESC')).'">'.esc_html(acym_translation('ACYM_ALIGNMENT')).'</label>'; | |
| 519 | + acym_select( | |
| 520 | + $options, | |
| 521 | + $this->get_field_name('alignment'), | |
| 522 | + $params['alignment'], | |
| 523 | + [ | |
| 524 | + 'class' => 'acym_simple_select2', | |
| 525 | + ], | |
| 526 | + 'value', | |
| 527 | + 'text', | |
| 528 | + $this->get_field_id('alignment'), | |
| 529 | + false, | |
| 530 | + true | |
| 531 | + ); | |
| 532 | + echo '</p>'; | |
| 533 | + | |
| 534 | + echo '<p><label class="acyWPconfig" for="'.esc_attr($this->get_field_id('source')).'" title="'.esc_attr(acym_translation('ACYM_SOURCE_DESC')).'">'.esc_html( | |
| 535 | + acym_translation('ACYM_SOURCE') | |
| 536 | + ).'</label> | |
| 537 | + <input type="text" class="widefat" id="'.esc_attr($this->get_field_id('source')).'" name="'.esc_attr($this->get_field_name('source')).'" value="'.esc_attr( | |
| 538 | + $params['source'] | |
| 539 | + ).'" /></p>'; | |
| 540 | + | |
| 541 | + echo '</div></div></div>'; | |
| 542 | + } | |
| 543 | + | |
| 544 | + // Widget's output | |
| 545 | + public function widget($args, $instance) | |
| 546 | + { | |
| 547 | + $this->loadAcyMailing(); | |
| 548 | + | |
| 549 | + $params = new AcymParameter($instance); | |
| 550 | + | |
| 551 | + acym_renderForm($params, $args); | |
| 552 | + } | |
| 553 | + | |
| 554 | + private function loadAcyMailing(): void | |
| 555 | + { | |
| 556 | + $ds = DIRECTORY_SEPARATOR; | |
| 557 | + require_once rtrim(dirname(dirname(__DIR__)), $ds).$ds.'back'.$ds.'Core'.$ds.'init.php'; | |
| 558 | + } | |
| 559 | +} | |