| @@ -1,16 +1,43 @@ | ||
| 1 | 1 | <?php |
| 2 | -$termsURL = acym_getArticleURL( | |
| 3 | - $form->settings['termspolicy']['termscond'], | |
| 4 | - 0, | |
| 5 | - 'ACYM_TERMS_CONDITIONS' | |
| 6 | -); | |
| 7 | -$privacyURL = acym_getArticleURL( | |
| 8 | - $form->settings['termspolicy']['privacy'], | |
| 9 | - 0, | |
| 10 | - 'ACYM_PRIVACY_POLICY' | |
| 11 | -); | |
| 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'); | |
| 12 | 4 | |
| 5 | +use AcyMailing\Helpers\SecurityHelper; | |
| 6 | + | |
| 7 | +$termspolicy = $form->settings['termspolicy'] ?? []; | |
| 8 | + | |
| 9 | +if (empty($termspolicy['privacy_type']) || $termspolicy['privacy_type'] === 'article') { | |
| 10 | + $privacyURL = acym_getArticleURL((int)($termspolicy['privacy'] ?? 0), false, 'ACYM_PRIVACY_POLICY'); | |
| 11 | +} elseif ($termspolicy['privacy_type'] === 'url') { | |
| 12 | + $privacyURL = $termspolicy['privacy_url'] ?? ''; | |
| 13 | +} else { | |
| 14 | + $privacyURL = ''; | |
| 15 | +} | |
| 16 | + | |
| 17 | +if (empty($termspolicy['terms_type']) || $termspolicy['terms_type'] === 'article') { | |
| 18 | + $termsURL = acym_getArticleURL((int)($termspolicy['termscond'] ?? 0), false, 'ACYM_TERMS_CONDITIONS'); | |
| 19 | +} elseif ($termspolicy['terms_type'] === 'url') { | |
| 20 | + $termsURL = $termspolicy['terms_url'] ?? ''; | |
| 21 | +} else { | |
| 22 | + $termsURL = ''; | |
| 23 | +} | |
| 24 | + | |
| 25 | +if (!empty($termspolicy['privacy_type']) && $termspolicy['privacy_type'] === 'url' && !empty($privacyURL)) { | |
| 26 | + $privacyLabel = acym_translation('ACYM_PRIVACY_POLICY'); | |
| 27 | + $privacyURL = '<a href="'.esc_url($privacyURL).'" target="_blank" rel="noopener noreferrer" aria-label="'.esc_attr( | |
| 28 | + $privacyLabel.', '.acym_translation('ACYM_OPENS_NEW_WINDOW') | |
| 29 | + ).'">'.esc_html($privacyLabel).'</a>'; | |
| 30 | +} | |
| 31 | + | |
| 32 | +if (!empty($termspolicy['terms_type']) && $termspolicy['terms_type'] === 'url' && !empty($termsURL)) { | |
| 33 | + $termsLabel = acym_translation('ACYM_TERMS_CONDITIONS'); | |
| 34 | + $termsURL = '<a href="'.esc_url($termsURL).'" target="_blank" rel="noopener noreferrer" aria-label="'.esc_attr( | |
| 35 | + $termsLabel.', '.acym_translation('ACYM_OPENS_NEW_WINDOW') | |
| 36 | + ).'">'.esc_html($termsLabel).'</a>'; | |
| 37 | +} | |
| 38 | + | |
| 39 | + | |
| 13 | 40 | if (empty($termsURL) && empty($privacyURL)) { |
| 14 | 41 | $termslink = ''; |
| 15 | 42 | } elseif (empty($privacyURL)) { |
| 16 | 43 | $termslink = acym_translationSprintf('ACYM_I_AGREE_TERMS', $termsURL); |
| @@ -21,11 +48,17 @@ | ||
| 21 | 48 | } |
| 22 | 49 | |
| 23 | 50 | if (!empty($termslink)) { |
| 24 | 51 | echo '<div class="acym__subscription__form__termscond">'; |
| 25 | - echo '<div class="onefield fieldacyterms" id="field_terms_'.$form->form_tag_name.'">'; | |
| 26 | - echo '<label for="mailingdata_terms_'.$form->form_tag_name.'">'; | |
| 27 | - echo '<input id="mailingdata_terms_'.$form->form_tag_name.'" class="checkbox" type="checkbox" name="terms" title="'.acym_translation('ACYM_TERMS_CONDITIONS').'"/> '.$termslink; | |
| 52 | + echo '<div class="onefield fieldacyterms" id="field_terms_'.esc_attr($form->form_tag_name).'">'; | |
| 53 | + echo '<label for="mailingdata_terms_'.esc_attr($form->form_tag_name).'">'; | |
| 54 | + echo '<input id="mailingdata_terms_'.esc_attr($form->form_tag_name).'" class="checkbox" type="checkbox" name="terms" aria-required="true" title="'.esc_attr( | |
| 55 | + acym_translation('ACYM_TERMS_CONDITIONS') | |
| 56 | + ).'"/> '; | |
| 57 | + echo wp_kses( | |
| 58 | + $termslink, | |
| 59 | + SecurityHelper::ALLOWED_HTML_TERMS | |
| 60 | + ); | |
| 28 | 61 | echo '</label>'; |
| 29 | 62 | echo '</div>'; |
| 30 | 63 | ?> |
| 31 | 64 | |
| @@ -34,9 +67,9 @@ | ||
| 34 | 67 | .acym__subscription__form__footer .acym__subscription__form__termscond{ |
| 35 | 68 | max-width: 250px; |
| 36 | 69 | } |
| 37 | 70 | |
| 38 | - <?php echo '#acym_fulldiv_'.$form->form_tag_name.' '; ?>.acym__subscription__form__fields .acym__subscription__form__termscond input[type="checkbox"]{ | |
| 71 | + <?php echo '#acym_fulldiv_'.esc_html($form->form_tag_name).' '; ?>.acym__subscription__form__fields .acym__subscription__form__termscond input[type="checkbox"]{ | |
| 39 | 72 | margin-top: 0 !important; |
| 40 | 73 | } |
| 41 | 74 | </style> |
| 42 | 75 | </div> |