PluginProbe
SureForms – Contact Form Builder, AI Forms, Payment Form, Survey & Quiz / 2.12.8
SureForms – Contact Form Builder, AI Forms, Payment Form, Survey & Quiz v2.12.8
2.12.8 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 All 98 releases
← All changes | inc/fields/input-markup.php +20 -8 0.0.12 → 2.12.8 View file →
@@ -17,9 +17,8 @@
17 17 *
18 18 * @since 0.0.1
19 19 */
20 20 class Input_Markup extends Base {
21 -
22 21 /**
23 22 * Maximum length of text allowed for an input field.
24 23 *
25 24 * @var string
@@ -42,8 +41,16 @@
42 41 */
43 42 protected $custom_input_mask;
44 43
45 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 + /**
46 53 * Initialize the properties based on block attributes.
47 54 *
48 55 * @param array<mixed> $attributes Block attributes.
49 56 * @since 0.0.2
@@ -49,13 +56,14 @@
49 56 * @since 0.0.2
50 57 */
51 58 public function __construct( $attributes ) {
52 59 $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'] : '';
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'] : '';
56 63 $this->set_properties( $attributes );
57 - $this->set_input_label( __( 'Text Field', 'sureforms' ) );
64 + $this->read_only = ! empty( $this->default ) && $attributes['readOnly'];
65 + $this->set_input_label( __( 'Text field', 'sureforms' ) );
58 66 $this->set_error_msg( $attributes, 'srfm_input_block_required_text' );
59 67 $this->set_duplicate_msg( $attributes, 'srfm_input_block_unique_text' );
60 68 $this->set_unique_slug();
61 69 $this->set_field_name( $this->unique_slug );
@@ -67,19 +75,23 @@
67 75 /**
68 76 * Render input markup
69 77 *
70 78 * @since 0.0.2
71 - * @return string|boolean
79 + * @return string|bool
72 80 */
73 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 +
74 86 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 ); ?>">
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 ) . "'" : ''; ?>>
76 88 <?php echo wp_kses_post( $this->label_markup ); ?>
77 89 <?php echo wp_kses_post( $this->help_markup ); ?>
78 90 <div class="srfm-block-wrap">
79 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 ); ?>"
80 92 <?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-mask="<?php echo esc_attr( $this->input_mask ); ?>" <?php echo ! empty( $this->custom_input_mask ) ? 'data-custom-mask="' . esc_attr( $this->custom_input_mask ) . '"' : ''; ?> />
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' : ''; ?> />
82 94 </div>
83 95 <div class="srfm-error-wrap">
84 96 <?php echo wp_kses_post( $this->duplicate_msg_markup ); ?>
85 97 </div>