PluginProbe
SureForms – Contact Form Builder, AI Forms, Payment Form, Survey & Quiz / 0.0.11
SureForms – Contact Form Builder, AI Forms, Payment Form, Survey & Quiz v0.0.11
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
sureforms / inc / fields / textarea-markup.php

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

130 lines 3.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Sureforms Textarea 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 Textarea Markup Class.
17 *
18 * @since 0.0.1
19 */
20 class Textarea_Markup extends Base {
21
22 /**
23 * Maximum length of text allowed for the textarea.
24 *
25 * @var string
26 * @since 0.0.2
27 */
28 protected $max_length;
29
30 /**
31 * HTML attribute string for the maximum length.
32 *
33 * @var string
34 * @since 0.0.2
35 */
36 protected $max_length_attr;
37
38 /**
39 * HTML string for displaying the maximum length in the UI.
40 *
41 * @var string
42 * @since 0.0.2
43 */
44 protected $max_length_html;
45
46 /**
47 * Number of rows for the textarea.
48 *
49 * @var string
50 * @since 0.0.2
51 */
52 protected $rows;
53
54 /**
55 * HTML attribute string for the number of rows.
56 *
57 * @var string
58 * @since 0.0.2
59 */
60 protected $rows_attr;
61
62 /**
63 * Number of columns for the textarea.
64 *
65 * @var string
66 * @since 0.0.2
67 */
68 protected $cols;
69
70 /**
71 * HTML attribute string for the number of columns.
72 *
73 * @var string
74 * @since 0.0.2
75 */
76 protected $cols_attr;
77
78 /**
79 * Initialize the properties based on block attributes.
80 *
81 * @param array<mixed> $attributes Block attributes.
82 * @since 0.0.2
83 */
84 public function __construct( $attributes ) {
85 $this->set_properties( $attributes );
86 $this->set_input_label( __( 'Textarea', 'sureforms' ) );
87 $this->set_error_msg( $attributes, 'srfm_textarea_block_required_text' );
88 $this->slug = 'textarea';
89 $this->max_length = isset( $attributes['maxLength'] ) ? $attributes['maxLength'] : '';
90 $this->rows = isset( $attributes['rows'] ) ? $attributes['rows'] : '';
91 $this->cols = isset( $attributes['cols'] ) ? $attributes['cols'] : '';
92 // html attributes.
93 $this->max_length_attr = $this->max_length ? ' maxLength="' . $this->max_length . '" ' : '';
94 $this->rows_attr = $this->rows ? ' rows="' . $this->rows . '" ' : '';
95 $this->cols_attr = $this->cols ? ' cols="' . $this->cols . '" ' : '';
96 $this->max_length_html = '' !== $this->max_length ? '0/' . $this->max_length : '';
97 $this->set_unique_slug();
98 $this->set_field_name( $this->unique_slug );
99 $this->set_markup_properties( $this->input_label );
100 $this->set_aria_described_by();
101 $this->set_label_as_placeholder( $this->input_label );
102 }
103
104 /**
105 * Render the sureforms textarea classic styling
106 *
107 * @since 0.0.2
108 * @return string|boolean
109 */
110 public function markup() {
111 ob_start(); ?>
112 <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 ); ?>">
113 <?php echo wp_kses_post( $this->label_markup ); ?>
114 <?php echo wp_kses_post( $this->help_markup ); ?>
115 <div class="srfm-block-wrap">
116 <textarea class="srfm-input-common srfm-input-<?php echo esc_attr( $this->slug ); ?>" name="<?php echo esc_attr( $this->field_name ); ?>" id="<?php echo esc_attr( $this->unique_slug ); ?>"
117 <?php echo ! empty( $this->aria_described_by ) ? "aria-describedby='" . esc_attr( trim( $this->aria_described_by ) ) . "'" : ''; ?>
118 aria-required="<?php echo esc_attr( $this->aria_require_attr ); ?>" <?php echo wp_kses_post( $this->max_length_attr . '' . $this->cols_attr . '' . $this->rows_attr ); ?> <?php echo wp_kses_post( $this->placeholder_attr ); ?>><?php echo esc_html( $this->default ); ?></textarea>
119 </div>
120 <div class="srfm-error-wrap">
121 <?php echo wp_kses_post( $this->error_msg_markup ); ?>
122 </div>
123 </div>
124
125 <?php
126 return ob_get_clean();
127
128 }
129 }
130