PluginProbe
SureForms – Contact Form Builder, AI Forms, Payment Form, Survey & Quiz / 0.0.13
SureForms – Contact Form Builder, AI Forms, Payment Form, Survey & Quiz v0.0.13
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 0.0.2 All 97 releases
sureforms / inc / fields / textarea-markup.php

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

112 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 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 * Initialize the properties based on block attributes.
64 *
65 * @param array<mixed> $attributes Block attributes.
66 * @since 0.0.2
67 */
68 public function __construct( $attributes ) {
69 $this->set_properties( $attributes );
70 $this->set_input_label( __( 'Textarea', 'sureforms' ) );
71 $this->set_error_msg( $attributes, 'srfm_textarea_block_required_text' );
72 $this->slug = 'textarea';
73 $this->max_length = isset( $attributes['maxLength'] ) ? $attributes['maxLength'] : '';
74 $this->rows = isset( $attributes['rows'] ) ? $attributes['rows'] : '';
75 // html attributes.
76 $this->max_length_attr = $this->max_length ? ' maxLength="' . $this->max_length . '" ' : '';
77 $this->rows_attr = $this->rows ? ' rows="' . $this->rows . '" ' : '';
78 $this->max_length_html = '' !== $this->max_length ? '0/' . $this->max_length : '';
79 $this->set_unique_slug();
80 $this->set_field_name( $this->unique_slug );
81 $this->set_markup_properties( $this->input_label );
82 $this->set_aria_described_by();
83 $this->set_label_as_placeholder( $this->input_label );
84 }
85
86 /**
87 * Render the sureforms textarea classic styling
88 *
89 * @since 0.0.2
90 * @return string|boolean
91 */
92 public function markup() {
93 ob_start(); ?>
94 <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 ); ?>">
95 <?php echo wp_kses_post( $this->label_markup ); ?>
96 <?php echo wp_kses_post( $this->help_markup ); ?>
97 <div class="srfm-block-wrap">
98 <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 ); ?>"
99 <?php echo ! empty( $this->aria_described_by ) ? "aria-describedby='" . esc_attr( trim( $this->aria_described_by ) ) . "'" : ''; ?>
100 aria-required="<?php echo esc_attr( $this->aria_require_attr ); ?>" <?php echo wp_kses_post( $this->max_length_attr . '' . $this->rows_attr ); ?> <?php echo wp_kses_post( $this->placeholder_attr ); ?>><?php echo esc_html( $this->default ); ?></textarea>
101 </div>
102 <div class="srfm-error-wrap">
103 <?php echo wp_kses_post( $this->error_msg_markup ); ?>
104 </div>
105 </div>
106
107 <?php
108 return ob_get_clean();
109
110 }
111 }
112