PluginProbe
SureForms – Contact Form Builder, AI Forms, Payment Form, Survey & Quiz / 1.5.0
SureForms – Contact Form Builder, AI Forms, Payment Form, Survey & Quiz v1.5.0
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 0.0.3 All 96 releases
sureforms / inc / fields / input-markup.php

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

94 lines 3.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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 * Initialize the properties based on block attributes.
46 *
47 * @param array<mixed> $attributes Block attributes.
48 * @since 0.0.2
49 */
50 public function __construct( $attributes ) {
51 $this->slug = 'input';
52 $this->max_text_length = $attributes['textLength'] ?? '';
53 $this->input_mask = $attributes['inputMask'] ?? '';
54 $this->custom_input_mask = 'custom-mask' === $this->input_mask && isset( $attributes['customInputMask'] ) ? $attributes['customInputMask'] : '';
55 $this->set_properties( $attributes );
56 $this->set_input_label( __( 'Text Field', 'sureforms' ) );
57 $this->set_error_msg( $attributes, 'srfm_input_block_required_text' );
58 $this->set_duplicate_msg( $attributes, 'srfm_input_block_unique_text' );
59 $this->set_unique_slug();
60 $this->set_field_name( $this->unique_slug );
61 $this->set_markup_properties( $this->input_label, true );
62 $this->set_aria_described_by();
63 $this->set_label_as_placeholder( $this->input_label );
64 }
65
66 /**
67 * Render input markup
68 *
69 * @since 0.0.2
70 * @return string|bool
71 */
72 public function markup() {
73 $data_config = $this->field_config;
74
75 $this->class_name = $this->get_field_classes();
76
77 ob_start(); ?>
78 <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 ) . "'" : ''; ?>>
79 <?php echo wp_kses_post( $this->label_markup ); ?>
80 <?php echo wp_kses_post( $this->help_markup ); ?>
81 <div class="srfm-block-wrap">
82 <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 ); ?>"
83 <?php echo ! empty( $this->aria_described_by ) ? "aria-describedby='" . esc_attr( trim( $this->aria_described_by ) ) . "'" : ''; ?>
84 data-required="<?php echo esc_attr( strval( $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 ) . '"' : ''; ?> />
85 </div>
86 <div class="srfm-error-wrap">
87 <?php echo wp_kses_post( $this->duplicate_msg_markup ); ?>
88 </div>
89 </div>
90 <?php
91 return ob_get_clean();
92 }
93 }
94