| @@ -17,9 +17,8 @@ | ||
| 17 | 17 | * |
| 18 | 18 | * @since 0.0.2 |
| 19 | 19 | */ |
| 20 | 20 | class GDPR_Markup extends Base { |
| 21 | - | |
| 22 | 21 | /** |
| 23 | 22 | * Initialize the properties based on block attributes. |
| 24 | 23 | * |
| 25 | 24 | * @param array<mixed> $attributes Block attributes. |
| @@ -26,16 +25,23 @@ | ||
| 26 | 25 | * @since 0.0.2 |
| 27 | 26 | */ |
| 28 | 27 | public function __construct( $attributes ) { |
| 29 | 28 | $this->set_properties( $attributes ); |
| 30 | - $this->set_input_label( __( 'I consent to have this website store my submitted information so they can respond to my inquiry.', 'sureforms' ) ); | |
| 29 | + $this->set_input_label( __( 'I consent to have this website store my information so they can respond to my inquiry.', 'sureforms' ) ); | |
| 31 | 30 | $this->set_error_msg( $attributes, 'srfm_gdpr_block_required_text' ); |
| 32 | 31 | $this->slug = 'gdpr'; |
| 33 | - $this->help = isset( $attributes['gdprHelpText'] ) ? $attributes['gdprHelpText'] : ''; | |
| 34 | 32 | $this->required = true; |
| 35 | - $this->aria_require_attr = 'true'; | |
| 33 | + $this->data_require_attr = 'true'; | |
| 36 | 34 | $this->set_markup_properties(); |
| 37 | 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 | + } | |
| 38 | 44 | } |
| 39 | 45 | |
| 40 | 46 | /** |
| 41 | 47 | * Render the sureforms GDPR classic styling |
| @@ -40,9 +46,9 @@ | ||
| 40 | 46 | /** |
| 41 | 47 | * Render the sureforms GDPR classic styling |
| 42 | 48 | * |
| 43 | 49 | * @since 0.0.2 |
| 44 | - * @return string|boolean | |
| 50 | + * @return string|bool | |
| 45 | 51 | */ |
| 46 | 52 | public function markup() { |
| 47 | 53 | $label_random_id = 'srfm-' . $this->slug . '-' . wp_rand(); |
| 48 | 54 | ob_start(); ?> |
| @@ -49,19 +55,20 @@ | ||
| 49 | 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 ); ?>"> |
| 50 | 56 | <div class="srfm-block-wrap"> |
| 51 | 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 ); ?>" |
| 52 | 58 | <?php echo ! empty( $this->aria_described_by ) ? "aria-describedby='" . esc_attr( trim( $this->aria_described_by ) ) . "'" : ''; ?> |
| 53 | - aria-required="<?php echo esc_attr( $this->aria_require_attr ); ?>" type="checkbox" <?php echo esc_attr( $this->checked_attr ); ?>/> | |
| 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 ); ?>/> | |
| 54 | 60 | <label class="srfm-cbx" for="<?php echo esc_attr( $label_random_id ); ?>"> |
| 55 | 61 | <span class="srfm-span-wrap"> |
| 56 | - <svg class="srfm-check-icon" width="12px" height="10px"> | |
| 62 | + <svg class="srfm-check-icon" width="12px" height="10px" aria-hidden="true"> | |
| 57 | 63 | <use xlink:href="#srfm-<?php echo esc_attr( $this->slug ); ?>-<?php echo esc_attr( $this->block_id ); ?>-check"></use> |
| 58 | 64 | </svg> |
| 59 | 65 | </span> |
| 60 | 66 | <span class="srfm-span-wrap srfm-block-label"><?php echo wp_kses( $this->label, $this->allowed_tags ); ?> |
| 61 | - <span class="srfm-required"> *</span></span> | |
| 67 | + <span class="srfm-required" aria-hidden="true"> *</span> | |
| 68 | + </span> | |
| 62 | 69 | </label> |
| 63 | - <svg class="srfm-inline-svg"> | |
| 70 | + <svg class="srfm-inline-svg" aria-hidden="true"> | |
| 64 | 71 | <symbol id="srfm-<?php echo esc_attr( $this->slug ); ?>-<?php echo esc_attr( $this->block_id ); ?>-check" viewbox="0 0 12 10"> |
| 65 | 72 | <polyline points="1.5 6 4.5 9 10.5 1"></polyline> |
| 66 | 73 | </symbol> |
| 67 | 74 | </svg> |
| @@ -71,7 +78,18 @@ | ||
| 71 | 78 | <?php echo wp_kses_post( $this->error_msg_markup ); ?> |
| 72 | 79 | </div> |
| 73 | 80 | </div> |
| 74 | 81 | <?php |
| 75 | - return ob_get_clean(); | |
| 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 | + ); | |
| 76 | 94 | } |
| 77 | 95 | } |