PluginProbe
SureForms – Contact Form Builder, AI Forms, Payment Form, Survey & Quiz / 1.0.1
SureForms – Contact Form Builder, AI Forms, Payment Form, Survey & Quiz v1.0.1
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.0.1, at inc/fields/input-markup.php

91 lines 3.3 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 /**
23 * Maximum length of text allowed for an input field.
24 *
25 * @var string
26 * @since 0.0.2
27 */
28 protected $max_text_length;
29
30 /**
31 * Input mask for the input field.
32 *
33 * @var string
34 * @since 0.0.11
35 */
36 protected $input_mask;
37 /**
38 * Custom input mask for the input field.
39 *
40 * @var string
41 * @since 0.0.11
42 */
43 protected $custom_input_mask;
44
45 /**
46 * Initialize the properties based on block attributes.
47 *
48 * @param array<mixed> $attributes Block attributes.
49 * @since 0.0.2
50 */
51 public function __construct( $attributes ) {
52 $this->slug = 'input';
53 $this->max_text_length = isset( $attributes['textLength'] ) ? $attributes['textLength'] : '';
54 $this->input_mask = isset( $attributes['inputMask'] ) ? $attributes['inputMask'] : '';
55 $this->custom_input_mask = ( 'custom-mask' === $this->input_mask && isset( $attributes['customInputMask'] ) ) ? $attributes['customInputMask'] : '';
56 $this->set_properties( $attributes );
57 $this->set_input_label( __( 'Text Field', 'sureforms' ) );
58 $this->set_error_msg( $attributes, 'srfm_input_block_required_text' );
59 $this->set_duplicate_msg( $attributes, 'srfm_input_block_unique_text' );
60 $this->set_unique_slug();
61 $this->set_field_name( $this->unique_slug );
62 $this->set_markup_properties( $this->input_label, true );
63 $this->set_aria_described_by();
64 $this->set_label_as_placeholder( $this->input_label );
65 }
66
67 /**
68 * Render input markup
69 *
70 * @since 0.0.2
71 * @return string|boolean
72 */
73 public function markup() {
74 ob_start(); ?>
75 <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 ); ?>">
76 <?php echo wp_kses_post( $this->label_markup ); ?>
77 <?php echo wp_kses_post( $this->help_markup ); ?>
78 <div class="srfm-block-wrap">
79 <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 ); ?>"
80 <?php echo ! empty( $this->aria_described_by ) ? "aria-describedby='" . esc_attr( trim( $this->aria_described_by ) ) . "'" : ''; ?>
81 aria-required="<?php echo esc_attr( strval( $this->aria_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 ) . '"' : ''; ?> />
82 </div>
83 <div class="srfm-error-wrap">
84 <?php echo wp_kses_post( $this->duplicate_msg_markup ); ?>
85 </div>
86 </div>
87 <?php
88 return ob_get_clean();
89 }
90 }
91