PluginProbe ʕ •ᴥ•ʔ
SureForms – Contact Form Builder, AI Forms, Payment Form, Survey & Quiz / 2.12.4
SureForms – Contact Form Builder, AI Forms, Payment Form, Survey & Quiz v2.12.4
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 0.0.3 0.0.4 0.0.5 0.0.6 0.0.7 0.0.8 0.0.9 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.1.0 1.1.1 1.1.2 1.10.0 1.10.1 1.11.0 1.12.0 1.12.1 1.12.2 1.12.3 1.13.0 1.13.1 1.13.2 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.3.0 1.3.1 1.3.2 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.5.0 1.5.1 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 1.7.0 1.7.1 1.7.2 1.7.3 1.7.4 1.8.0 1.9.0 1.9.1 2.0.0 2.0.1 2.0.2 2.1.0 2.1.1 2.2.0 2.2.1 2.2.2 2.3.0 2.4.0 2.5.0 2.5.2 2.6.0
sureforms / inc / fields / input-markup.php
sureforms / inc / fields Last commit date
address-markup.php 3 months ago base.php 3 weeks ago checkbox-markup.php 1 year ago countries.json 1 year ago dropdown-markup.php 2 months ago email-markup.php 3 weeks ago gdpr-markup.php 5 months ago inlinebutton-markup.php 3 weeks ago input-markup.php 5 months ago multichoice-markup.php 3 months ago number-markup.php 5 months ago payment-markup.php 3 weeks ago phone-markup.php 2 months ago textarea-markup.php 2 months ago url-markup.php 5 months ago
input-markup.php
103 lines
1 <?php
2 /**
3 * Sureforms Input Markup Class file.
4 *
5 * @package sureforms.
6 * @since 0.0.1
7 */
8
9 namespace SRFM\Inc\Fields;
10
11 if ( ! defined( 'ABSPATH' ) ) {
12 exit; // Exit if accessed directly.
13 }
14
15 /**
16 * Sureforms Input Markup Class.
17 *
18 * @since 0.0.1
19 */
20 class Input_Markup extends Base {
21 /**
22 * Maximum length of text allowed for an input field.
23 *
24 * @var string
25 * @since 0.0.2
26 */
27 protected $max_text_length;
28
29 /**
30 * Input mask for the input field.
31 *
32 * @var string
33 * @since 0.0.11
34 */
35 protected $input_mask;
36 /**
37 * Custom input mask for the input field.
38 *
39 * @var string
40 * @since 0.0.11
41 */
42 protected $custom_input_mask;
43
44 /**
45 * Read-only attribute for the input field.
46 *
47 * @var bool
48 * @since 1.7.2
49 */
50 protected $read_only;
51
52 /**
53 * Initialize the properties based on block attributes.
54 *
55 * @param array<mixed> $attributes Block attributes.
56 * @since 0.0.2
57 */
58 public function __construct( $attributes ) {
59 $this->slug = 'input';
60 $this->max_text_length = $attributes['textLength'] ?? '';
61 $this->input_mask = $attributes['inputMask'] ?? '';
62 $this->custom_input_mask = 'custom-mask' === $this->input_mask && isset( $attributes['customInputMask'] ) ? $attributes['customInputMask'] : '';
63 $this->set_properties( $attributes );
64 $this->read_only = ! empty( $this->default ) && $attributes['readOnly'];
65 $this->set_input_label( __( 'Text field', 'sureforms' ) );
66 $this->set_error_msg( $attributes, 'srfm_input_block_required_text' );
67 $this->set_duplicate_msg( $attributes, 'srfm_input_block_unique_text' );
68 $this->set_unique_slug();
69 $this->set_field_name( $this->unique_slug );
70 $this->set_markup_properties( $this->input_label, true );
71 $this->set_aria_described_by();
72 $this->set_label_as_placeholder( $this->input_label );
73 }
74
75 /**
76 * Render input markup
77 *
78 * @since 0.0.2
79 * @return string|bool
80 */
81 public function markup() {
82 $data_config = $this->field_config;
83
84 $this->class_name = $this->get_field_classes( $this->read_only ? [ 'srfm-read-only' ] : [] );
85
86 ob_start(); ?>
87 <div data-block-id="<?php echo esc_attr( $this->block_id ); ?>" class="<?php echo esc_attr( $this->class_name ); ?>" <?php echo $data_config ? "data-field-config='" . esc_attr( $data_config ) . "'" : ''; ?>>
88 <?php echo wp_kses_post( $this->label_markup ); ?>
89 <?php echo wp_kses_post( $this->help_markup ); ?>
90 <div class="srfm-block-wrap">
91 <input class="srfm-input-common srfm-input-<?php echo esc_attr( $this->slug ); ?>" type="text" name="<?php echo esc_attr( $this->field_name ); ?>" id="<?php echo esc_attr( $this->unique_slug ); ?>"
92 <?php echo ! empty( $this->aria_described_by ) ? "aria-describedby='" . esc_attr( trim( $this->aria_described_by ) ) . "'" : ''; ?>
93 data-required="<?php echo esc_attr( strval( $this->data_require_attr ) ); ?>" aria-required="<?php echo esc_attr( $this->data_require_attr ); ?>" data-unique="<?php echo esc_attr( $this->aria_unique ); ?>" maxlength="<?php echo esc_attr( $this->max_text_length ); ?>" value="<?php echo esc_attr( $this->default ); ?>" <?php echo wp_kses_post( $this->placeholder_attr ); ?> data-srfm-mask="<?php echo esc_attr( $this->input_mask ); ?>" <?php echo ! empty( $this->custom_input_mask ) ? 'data-custom-srfm-mask="' . esc_attr( $this->custom_input_mask ) . '"' : ''; ?> <?php echo $this->read_only ? 'readonly' : ''; ?> />
94 </div>
95 <div class="srfm-error-wrap">
96 <?php echo wp_kses_post( $this->duplicate_msg_markup ); ?>
97 </div>
98 </div>
99 <?php
100 return ob_get_clean();
101 }
102 }
103