| 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 |
/** |
| 23 |
* Initialize the properties based on block attributes. |
| 24 |
* |
| 25 |
* @param array<mixed> $attributes Block attributes. |
| 26 |
* @since 0.0.2 |
| 27 |
*/ |
| 28 |
public function __construct( $attributes ) { |
| 29 |
$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' ) ); |
| 31 |
$this->set_error_msg( $attributes, 'srfm_gdpr_block_required_text' ); |
| 32 |
$this->slug = 'gdpr'; |
| 33 |
$this->required = true; |
| 34 |
$this->aria_require_attr = 'true'; |
| 35 |
$this->set_markup_properties(); |
| 36 |
$this->set_aria_described_by(); |
| 37 |
} |
| 38 |
|
| 39 |
/** |
| 40 |
* Render the sureforms GDPR classic styling |
| 41 |
* |
| 42 |
* @since 0.0.2 |
| 43 |
* @return string|boolean |
| 44 |
*/ |
| 45 |
public function markup() { |
| 46 |
$label_random_id = 'srfm-' . $this->slug . '-' . wp_rand(); |
| 47 |
ob_start(); ?> |
| 48 |
<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 ); ?>"> |
| 49 |
<div class="srfm-block-wrap"> |
| 50 |
<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 ); ?>" |
| 51 |
<?php echo ! empty( $this->aria_described_by ) ? "aria-describedby='" . esc_attr( trim( $this->aria_described_by ) ) . "'" : ''; ?> |
| 52 |
aria-required="<?php echo esc_attr( $this->aria_require_attr ); ?>" type="checkbox" <?php echo esc_attr( $this->checked_attr ); ?>/> |
| 53 |
<label class="srfm-cbx" for="<?php echo esc_attr( $label_random_id ); ?>"> |
| 54 |
<span class="srfm-span-wrap"> |
| 55 |
<svg class="srfm-check-icon" width="12px" height="10px"> |
| 56 |
<use xlink:href="#srfm-<?php echo esc_attr( $this->slug ); ?>-<?php echo esc_attr( $this->block_id ); ?>-check"></use> |
| 57 |
</svg> |
| 58 |
</span> |
| 59 |
<span class="srfm-span-wrap srfm-block-label"><?php echo wp_kses( $this->label, $this->allowed_tags ); ?> |
| 60 |
<span class="srfm-required"> *</span></span> |
| 61 |
</label> |
| 62 |
<svg class="srfm-inline-svg"> |
| 63 |
<symbol id="srfm-<?php echo esc_attr( $this->slug ); ?>-<?php echo esc_attr( $this->block_id ); ?>-check" viewbox="0 0 12 10"> |
| 64 |
<polyline points="1.5 6 4.5 9 10.5 1"></polyline> |
| 65 |
</symbol> |
| 66 |
</svg> |
| 67 |
</div> |
| 68 |
<?php echo wp_kses_post( $this->help_markup ); ?> |
| 69 |
<div class="srfm-error-wrap"> |
| 70 |
<?php echo wp_kses_post( $this->error_msg_markup ); ?> |
| 71 |
</div> |
| 72 |
</div> |
| 73 |
<?php |
| 74 |
return ob_get_clean(); |
| 75 |
} |
| 76 |
} |
| 77 |
|