| @@ -1,9 +1,10 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | +defined('ABSPATH') || die('Restricted Access'); | |
| 4 | + | |
| 3 | 5 | use AcyMailing\Classes\FieldClass; |
| 4 | 6 | use AcyMailing\Classes\ListClass; |
| 5 | -use AcyMailing\Classes\UserClass; | |
| 6 | 7 | use AcyMailing\Core\AcymParameter; |
| 7 | 8 | |
| 8 | 9 | class acym_subscriptionform_widget extends WP_Widget |
| 9 | 10 | { |
| @@ -17,15 +18,43 @@ | ||
| 17 | 18 | ['description' => acym_translation('ACYM_MENU_FORM_DESC')] |
| 18 | 19 | ); |
| 19 | 20 | } |
| 20 | 21 | |
| 22 | + // Configuration | |
| 21 | 23 | public function form($instance) |
| 22 | 24 | { |
| 23 | 25 | $this->loadAcyMailing(); |
| 24 | 26 | |
| 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']); | |
| 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 | + ); | |
| 28 | 57 | acym_addStyle(false, ACYM_CSS.'widget.min.css?v='.filemtime(ACYM_MEDIA.'css'.DS.'widget.min.css')); |
| 29 | 58 | |
| 30 | 59 | $listClass = new ListClass(); |
| 31 | 60 | $fieldClass = new FieldClass(); |
| @@ -56,8 +85,11 @@ | ||
| 56 | 85 | 'subtext' => '', |
| 57 | 86 | 'subtextlogged' => '', |
| 58 | 87 | 'termscontent' => '0', |
| 59 | 88 | 'privacypolicy' => '0', |
| 89 | + 'termscontentURL' => '', | |
| 90 | + 'privacypolicyURL' => '', | |
| 91 | + 'trackingconsent' => '0', | |
| 60 | 92 | 'articlepopup' => '1', |
| 61 | 93 | 'unsub' => '0', |
| 62 | 94 | 'unsubtext' => '', |
| 63 | 95 | 'unsubredirect' => '', |
| @@ -65,9 +97,9 @@ | ||
| 65 | 97 | 'confirmation_message' => '', |
| 66 | 98 | 'redirect' => '', |
| 67 | 99 | 'introtext' => '', |
| 68 | 100 | 'posttext' => '', |
| 69 | - 'userinfo' => '1', | |
| 101 | + 'userinfo' => true, | |
| 70 | 102 | 'formclass' => '', |
| 71 | 103 | 'alignment' => 'none', |
| 72 | 104 | 'source' => 'widget __i__', |
| 73 | 105 | 'includejs' => 'header', |
| @@ -73,13 +105,9 @@ | ||
| 73 | 105 | 'includejs' => 'header', |
| 74 | 106 | ]; |
| 75 | 107 | foreach ($params as $oneParam => &$value) { |
| 76 | 108 | if (!empty($instance)) { |
| 77 | - if (isset($instance[$oneParam])) { | |
| 78 | - $value = $instance[$oneParam]; | |
| 79 | - } else { | |
| 80 | - $value = ''; | |
| 81 | - } | |
| 109 | + $value = $instance[$oneParam] ?? ''; | |
| 82 | 110 | } |
| 83 | 111 | |
| 84 | 112 | if (is_array($value)) { |
| 85 | 113 | $value = implode(',', $value); |
| @@ -84,9 +112,13 @@ | ||
| 84 | 112 | if (is_array($value)) { |
| 85 | 113 | $value = implode(',', $value); |
| 86 | 114 | } |
| 87 | 115 | |
| 88 | - $value = esc_attr($value); | |
| 116 | + if ($oneParam === 'userinfo') { | |
| 117 | + $value = (bool)$value; | |
| 118 | + } else { | |
| 119 | + $value = esc_attr($value); | |
| 120 | + } | |
| 89 | 121 | } |
| 90 | 122 | |
| 91 | 123 | if (!isset($instance['hiddenlists']) && !empty($params['displists'])) { |
| 92 | 124 | $params['hiddenlists'] = ''; |
| @@ -94,207 +126,301 @@ | ||
| 94 | 126 | |
| 95 | 127 | echo '<div class="acym_toggle_zone"> |
| 96 | 128 | <div class="acyblock" id="mainopt_acywidget"> |
| 97 | 129 | <div class="acym_toggle_div_title"> |
| 98 | - <h3>'.acym_translation('ACYM_MAIN_OPTIONS').'</h3> | |
| 130 | + <h3>'.esc_html(acym_translation('ACYM_MAIN_OPTIONS')).'</h3> | |
| 99 | 131 | </div> |
| 100 | 132 | <div class="acym_toggle_div" style="display: none;">'; |
| 101 | 133 | |
| 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>'; | |
| 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>'; | |
| 104 | 138 | |
| 105 | 139 | $options = []; |
| 106 | 140 | $options[] = acym_selectOption('inline', 'ACYM_MODE_HORIZONTAL'); |
| 107 | 141 | $options[] = acym_selectOption('vertical', 'ACYM_MODE_VERTICAL'); |
| 108 | 142 | $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>'; | |
| 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>'; | |
| 121 | 158 | |
| 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>'; | |
| 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>'; | |
| 134 | 173 | |
| 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>'; | |
| 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>'; | |
| 147 | 188 | |
| 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>'; | |
| 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>'; | |
| 160 | 205 | |
| 161 | 206 | $options = []; |
| 162 | 207 | $options[] = acym_selectOption('before', 'ACYM_BEFORE_FIELDS'); |
| 163 | 208 | $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>'; | |
| 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>'; | |
| 176 | 224 | |
| 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>'; | |
| 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>'; | |
| 187 | 239 | |
| 188 | 240 | $options = []; |
| 189 | 241 | $options[] = acym_selectOption('1', 'ACYM_TEXT_INSIDE'); |
| 190 | 242 | $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>'; | |
| 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>'; | |
| 203 | 258 | |
| 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' | |
| 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 | + ) | |
| 206 | 263 | ).'</label> |
| 207 | - <input type="text" class="widefat" id="'.$this->get_field_id('subtext').'" name="'.$this->get_field_name('subtext').'" value="'.$params['subtext'].'" /></p>'; | |
| 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>'; | |
| 208 | 267 | |
| 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' | |
| 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 | + ) | |
| 211 | 274 | ).'</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>'; | |
| 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>'; | |
| 215 | 280 | |
| 216 | 281 | $options = []; |
| 217 | 282 | if (!empty($params['termscontent'])) { |
| 218 | 283 | $options[] = acym_selectOption($params['termscontent'], get_the_title($params['termscontent'])); |
| 219 | 284 | } |
| 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>'; | |
| 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>'; | |
| 233 | 301 | |
| 234 | 302 | $options = []; |
| 235 | 303 | if (!empty($params['privacypolicy'])) { |
| 236 | 304 | $options[] = acym_selectOption($params['privacypolicy'], get_the_title($params['privacypolicy'])); |
| 237 | 305 | } |
| 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>'; | |
| 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>'; | |
| 251 | 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>'; | |
| 252 | 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 | + | |
| 253 | 369 | echo '</div> |
| 254 | 370 | </div> |
| 255 | 371 | <div class="acyblock" id="advopt_acywidget"> |
| 256 | 372 | <div class="acym_toggle_div_title"> |
| 257 | - <h3>'.acym_translation('ACYM_ADVANCED_OPTIONS').'</h3> | |
| 373 | + <h3>'.esc_html(acym_translation('ACYM_ADVANCED_OPTIONS')).'</h3> | |
| 258 | 374 | </div> |
| 259 | 375 | <div class="acym_toggle_div" style="display: none;">'; |
| 260 | 376 | |
| 261 | - echo '<p><label class="acyWPconfig">'.acym_translation('ACYM_DISPLAY_UNSUB_BUTTON').'</label>'; | |
| 377 | + echo '<p><label class="acyWPconfig">'.esc_html(acym_translation('ACYM_DISPLAY_UNSUB_BUTTON')).'</label>'; | |
| 262 | 378 | $onchange = "var disp = 'none';"; |
| 263 | 379 | $onchange .= "if(this.value != 0){disp = 'block';}"; |
| 264 | - $onchange .= "var elements = document.getElementsByClassName('".$this->get_field_id('unsubtextrow')."');"; | |
| 380 | + $onchange .= "var elements = document.getElementsByClassName('".esc_js($this->get_field_id('unsubtextrow'))."');"; | |
| 265 | 381 | $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>'; | |
| 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>'; | |
| 283 | 401 | |
| 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' | |
| 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 | + ) | |
| 287 | 407 | ).'</label> |
| 288 | - <input type="text" class="widefat" id="'.$this->get_field_id('unsubtext').'" name="'.$this->get_field_name('unsubtext').'" value="'.$params['unsubtext'].'" /></p>'; | |
| 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>'; | |
| 289 | 411 | |
| 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' | |
| 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 | + ) | |
| 293 | 417 | ).'</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>'; | |
| 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>'; | |
| 297 | 423 | |
| 298 | 424 | $optionsSuccess = []; |
| 299 | 425 | $optionsSuccess[] = acym_selectOption('replace', 'ACYM_SUCCESS_REPLACE'); |
| 300 | 426 | $optionsSuccess[] = acym_selectOption('replacetemp', 'ACYM_SUCCESS_REPLACE_TEMP'); |
| @@ -299,65 +425,91 @@ | ||
| 299 | 425 | $optionsSuccess[] = acym_selectOption('replace', 'ACYM_SUCCESS_REPLACE'); |
| 300 | 426 | $optionsSuccess[] = acym_selectOption('replacetemp', 'ACYM_SUCCESS_REPLACE_TEMP'); |
| 301 | 427 | $optionsSuccess[] = acym_selectOption('toptemp', 'ACYM_SUCCESS_TOP_TEMP'); |
| 302 | 428 | $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>'; | |
| 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>'; | |
| 315 | 444 | |
| 316 | 445 | echo '<p> |
| 317 | 446 | <label |
| 318 | 447 | class="acyWPconfig" |
| 319 | - for="'.$this->get_field_id('confirmation_message').'" | |
| 320 | - title="'.acym_translation('ACYM_CONFIRMATION_MESSAGE_DESC').'">'.acym_translation('ACYM_CONFIRMATION_MESSAGE').'</label> | |
| 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> | |
| 321 | 450 | <input |
| 322 | 451 | 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']).'" /> | |
| 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']).'" /> | |
| 326 | 455 | </p>'; |
| 327 | 456 | |
| 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' | |
| 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 | + ) | |
| 330 | 461 | ).'</label> |
| 331 | - <input type="text" class="widefat" id="'.$this->get_field_id('redirect').'" name="'.$this->get_field_name('redirect').'" value="'.$params['redirect'].'" /></p>'; | |
| 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>'; | |
| 332 | 465 | |
| 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>'; | |
| 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>'; | |
| 335 | 474 | |
| 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>'; | |
| 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>'; | |
| 338 | 483 | |
| 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>'; | |
| 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>'; | |
| 341 | 486 | |
| 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>'; | |
| 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>'; | |
| 344 | 493 | |
| 345 | 494 | $options = []; |
| 346 | 495 | $options[] = acym_selectOption('header', 'ACYM_IN_HEADER'); |
| 347 | 496 | $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>'; | |
| 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>'; | |
| 360 | 512 | |
| 361 | 513 | $options = []; |
| 362 | 514 | $options[] = acym_selectOption('none', 'ACYM_DEFAULT'); |
| 363 | 515 | $options[] = acym_selectOption('left', 'ACYM_LEFT'); |
| @@ -362,27 +514,35 @@ | ||
| 362 | 514 | $options[] = acym_selectOption('none', 'ACYM_DEFAULT'); |
| 363 | 515 | $options[] = acym_selectOption('left', 'ACYM_LEFT'); |
| 364 | 516 | $options[] = acym_selectOption('center', 'ACYM_CENTER'); |
| 365 | 517 | $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>'; | |
| 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>'; | |
| 378 | 533 | |
| 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>'; | |
| 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>'; | |
| 381 | 540 | |
| 382 | 541 | echo '</div></div></div>'; |
| 383 | 542 | } |
| 384 | 543 | |
| 544 | + // Widget's output | |
| 385 | 545 | public function widget($args, $instance) |
| 386 | 546 | { |
| 387 | 547 | $this->loadAcyMailing(); |
| 388 | 548 | |
| @@ -387,9 +547,9 @@ | ||
| 387 | 547 | $this->loadAcyMailing(); |
| 388 | 548 | |
| 389 | 549 | $params = new AcymParameter($instance); |
| 390 | 550 | |
| 391 | - echo acym_renderForm($params, $args); | |
| 551 | + acym_renderForm($params, $args); | |
| 392 | 552 | } |
| 393 | 553 | |
| 394 | 554 | private function loadAcyMailing(): void |
| 395 | 555 | { |