PluginProbe
SureForms – Contact Form Builder, AI Forms, Payment Form, Survey & Quiz / 0.0.13
SureForms – Contact Form Builder, AI Forms, Payment Form, Survey & Quiz v0.0.13
2.12.7 2.12.6 2.12.5 2.12.4 2.12.3 2.12.2 2.12.1 2.12.0 2.11.1 2.11.0 2.10.1 2.10.0 2.9.1 2.9.0 2.8.2 2.8.1 2.7.0 2.7.1 2.8.0 trunk 0.0.10 0.0.11 0.0.12 0.0.13 0.0.2 All 97 releases
sureforms / inc / fields / email-markup.php

email-markup.php in SureForms – Contact Form Builder, AI Forms, Payment Form, Survey & Quiz 0.0.13, at inc/fields/email-markup.php

141 lines 5.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Sureforms Email Markup Class file.
4 *
5 * @package sureforms.
6 * @since 0.0.1
7 */
8
9 namespace SRFM\Inc\Fields;
10
11 use SRFM\Inc\Helper;
12
13 if ( ! defined( 'ABSPATH' ) ) {
14 exit; // Exit if accessed directly.
15 }
16
17 /**
18 * SureForms Email Markup Class.
19 *
20 * @since 0.0.1
21 */
22 class Email_Markup extends Base {
23
24 /**
25 * Flag indicating whether email confirmation is required.
26 *
27 * @var bool
28 * @since 0.0.2
29 */
30 protected $is_confirm_email;
31
32 /**
33 * Fallback label for the confirmation input field.
34 *
35 * @var string
36 * @since 0.0.2
37 */
38 protected $input_confirm_label_fallback;
39
40 /**
41 * Encrypted label for the confirmation input field.
42 *
43 * @var string
44 * @since 0.0.2
45 */
46 protected $input_confirm_label;
47
48 /**
49 * Unique slug for the confirmation input field, combining the form slug, block ID, and encrypted label.
50 *
51 * @var string
52 * @since 0.0.2
53 */
54 protected $unique_confirm_slug;
55
56 /**
57 * Retains a copy of Confirmation Email input label.
58 *
59 * @var string
60 * @since 0.0.7
61 */
62 protected $confirm_label;
63
64 /**
65 * Initialize the properties based on block attributes.
66 *
67 * @param array<mixed> $attributes Block attributes.
68 * @since 0.0.2
69 */
70 public function __construct( $attributes ) {
71 $this->set_properties( $attributes );
72 $this->set_input_label( __( 'Email', 'sureforms' ) );
73 $this->set_error_msg( $attributes, 'srfm_email_block_required_text' );
74 $this->set_duplicate_msg( $attributes, 'srfm_email_block_unique_text' );
75 $this->slug = 'email';
76 $this->is_confirm_email = isset( $attributes['isConfirmEmail'] ) ? $attributes['isConfirmEmail'] : false;
77 $this->input_confirm_label_fallback = __( 'Confirm ', 'sureforms' ) . $this->input_label_fallback;
78 $this->input_confirm_label = '-lbl-' . Helper::encrypt( $this->input_confirm_label_fallback );
79 $this->unique_confirm_slug = 'srfm-' . $this->slug . '-confirm-' . $this->block_id . $this->input_confirm_label;
80 $this->set_unique_slug();
81 $this->set_field_name( $this->unique_slug );
82 $this->set_markup_properties( $this->input_label, true );
83 $this->set_aria_described_by();
84 // Translators: %s is label of block.
85 $this->confirm_label = sprintf( __( 'Confirm %s', 'sureforms' ), $this->label );
86 $this->set_label_as_placeholder( $this->input_label );
87 }
88
89 /**
90 * Render the sureforms email classic styling
91 *
92 * @since 0.0.2
93 * @return string|boolean
94 */
95 public function markup() {
96 ob_start(); ?>
97 <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-wrap<?php echo esc_attr( $this->block_width ); ?><?php echo esc_attr( $this->class_name ); ?> <?php echo esc_attr( $this->conditional_class ); ?>">
98 <div class="srfm-<?php echo esc_attr( $this->slug ); ?>-block srf-<?php echo esc_attr( $this->slug ); ?>-<?php echo esc_attr( $this->block_id ); ?>-block">
99 <?php echo wp_kses_post( $this->label_markup ); ?>
100 <?php echo wp_kses_post( $this->help_markup ); ?>
101 <div class="srfm-block-wrap">
102 <input class="srfm-input-common srfm-input-<?php echo esc_attr( $this->slug ); ?>" type="email" name="<?php echo esc_attr( $this->field_name ); ?>" id="<?php echo esc_attr( $this->unique_slug ); ?>"
103 <?php echo ! empty( $this->aria_described_by ) ? "aria-describedby='" . esc_attr( trim( $this->aria_described_by ) ) . "'" : ''; ?>
104 aria-required="<?php echo esc_attr( strval( $this->aria_require_attr ) ); ?>" data-unique="<?php echo esc_attr( $this->aria_unique ); ?>" <?php echo wp_kses_post( $this->default_value_attr ); ?> <?php echo wp_kses_post( $this->placeholder_attr ); ?> />
105 <?php echo $this->error_svg; //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Ignored to render svg ?>
106 </div>
107 <div class="srfm-error-wrap">
108 <?php echo wp_kses_post( $this->duplicate_msg_markup ); ?>
109 </div>
110 </div>
111 <?php
112 if ( true === $this->is_confirm_email ) {
113 $confirm_label_markup = Helper::generate_common_form_markup( $this->form_id, 'label', $this->confirm_label, $this->slug . '-confirm', $this->block_id . $this->input_confirm_label, boolval( $this->required ) );
114 $placeholder = Helper::generate_common_form_markup( $this->form_id, 'placeholder', $this->confirm_label, $this->slug, $this->block_id . $this->block_id . $this->input_confirm_label, boolval( $this->required ) );
115 $this->placeholder_attr = '';
116 if ( ! empty( $placeholder ) ) {
117 $confirm_label_markup = '';
118 $this->placeholder_attr = ' placeholder="' . $placeholder . '" ';
119 }
120
121 ?>
122 <div class="srfm-<?php echo esc_attr( $this->slug ); ?>-confirm-block srf-<?php echo esc_attr( $this->slug ); ?>-<?php echo esc_attr( $this->block_id ); ?>-confirm-block">
123 <?php echo wp_kses_post( $confirm_label_markup ); ?>
124 <div class="srfm-block-wrap">
125 <input class="srfm-input-common srfm-input-<?php echo esc_attr( $this->slug ); ?>-confirm" type="email" name="<?php echo esc_attr( $this->unique_confirm_slug ); ?>" id="<?php echo esc_attr( $this->unique_confirm_slug ); ?>"
126 <?php echo ! empty( $this->aria_described_by ) ? "aria-describedby='" . esc_attr( trim( $this->aria_described_by ) ) . "'" : ''; ?>
127 aria-required="<?php echo esc_attr( $this->aria_require_attr ); ?>" <?php echo wp_kses_post( $this->default_value_attr ); ?> <?php echo wp_kses_post( $this->placeholder_attr ); ?> />
128 <?php echo $this->error_svg; //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Ignored to render svg ?>
129 </div>
130 <div class="srfm-error-wrap">
131 <?php echo wp_kses_post( $this->error_msg_markup ); ?>
132 </div>
133 </div>
134 <?php } ?>
135 </div>
136 <?php
137 return ob_get_clean();
138 }
139
140 }
141