| @@ -1,31 +1,42 @@ | ||
| 1 | 1 | <?php |
| 2 | -$hideForScroll = ''; | |
| 3 | -if (!$edition && isset($form->settings['display']['scroll']) && $form->settings['display']['scroll'] != 0) { | |
| 4 | - $hideForScroll = 'style="display: none;"'; | |
| 5 | -} | |
| 2 | +// phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- View file, its variables are local to the include scope, not true globals. | |
| 3 | +defined('ABSPATH') || die('Restricted Access'); | |
| 6 | 4 | ?> |
| 7 | -<div id="acym_fulldiv_<?php echo $form->form_tag_name; ?>" | |
| 8 | - class="acym__subscription__form__popup__overlay acym__subscription__form-erase" | |
| 9 | - <?php echo $hideForScroll; ?>> | |
| 5 | +<div id="acym_fulldiv_<?php echo esc_attr($form->form_tag_name); ?>" | |
| 6 | + class="acym__subscription__form__popup__overlay acym__subscription__form-erase" | |
| 7 | + role="dialog" | |
| 8 | + aria-modal="true" | |
| 9 | + aria-label="<?php echo esc_attr(acym_translation('ACYM_SUBSCRIPTION')); ?>" | |
| 10 | + <?php | |
| 11 | + if (!$edition && isset($form->settings['display']['scroll']) && $form->settings['display']['scroll'] != 0) { | |
| 12 | + echo 'style="display: none;"'; | |
| 13 | + } | |
| 14 | + ?>> | |
| 10 | 15 | <div class="acym__subscription__form__popup"> |
| 11 | - <div class="acym__subscription__form__popup__close acymicon-close"></div> | |
| 16 | + <button type="button" class="acym__subscription__form__popup__close acymicon-close" aria-label="<?php echo esc_attr(acym_translation('ACYM_CLOSE')); ?>"></button> | |
| 12 | 17 | <?php |
| 13 | 18 | if ($edition) { |
| 14 | - echo '<form action="#" onsubmit="return false;" id="'.$form->form_tag_name.'">'; | |
| 19 | + echo '<form action="#" onsubmit="return false;" id="'.esc_attr($form->form_tag_name).'">'; | |
| 15 | 20 | } else { |
| 16 | 21 | $isButton = $form->settings['display']['display_action'] === 'yes'; |
| 17 | 22 | if ($isButton) { |
| 18 | - $cookieExpirationAttr = 'acym-data-cookie="0"'; | |
| 23 | + $cookieExpiration = '0'; | |
| 19 | 24 | } else { |
| 20 | - $cookieExpirationAttr = empty($form->settings['cookie']['cookie_expiration']) ? 'acym-data-cookie="1"' | |
| 21 | - : 'acym-data-cookie="'.$form->settings['cookie']['cookie_expiration'].'"'; | |
| 25 | + $cookieExpiration = empty($form->settings['cookie']['cookie_expiration']) ? '1' : $form->settings['cookie']['cookie_expiration']; | |
| 22 | 26 | } |
| 23 | - echo '<form acym-data-id="'.$form->id.'" '.$cookieExpirationAttr.' action="'.$form->form_tag_action.'" id="'.$form->form_tag_name.'" name="'.$form->form_tag_name.'" enctype="multipart/form-data" onsubmit="return submitAcymForm(\'subscribe\',\''.$form->form_tag_name.'\', \'acymSubmitSubForm\')">'; | |
| 27 | + echo '<form acym-data-id="'.esc_attr($form->id).'" | |
| 28 | + acym-data-cookie="'.intval($cookieExpiration).'" | |
| 29 | + action="'.esc_url($form->form_tag_action).'" | |
| 30 | + id="'.esc_attr($form->form_tag_name).'" | |
| 31 | + name="'.esc_attr($form->form_tag_name).'" | |
| 32 | + aria-label="'.esc_attr(acym_translation('ACYM_SUBSCRIPTION')).'" | |
| 33 | + enctype="multipart/form-data" | |
| 34 | + onsubmit="return submitAcymForm(\'subscribe\',\''.esc_attr($form->form_tag_name).'\', \'acymSubmitSubForm\')">'; | |
| 24 | 35 | } |
| 25 | 36 | if (in_array($form->settings['style']['position'], ['image-top', 'image-left'])) { |
| 26 | 37 | if (!empty($form->settings['message']['text']) && $form->settings['message']['position'] === 'before-image') { |
| 27 | - echo '<p id="acym__subscription__form__popup-text">'.nl2br(acym_translation($form->settings['message']['text'])).'</p>'; | |
| 38 | + echo '<p id="acym__subscription__form__popup-text">'.nl2br(esc_html(acym_translation($form->settings['message']['text']))).'</p>'; | |
| 28 | 39 | } |
| 29 | 40 | include acym_getPartial('forms', 'image'); |
| 30 | 41 | } |
| 31 | 42 | echo '<div class="acym__subscription__form__popup__fields-button">'; |
| @@ -30,21 +41,21 @@ | ||
| 30 | 41 | } |
| 31 | 42 | echo '<div class="acym__subscription__form__popup__fields-button">'; |
| 32 | 43 | include acym_getPartial('forms', 'fields'); |
| 33 | 44 | if (!empty($form->settings['message']['text']) && $form->settings['message']['position'] == 'before-button') { |
| 34 | - echo '<p id="acym__subscription__form__popup-text">'.nl2br(acym_translation($form->settings['message']['text'])).'</p>'; | |
| 45 | + echo '<p id="acym__subscription__form__popup-text">'.nl2br(esc_html(acym_translation($form->settings['message']['text']))).'</p>'; | |
| 35 | 46 | } |
| 36 | 47 | include acym_getPartial('forms', 'button'); |
| 37 | 48 | echo '</div>'; |
| 38 | 49 | if (in_array($form->settings['style']['position'], ['image-bottom', 'image-right'])) { |
| 39 | 50 | if (!empty($form->settings['message']['text']) && $form->settings['message']['position'] == 'before-image') { |
| 40 | - echo '<p id="acym__subscription__form__popup-text">'.nl2br(acym_translation($form->settings['message']['text'])).'</p>'; | |
| 51 | + echo '<p id="acym__subscription__form__popup-text">'.nl2br(esc_html(acym_translation($form->settings['message']['text']))).'</p>'; | |
| 41 | 52 | } |
| 42 | 53 | include acym_getPartial('forms', 'image'); |
| 43 | 54 | } |
| 44 | 55 | include acym_getPartial('forms', 'hidden_params'); |
| 56 | + echo '</form>'; | |
| 45 | 57 | ?> |
| 46 | - </form> | |
| 47 | 58 | </div> |
| 48 | 59 | </div> |
| 49 | 60 | <?php |
| 50 | 61 | $popupPosition = $form->settings['display']['popup_position'] ?? 'center'; |
| @@ -60,9 +71,9 @@ | ||
| 60 | 71 | ]; |
| 61 | 72 | $positionCss = $positionMap[$popupPosition] ?? 'top: 50%; left: 50%; transform: translate(-50%, -50%);'; |
| 62 | 73 | ?> |
| 63 | 74 | <style> |
| 64 | - <?php echo '#acym_fulldiv_'.$form->form_tag_name; ?>.acym__subscription__form__popup__overlay{ | |
| 75 | + #acym_fulldiv_<?php echo esc_html($form->form_tag_name); ?>.acym__subscription__form__popup__overlay{ | |
| 65 | 76 | display: <?php echo $edition ? 'inline' : 'none'; ?>; |
| 66 | 77 | <?php if ($popupPosition === 'center') { ?> |
| 67 | 78 | position: fixed; |
| 68 | 79 | top: 0; |
| @@ -74,9 +85,9 @@ | ||
| 74 | 85 | position: static; |
| 75 | 86 | <?php } ?> z-index: 999999; |
| 76 | 87 | } |
| 77 | 88 | |
| 78 | - <?php echo '#acym_fulldiv_'.$form->form_tag_name.' '; ?>.acym__subscription__form__popup__close{ | |
| 89 | + #acym_fulldiv_<?php echo esc_html($form->form_tag_name); ?> .acym__subscription__form__popup__close{ | |
| 79 | 90 | position: absolute; |
| 80 | 91 | top: 10px; |
| 81 | 92 | right: 10px; |
| 82 | 93 | font-weight: bold; |
| @@ -81,21 +92,26 @@ | ||
| 81 | 92 | right: 10px; |
| 82 | 93 | font-weight: bold; |
| 83 | 94 | font-size: 1rem; |
| 84 | 95 | cursor: pointer; |
| 96 | + background: none; | |
| 97 | + border: none; | |
| 98 | + padding: 0; | |
| 99 | + line-height: 1; | |
| 100 | + color: inherit; | |
| 85 | 101 | } |
| 86 | 102 | |
| 87 | - <?php echo '#acym_fulldiv_'.$form->form_tag_name.' '; ?>.acym__subscription__form__popup{ | |
| 103 | + #acym_fulldiv_<?php echo esc_html($form->form_tag_name); ?> .acym__subscription__form__popup{ | |
| 88 | 104 | position: fixed; |
| 89 | - <?php echo $positionCss; ?> padding: <?php echo $form->settings['style']['padding']['height']; ?>px <?php echo $form->settings['style']['padding']['width']; ?>px; | |
| 90 | - background-color: <?php echo $form->settings['style']['background_color']; ?>; | |
| 91 | - color: <?php echo $form->settings['style']['text_color']; ?> !important; | |
| 92 | - background-image: url("<?php echo $form->settings['style']['background_image']; ?>"); | |
| 93 | - background-size: <?php echo $form->settings['style']['background_size']; ?>; | |
| 94 | - background-position: <?php echo str_replace('_', ' ', $form->settings['style']['background_position']); ?>; | |
| 95 | - background-repeat: <?php echo $form->settings['style']['background_repeat']; ?>; | |
| 105 | + <?php echo esc_html($positionCss); ?> padding: <?php echo esc_html($form->settings['style']['padding']['height']); ?>px <?php echo esc_html($form->settings['style']['padding']['width']); ?>px; | |
| 106 | + background-color: <?php echo esc_html($form->settings['style']['background_color']); ?>; | |
| 107 | + color: <?php echo esc_html($form->settings['style']['text_color']); ?> !important; | |
| 108 | + background-image: url("<?php echo esc_url($form->settings['style']['background_image']); ?>"); | |
| 109 | + background-size: <?php echo esc_html($form->settings['style']['background_size']); ?>; | |
| 110 | + background-position: <?php echo esc_html(str_replace('_', ' ', $form->settings['style']['background_position'])); ?>; | |
| 111 | + background-repeat: <?php echo esc_html($form->settings['style']['background_repeat']); ?>; | |
| 96 | 112 | border-radius: <?php echo intval($form->settings['style']['border_radius'] ?? 0); ?>px; |
| 97 | - box-shadow: <?php echo intval($form->settings['style']['shadow_x'] ?? 0); ?>px <?php echo intval($form->settings['style']['shadow_y'] ?? 0); ?>px <?php echo intval($form->settings['style']['shadow_blur'] ?? 0); ?>px<?php echo $form->settings['style']['shadow_color'] ?? 'rgba(0,0,0,0.2)'; ?>; | |
| 113 | + box-shadow: <?php echo intval($form->settings['style']['shadow_x'] ?? 0); ?>px <?php echo intval($form->settings['style']['shadow_y'] ?? 0); ?>px <?php echo intval($form->settings['style']['shadow_blur'] ?? 0); ?>px<?php echo esc_html($form->settings['style']['shadow_color'] ?? 'rgba(0,0,0,0.2)'); ?>; | |
| 98 | 114 | z-index: 999999; |
| 99 | 115 | text-align: center; |
| 100 | 116 | display: flex; |
| 101 | 117 | justify-content: center; |
| @@ -101,56 +117,56 @@ | ||
| 101 | 117 | justify-content: center; |
| 102 | 118 | align-items: center; |
| 103 | 119 | } |
| 104 | 120 | |
| 105 | - <?php echo '#acym_fulldiv_'.$form->form_tag_name.' '; ?>.acym__subscription__form__popup .responseContainer{ | |
| 121 | + <?php echo '#acym_fulldiv_'.esc_html($form->form_tag_name).' '; ?>.acym__subscription__form__popup .responseContainer{ | |
| 106 | 122 | margin-bottom: 0 !important; |
| 107 | 123 | padding: .4rem !important; |
| 108 | 124 | } |
| 109 | 125 | |
| 110 | - <?php echo '#acym_fulldiv_'.$form->form_tag_name.' '; ?>.acym__subscription__form__popup <?php echo '#'.$form->form_tag_name; ?>{ | |
| 126 | + <?php echo '#acym_fulldiv_'.esc_html($form->form_tag_name).' '; ?>.acym__subscription__form__popup <?php echo '#'.esc_html($form->form_tag_name); ?>{ | |
| 111 | 127 | margin: 0; |
| 112 | 128 | } |
| 113 | 129 | |
| 114 | - <?php echo '#acym_fulldiv_'.$form->form_tag_name.' '; ?>.acym__subscription__form__popup .acym__subscription__form__fields, <?php echo '#acym_fulldiv_'.$form->form_tag_name.' '; ?>.acym__subscription__form__popup .acym__subscription__form__button{ | |
| 130 | + <?php echo '#acym_fulldiv_'.esc_html($form->form_tag_name).' '; ?>.acym__subscription__form__popup .acym__subscription__form__fields, <?php echo '#acym_fulldiv_'.esc_html($form->form_tag_name).' '; ?>.acym__subscription__form__popup .acym__subscription__form__button{ | |
| 115 | 131 | display: block; |
| 116 | 132 | width: 100%; |
| 117 | 133 | margin: 1rem 0 !important; |
| 118 | 134 | } |
| 119 | 135 | |
| 120 | - <?php echo '#acym_fulldiv_'.$form->form_tag_name.' '; ?>.acym__subscription__form__popup .acym__subscription__form__fields input:not([type="radio"]):not([type="checkbox"]), <?php echo '#acym_fulldiv_'.$form->form_tag_name.' '; ?>.acym__subscription__form__popup .acym__subscription__form__fields label{ | |
| 136 | + <?php echo '#acym_fulldiv_'.esc_html($form->form_tag_name).' '; ?>.acym__subscription__form__popup .acym__subscription__form__fields input:not([type="radio"]):not([type="checkbox"]), <?php echo '#acym_fulldiv_'.esc_html($form->form_tag_name).' '; ?>.acym__subscription__form__popup .acym__subscription__form__fields label{ | |
| 121 | 137 | display: block; |
| 122 | 138 | } |
| 123 | 139 | |
| 124 | - <?php echo '#acym_fulldiv_'.$form->form_tag_name.' '; ?>.acym__subscription__form__popup .acym__subscription__form__fields input[type="radio"], <?php echo '#acym_fulldiv_'.$form->form_tag_name.' '; ?>.acym__subscription__form__popup .acym__subscription__form__fields input[type="checkbox"]{ | |
| 140 | + <?php echo '#acym_fulldiv_'.esc_html($form->form_tag_name).' '; ?>.acym__subscription__form__popup .acym__subscription__form__fields input[type="radio"], <?php echo '#acym_fulldiv_'.esc_html($form->form_tag_name).' '; ?>.acym__subscription__form__popup .acym__subscription__form__fields input[type="checkbox"]{ | |
| 125 | 141 | margin-left: 5px; |
| 126 | 142 | } |
| 127 | 143 | |
| 128 | - <?php echo '#acym_fulldiv_'.$form->form_tag_name.' '; ?>.acym__subscription__form__popup .acym__subscription__form__fields .acym__subscription__form__lists{ | |
| 144 | + <?php echo '#acym_fulldiv_'.esc_html($form->form_tag_name).' '; ?>.acym__subscription__form__popup .acym__subscription__form__fields .acym__subscription__form__lists{ | |
| 129 | 145 | display: block; |
| 130 | 146 | width: 100%; |
| 131 | 147 | margin: 1rem 10px !important; |
| 132 | 148 | } |
| 133 | 149 | |
| 134 | - <?php echo '#acym_fulldiv_'.$form->form_tag_name.' '; ?>.acym__subscription__form__popup .acym__subscription__form__fields .acym__user__edit__email{ | |
| 150 | + <?php echo '#acym_fulldiv_'.esc_html($form->form_tag_name).' '; ?>.acym__subscription__form__popup .acym__subscription__form__fields .acym__user__edit__email{ | |
| 135 | 151 | margin: auto; |
| 136 | 152 | } |
| 137 | 153 | |
| 138 | 154 | <?php if (!empty($form->settings['message']['color'])) { ?> |
| 139 | - <?php echo '#acym_fulldiv_'.$form->form_tag_name.' '; ?>#acym__subscription__form__popup-text{ | |
| 140 | - color: <?php echo $form->settings['message']['color']; ?>; | |
| 155 | + <?php echo '#acym_fulldiv_'.esc_html($form->form_tag_name).' '; ?>#acym__subscription__form__popup-text{ | |
| 156 | + color: <?php echo esc_html($form->settings['message']['color']); ?>; | |
| 141 | 157 | } |
| 142 | 158 | |
| 143 | 159 | <?php } ?> |
| 144 | 160 | |
| 145 | 161 | <?php if (in_array($form->settings['style']['position'], ['image-right', 'image-left'])) { ?> |
| 146 | - <?php echo '#acym_fulldiv_'.$form->form_tag_name.' '; ?>.acym__subscription__form__popup <?php echo '#'.$form->form_tag_name; ?>{ | |
| 162 | + <?php echo '#acym_fulldiv_'.esc_html($form->form_tag_name).' '; ?>.acym__subscription__form__popup <?php echo '#'.esc_html($form->form_tag_name); ?>{ | |
| 147 | 163 | display: flex; |
| 148 | 164 | justify-content: center; |
| 149 | 165 | align-items: center |
| 150 | 166 | } |
| 151 | 167 | |
| 152 | - <?php echo '#acym_fulldiv_'.$form->form_tag_name.' '; ?>.acym__subscription__form__popup__fields-button, <?php echo '#acym_fulldiv_'.$form->form_tag_name.' '; ?>.acym__subscription__form__image{ | |
| 168 | + <?php echo '#acym_fulldiv_'.esc_html($form->form_tag_name).' '; ?>.acym__subscription__form__popup__fields-button, <?php echo '#acym_fulldiv_'.esc_html($form->form_tag_name).' '; ?>.acym__subscription__form__image{ | |
| 153 | 169 | display: inline-block; |
| 154 | 170 | } |
| 155 | 171 | |
| 156 | 172 | <?php } ?> |
| @@ -157,19 +173,19 @@ | ||
| 157 | 173 | |
| 158 | 174 | </style> |
| 159 | 175 | <?php if (!$edition) { ?> |
| 160 | 176 | <script type="text/javascript"> |
| 161 | - const acymBackupFormTimeout<?php echo $form->form_tag_name; ?> = setTimeout(() => { | |
| 162 | - acym_initPopupDisplay<?php echo $form->form_tag_name; ?>(true); | |
| 177 | + const acymBackupFormTimeout<?php echo esc_html($form->form_tag_name); ?> = setTimeout(() => { | |
| 178 | + acym_initPopupDisplay<?php echo esc_html($form->form_tag_name); ?>(true); | |
| 163 | 179 | }, 1000); |
| 164 | 180 | |
| 165 | 181 | window.addEventListener('DOMContentLoaded', function () { |
| 166 | - clearTimeout(acymBackupFormTimeout<?php echo $form->form_tag_name; ?>); | |
| 167 | - acym_initPopupDisplay<?php echo $form->form_tag_name; ?>(); | |
| 182 | + clearTimeout(acymBackupFormTimeout<?php echo esc_html($form->form_tag_name); ?>); | |
| 183 | + acym_initPopupDisplay<?php echo esc_html($form->form_tag_name); ?>(); | |
| 168 | 184 | }); |
| 169 | 185 | |
| 170 | - function acym_initPopupDisplay<?php echo $form->form_tag_name; ?>(addedDelayForBackup = false) { | |
| 171 | - const acym_popupForm = document.querySelector('#acym_fulldiv_<?php echo $form->form_tag_name; ?>.acym__subscription__form__popup__overlay'); | |
| 186 | + function acym_initPopupDisplay<?php echo esc_html($form->form_tag_name); ?>(addedDelayForBackup = false) { | |
| 187 | + const acym_popupForm = document.querySelector('#acym_fulldiv_<?php echo esc_html($form->form_tag_name); ?>.acym__subscription__form__popup__overlay'); | |
| 172 | 188 | |
| 173 | 189 | if (!acym_popupForm) { |
| 174 | 190 | return; |
| 175 | 191 | } |
| @@ -174,12 +190,62 @@ | ||
| 174 | 190 | return; |
| 175 | 191 | } |
| 176 | 192 | |
| 177 | 193 | const isDisplayButton = <?php echo $isButton ? 'true' : 'false'; ?>; |
| 194 | + let acymLastFocusedElement = null; | |
| 178 | 195 | |
| 179 | - function acym_closePopupform<?php echo $form->form_tag_name; ?>(element) { | |
| 196 | + function acymGetFocusableElements() { | |
| 197 | + return acym_popupForm.querySelectorAll( | |
| 198 | + 'button, [href], input:not([type="hidden"]), select, textarea, [tabindex]:not([tabindex="-1"])' | |
| 199 | + ); | |
| 200 | + } | |
| 201 | + | |
| 202 | + function acymPopupKeydown(event) { | |
| 203 | + if (event.key === 'Escape' || event.key === 'Esc') { | |
| 204 | + acym_closePopupform<?php echo esc_html($form->form_tag_name); ?>(acym_popupForm); | |
| 205 | + return; | |
| 206 | + } | |
| 207 | + | |
| 208 | + if (event.key !== 'Tab') { | |
| 209 | + return; | |
| 210 | + } | |
| 211 | + | |
| 212 | + const focusable = acymGetFocusableElements(); | |
| 213 | + if (focusable.length === 0) { | |
| 214 | + return; | |
| 215 | + } | |
| 216 | + | |
| 217 | + const first = focusable[0]; | |
| 218 | + const last = focusable[focusable.length - 1]; | |
| 219 | + | |
| 220 | + if (event.shiftKey && document.activeElement === first) { | |
| 221 | + event.preventDefault(); | |
| 222 | + last.focus(); | |
| 223 | + } else if (!event.shiftKey && document.activeElement === last) { | |
| 224 | + event.preventDefault(); | |
| 225 | + first.focus(); | |
| 226 | + } | |
| 227 | + } | |
| 228 | + | |
| 229 | + function acym_openPopupform<?php echo esc_html($form->form_tag_name); ?>() { | |
| 230 | + acymLastFocusedElement = document.activeElement; | |
| 231 | + acym_popupForm.style.display = 'inline'; | |
| 232 | + acym_popupForm.addEventListener('keydown', acymPopupKeydown); | |
| 233 | + | |
| 234 | + const focusable = acymGetFocusableElements(); | |
| 235 | + if (focusable.length > 0) { | |
| 236 | + focusable[0].focus(); | |
| 237 | + } | |
| 238 | + } | |
| 239 | + | |
| 240 | + function acym_closePopupform<?php echo esc_html($form->form_tag_name); ?>(element) { | |
| 180 | 241 | element.style.display = 'none'; |
| 242 | + acym_popupForm.removeEventListener('keydown', acymPopupKeydown); | |
| 181 | 243 | |
| 244 | + if (acymLastFocusedElement && typeof acymLastFocusedElement.focus === 'function') { | |
| 245 | + acymLastFocusedElement.focus(); | |
| 246 | + } | |
| 247 | + | |
| 182 | 248 | if (isDisplayButton) { |
| 183 | 249 | return; |
| 184 | 250 | } |
| 185 | 251 | |
| @@ -184,22 +250,23 @@ | ||
| 184 | 250 | } |
| 185 | 251 | |
| 186 | 252 | let expirationDate = new Date(); |
| 187 | 253 | expirationDate.setDate(expirationDate.getDate() + <?php echo empty($form->settings['cookie']['cookie_expiration']) ? 1 |
| 188 | - : $form->settings['cookie']['cookie_expiration']; ?>); | |
| 189 | - document.cookie = 'acym_form_<?php echo $form->id; ?>=' + Date.now() + ';expires=' + expirationDate.toUTCString() + ';path=/'; | |
| 254 | + : intval($form->settings['cookie']['cookie_expiration']); ?>); | |
| 255 | + document.cookie = 'acym_form_<?php echo esc_html($form->id); ?>=' + Date.now() + ';expires=' + expirationDate.toUTCString() + ';path=/'; | |
| 190 | 256 | } |
| 191 | 257 | |
| 192 | 258 | <?php if ($popupPosition === 'center') { ?> |
| 193 | 259 | acym_popupForm.addEventListener('click', function (event) { |
| 194 | 260 | if (event.target.closest('.acym__subscription__form__popup') === null) { |
| 195 | - acym_closePopupform<?php echo $form->form_tag_name; ?>(this); | |
| 261 | + acym_closePopupform<?php echo esc_html($form->form_tag_name); ?>(this); | |
| 196 | 262 | } |
| 197 | 263 | }); |
| 198 | 264 | <?php } ?> |
| 199 | - document.querySelector('#acym_fulldiv_<?php echo $form->form_tag_name; ?> .acym__subscription__form__popup__close').addEventListener('click', function (event) { | |
| 200 | - acym_closePopupform<?php echo $form->form_tag_name; ?>(event.target.closest('.acym__subscription__form__popup__overlay')); | |
| 201 | - }); | |
| 265 | + document.querySelector('#acym_fulldiv_<?php echo esc_html($form->form_tag_name); ?> .acym__subscription__form__popup__close') | |
| 266 | + .addEventListener('click', function (event) { | |
| 267 | + acym_closePopupform<?php echo esc_html($form->form_tag_name); ?>(event.target.closest('.acym__subscription__form__popup__overlay')); | |
| 268 | + }); | |
| 202 | 269 | |
| 203 | 270 | if (isDisplayButton) { |
| 204 | 271 | displayByButton(); |
| 205 | 272 | } else { |
| @@ -206,23 +273,23 @@ | ||
| 206 | 273 | displayByDelayAndScroll(); |
| 207 | 274 | } |
| 208 | 275 | |
| 209 | 276 | function displayByButton() { |
| 210 | - const button = document.querySelector('#<?php echo $form->settings['display']['button']; ?>'); | |
| 277 | + const button = document.querySelector('#<?php echo esc_html($form->settings['display']['button']); ?>'); | |
| 211 | 278 | |
| 212 | 279 | if (!button) { |
| 213 | - console.error('Could not find the button with the ID <?php echo $form->settings['display']['button']; ?>'); | |
| 280 | + console.error('Could not find the button with the ID <?php echo esc_html($form->settings['display']['button']); ?>'); | |
| 214 | 281 | return; |
| 215 | 282 | } |
| 216 | 283 | |
| 217 | 284 | button.addEventListener('click', function () { |
| 218 | - acym_popupForm.style.display = 'inline'; | |
| 285 | + acym_openPopupform<?php echo esc_html($form->form_tag_name); ?>(); | |
| 219 | 286 | }); |
| 220 | 287 | } |
| 221 | 288 | |
| 222 | 289 | function displayByDelayAndScroll() { |
| 223 | - const delayDisplay = parseInt(<?php echo $form->settings['display']['delay']; ?>); | |
| 224 | - const scrollPercentLimit = parseInt(<?php echo $form->settings['display']['scroll']; ?>); | |
| 290 | + const delayDisplay = parseInt(<?php echo esc_html($form->settings['display']['delay']); ?>); | |
| 291 | + const scrollPercentLimit = parseInt(<?php echo esc_html($form->settings['display']['scroll']); ?>); | |
| 225 | 292 | let windowSize; |
| 226 | 293 | let browserHeight; |
| 227 | 294 | let delayRemaining = false; |
| 228 | 295 | |
| @@ -237,19 +304,25 @@ | ||
| 237 | 304 | |
| 238 | 305 | windowSize = document.getElementsByTagName('body')[0].clientHeight; |
| 239 | 306 | browserHeight = document.documentElement.clientHeight; |
| 240 | 307 | |
| 241 | - if (!delayRemaining && (windowSize <= browserHeight || !scrollRemaining)) { | |
| 308 | + if (!delayRemaining && ( | |
| 309 | + windowSize <= browserHeight || !scrollRemaining | |
| 310 | + )) { | |
| 242 | 311 | scrollRemaining = false; |
| 243 | - acym_popupForm.style.display = 'inline'; | |
| 312 | + acym_openPopupform<?php echo esc_html($form->form_tag_name); ?>(); | |
| 244 | 313 | } else { |
| 245 | 314 | function displayAcymPopupForm() { |
| 246 | - let scrollPercent = Math.round((window.scrollY) / (windowSize - browserHeight) * 100); | |
| 315 | + let scrollPercent = Math.round(( | |
| 316 | + window.scrollY | |
| 317 | + ) / ( | |
| 318 | + windowSize - browserHeight | |
| 319 | + ) * 100); | |
| 247 | 320 | if (scrollPercent >= scrollPercentLimit) { |
| 248 | 321 | scrollRemaining = false; |
| 249 | 322 | window.removeEventListener('scroll', displayAcymPopupForm); |
| 250 | 323 | if (!delayRemaining && acym_popupForm) { |
| 251 | - acym_popupForm.style.display = 'inline'; | |
| 324 | + acym_openPopupform<?php echo esc_html($form->form_tag_name); ?>(); | |
| 252 | 325 | } |
| 253 | 326 | } |
| 254 | 327 | } |
| 255 | 328 | |
| @@ -263,9 +336,9 @@ | ||
| 263 | 336 | setTimeout(function () { |
| 264 | 337 | if (acym_popupForm !== null) { |
| 265 | 338 | delayRemaining = false; |
| 266 | 339 | if (!scrollRemaining) { |
| 267 | - acym_popupForm.style.display = 'inline'; | |
| 340 | + acym_openPopupform<?php echo esc_html($form->form_tag_name); ?>(); | |
| 268 | 341 | window.removeEventListener('scroll', displayAcymPopupForm); |
| 269 | 342 | } |
| 270 | 343 | } |
| 271 | 344 | }, delayInMs); |