address-markup.php
1 month ago
base.php
2 months ago
checkbox-markup.php
1 year ago
countries.json
1 year ago
dropdown-markup.php
1 month ago
email-markup.php
2 months ago
gdpr-markup.php
4 months ago
inlinebutton-markup.php
3 weeks ago
input-markup.php
4 months ago
multichoice-markup.php
1 month ago
number-markup.php
4 months ago
payment-markup.php
2 months ago
phone-markup.php
1 month ago
textarea-markup.php
1 month ago
url-markup.php
4 months ago
gdpr-markup.php
96 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Sureforms GDPR Markup Class file. |
| 4 | * |
| 5 | * @package sureforms. |
| 6 | * @since 0.0.2 |
| 7 | */ |
| 8 | |
| 9 | namespace SRFM\Inc\Fields; |
| 10 | |
| 11 | if ( ! defined( 'ABSPATH' ) ) { |
| 12 | exit; // Exit if accessed directly. |
| 13 | } |
| 14 | |
| 15 | /** |
| 16 | * Sureforms GDPR Markup Class. |
| 17 | * |
| 18 | * @since 0.0.2 |
| 19 | */ |
| 20 | class GDPR_Markup extends Base { |
| 21 | /** |
| 22 | * Initialize the properties based on block attributes. |
| 23 | * |
| 24 | * @param array<mixed> $attributes Block attributes. |
| 25 | * @since 0.0.2 |
| 26 | */ |
| 27 | public function __construct( $attributes ) { |
| 28 | $this->set_properties( $attributes ); |
| 29 | $this->set_input_label( __( 'I consent to have this website store my information so they can respond to my inquiry.', 'sureforms' ) ); |
| 30 | $this->set_error_msg( $attributes, 'srfm_gdpr_block_required_text' ); |
| 31 | $this->slug = 'gdpr'; |
| 32 | $this->required = true; |
| 33 | $this->data_require_attr = 'true'; |
| 34 | $this->set_markup_properties(); |
| 35 | $this->set_aria_described_by(); |
| 36 | |
| 37 | // Translate the default GDPR consent text for frontend display. |
| 38 | // Match both old ("submitted information") and new ("information") default strings for backward compatibility. |
| 39 | if ( 'I consent to have this website store my information so they can respond to my inquiry.' === $this->label |
| 40 | || 'I consent to have this website store my submitted information so they can respond to my inquiry.' === $this->label |
| 41 | ) { |
| 42 | $this->label = __( 'I consent to have this website store my information so they can respond to my inquiry.', 'sureforms' ); |
| 43 | } |
| 44 | } |
| 45 | |
| 46 | /** |
| 47 | * Render the sureforms GDPR classic styling |
| 48 | * |
| 49 | * @since 0.0.2 |
| 50 | * @return string|bool |
| 51 | */ |
| 52 | public function markup() { |
| 53 | $label_random_id = 'srfm-' . $this->slug . '-' . wp_rand(); |
| 54 | ob_start(); ?> |
| 55 | <div data-block-id="<?php echo esc_attr( $this->block_id ); ?>" class="srfm-block-single srfm-block srfm-<?php echo esc_attr( $this->slug ); ?>-block srf-<?php echo esc_attr( $this->slug ); ?>-<?php echo esc_attr( $this->block_id ); ?>-block<?php echo esc_attr( $this->block_width ); ?><?php echo esc_attr( $this->class_name ); ?> <?php echo esc_attr( $this->conditional_class ); ?>"> |
| 56 | <div class="srfm-block-wrap"> |
| 57 | <input class="srfm-input-common screen-reader-text srfm-input-<?php echo esc_attr( $this->slug ); ?>" id="<?php echo esc_attr( $label_random_id ); ?>" name="srfm-<?php echo esc_attr( $this->slug ); ?>-<?php echo esc_attr( $this->block_id ); ?><?php echo esc_attr( $this->field_name ); ?>" |
| 58 | <?php echo ! empty( $this->aria_described_by ) ? "aria-describedby='" . esc_attr( trim( $this->aria_described_by ) ) . "'" : ''; ?> |
| 59 | data-required="<?php echo esc_attr( $this->data_require_attr ); ?>" aria-required="<?php echo esc_attr( $this->data_require_attr ); ?>" type="checkbox" <?php echo esc_attr( $this->checked_attr ); ?>/> |
| 60 | <label class="srfm-cbx" for="<?php echo esc_attr( $label_random_id ); ?>"> |
| 61 | <span class="srfm-span-wrap"> |
| 62 | <svg class="srfm-check-icon" width="12px" height="10px" aria-hidden="true"> |
| 63 | <use xlink:href="#srfm-<?php echo esc_attr( $this->slug ); ?>-<?php echo esc_attr( $this->block_id ); ?>-check"></use> |
| 64 | </svg> |
| 65 | </span> |
| 66 | <span class="srfm-span-wrap srfm-block-label"><?php echo wp_kses( $this->label, $this->allowed_tags ); ?> |
| 67 | <span class="srfm-required" aria-hidden="true"> *</span> |
| 68 | </span> |
| 69 | </label> |
| 70 | <svg class="srfm-inline-svg" aria-hidden="true"> |
| 71 | <symbol id="srfm-<?php echo esc_attr( $this->slug ); ?>-<?php echo esc_attr( $this->block_id ); ?>-check" viewbox="0 0 12 10"> |
| 72 | <polyline points="1.5 6 4.5 9 10.5 1"></polyline> |
| 73 | </symbol> |
| 74 | </svg> |
| 75 | </div> |
| 76 | <?php echo wp_kses_post( $this->help_markup ); ?> |
| 77 | <div class="srfm-error-wrap"> |
| 78 | <?php echo wp_kses_post( $this->error_msg_markup ); ?> |
| 79 | </div> |
| 80 | </div> |
| 81 | <?php |
| 82 | $markup = ob_get_clean(); |
| 83 | |
| 84 | return apply_filters( |
| 85 | 'srfm_block_field_markup', |
| 86 | $markup, |
| 87 | [ |
| 88 | 'slug' => $this->slug, |
| 89 | 'field_name' => $this->field_name, |
| 90 | 'is_editing' => $this->is_editing, |
| 91 | 'attributes' => $this->attributes, |
| 92 | ] |
| 93 | ); |
| 94 | } |
| 95 | } |
| 96 |