PluginProbe ʕ •ᴥ•ʔ
Everest Forms – Contact Form, Payment Form, Quiz, Survey & Custom Form Builder with AI / 2.0.4
Everest Forms – Contact Form, Payment Form, Quiz, Survey & Custom Form Builder with AI v2.0.4
3.5.2 3.5.1 3.5.0 3.4.8 3.4.7 3.4.6 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.5.1 1.1.6 1.1.7 1.1.8 1.1.9 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.4.8 1.4.9 1.5.0 1.5.1 1.5.10 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.5.9 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6 1.6.6.1 1.6.7 1.7.0 1.7.0.1 1.7.0.2 1.7.0.3 1.7.1 1.7.2 1.7.2.1 1.7.2.2 1.7.3 1.7.4 1.7.5 1.7.5.1 1.7.5.2 1.7.6 1.7.7 1.7.7.1 1.7.7.2 1.7.8 1.7.9 1.8.0 1.8.0.1 1.8.1 1.8.2 1.8.2.1 1.8.2.2 1.8.2.3 1.8.3 1.8.4 1.8.5 1.8.6 1.8.7 1.8.8 1.8.9 1.9.0 1.9.0.1 1.9.1 1.9.2 1.9.3 1.9.4 1.9.4.1 1.9.5 1.9.6 1.9.7 1.9.8 1.9.9 2.0.0 2.0.0.1 2.0.1 2.0.2 2.0.3 2.0.3.1 2.0.4 2.0.4.1 2.0.5 2.0.6 2.0.7 2.0.8 2.0.8.1 2.0.9 3.0.0 3.0.0.1 3.0.1 3.0.2 3.0.3 3.0.3.1 3.0.4 3.0.4.1 3.0.4.2 3.0.5 3.0.5.1 3.0.5.2 3.0.6 3.0.6.1 3.0.7.1 3.0.8 3.0.8.1 3.0.9 3.0.9.1 3.0.9.2 3.0.9.3 3.0.9.4 3.0.9.5 3.1.0 3.1.1 3.1.2 3.2.0 3.2.1 3.2.2 3.2.3 3.2.4 3.2.5 3.2.6 3.3.0 3.4.0 3.4.1 3.4.2 3.4.2.1 3.4.3 3.4.4 3.4.5 trunk 1.0 1.0.1 1.0.2 1.0.3
everest-forms / includes / fields / class-evf-field-textarea.php
everest-forms / includes / fields Last commit date
class-evf-field-address.php 7 years ago class-evf-field-ai.php 2 years ago class-evf-field-captcha.php 2 years ago class-evf-field-checkbox.php 2 years ago class-evf-field-color.php 3 years ago class-evf-field-country.php 7 years ago class-evf-field-credit-card.php 2 years ago class-evf-field-date-time.php 2 years ago class-evf-field-divider.php 4 years ago class-evf-field-email.php 2 years ago class-evf-field-file-upload.php 6 years ago class-evf-field-first-name.php 2 years ago class-evf-field-hidden.php 7 years ago class-evf-field-html.php 7 years ago class-evf-field-image-upload.php 7 years ago class-evf-field-last-name.php 2 years ago class-evf-field-likert.php 2 years ago class-evf-field-lookup.php 2 years ago class-evf-field-number.php 2 years ago class-evf-field-password.php 7 years ago class-evf-field-payment-authorize-net.php 2 years ago class-evf-field-payment-checkbox.php 7 years ago class-evf-field-payment-coupon.php 2 years ago class-evf-field-payment-quantity.php 5 years ago class-evf-field-payment-radio.php 7 years ago class-evf-field-payment-single.php 7 years ago class-evf-field-payment-subtotal.php 3 years ago class-evf-field-payment-total.php 6 years ago class-evf-field-phone.php 7 years ago class-evf-field-privacy-policy.php 4 years ago class-evf-field-progress.php 3 years ago class-evf-field-radio.php 2 years ago class-evf-field-range-slider.php 6 years ago class-evf-field-rating.php 7 years ago class-evf-field-repeater.php 2 years ago class-evf-field-reset.php 3 years ago class-evf-field-scale-rating.php 2 years ago class-evf-field-select.php 2 years ago class-evf-field-signature.php 7 years ago class-evf-field-text.php 2 years ago class-evf-field-textarea.php 2 years ago class-evf-field-title.php 6 years ago class-evf-field-url.php 2 years ago class-evf-field-wysiwyg.php 4 years ago class-evf-field-yes-no.php 2 years ago
class-evf-field-textarea.php
299 lines
1 <?php
2
3 /**
4 * Textarea field.
5 *
6 * @package EverestForms\Fields
7 * @since 1.0.0
8 */
9
10 defined('ABSPATH') || exit;
11
12 /**
13 * EVF_Field_Textarea class.
14 */
15 class EVF_Field_Textarea extends EVF_Form_Fields
16 {
17
18 /**
19 * Constructor.
20 */
21 public function __construct()
22 {
23 $this->name = esc_html__('Paragraph Text', 'everest-forms');
24 $this->type = 'textarea';
25 $this->icon = 'evf-icon evf-icon-paragraph';
26 $this->order = 40;
27 $this->group = 'general';
28 $this->settings = array(
29 'basic-options' => array(
30 'field_options' => array(
31 'label',
32 'meta',
33 'description',
34 'required',
35 'required_field_message_setting',
36 'required_field_message',
37 'readonly',
38 ),
39 ),
40 'advanced-options' => array(
41 'field_options' => array(
42 'size',
43 'placeholder',
44 'label_hide',
45 'limit_length',
46 'min_length',
47 'default_value',
48 'css',
49 ),
50 ),
51 );
52
53 parent::__construct();
54 }
55
56 /**
57 * Hook in tabs.
58 */
59 public function init_hooks()
60 {
61 add_action('everest_forms_shortcode_scripts', array($this, 'load_assets'));
62 }
63
64 /**
65 * Limit length field option.
66 *
67 * @param array $field Field settings.
68 */
69 public function limit_length($field)
70 {
71 // Limit length.
72 $args = array(
73 'slug' => 'limit_enabled',
74 'content' => $this->field_element(
75 'toggle',
76 $field,
77 array(
78 'slug' => 'limit_enabled',
79 'value' => isset($field['limit_enabled']),
80 'desc' => esc_html__('Limit Length', 'everest-forms'),
81 'tooltip' => esc_html__('Check this option to specify maximum text length by characters or word count.', 'everest-forms'),
82 ),
83 false
84 ),
85 );
86 $this->field_element('row', $field, $args);
87
88 // Limit controls.
89 $count = $this->field_element(
90 'text',
91 $field,
92 array(
93 'type' => 'number',
94 'class' => 'small-text',
95 'slug' => 'limit_count',
96 'attrs' => array(
97 'min' => 1,
98 'step' => 1,
99 'pattern' => '[0-9]',
100 ),
101 'value' => !empty($field['limit_count']) ? absint($field['limit_count']) : 1,
102 ),
103 false
104 );
105
106 $mode = $this->field_element(
107 'select',
108 $field,
109 array(
110 'slug' => 'limit_mode',
111 'class' => 'limit-select',
112 'value' => !empty($field['limit_mode']) ? esc_attr($field['limit_mode']) : 'characters',
113 'options' => array(
114 'characters' => esc_html__('Characters', 'everest-forms'),
115 'words' => esc_html__('Words Count', 'everest-forms'),
116 ),
117 ),
118 false
119 );
120 $args = array(
121 'slug' => 'limit_controls',
122 'class' => !isset($field['limit_enabled']) ? 'everest-forms-hidden' : '',
123 'content' => $count . $mode,
124 );
125 $this->field_element('row', $field, $args);
126 }
127
128 /**
129 * Minimum Length length field option.
130 *
131 * @param array $field Field settings.
132 */
133 public function min_length($field)
134 {
135 // Minimum length.
136 $args = array(
137 'slug' => 'min_length_enabled',
138 'content' => $this->field_element(
139 'toggle',
140 $field,
141 array(
142 'slug' => 'min_length_enabled',
143 'value' => isset($field['min_length_enabled']),
144 'desc' => esc_html__('Minimum Length', 'everest-forms'),
145 'tooltip' => esc_html__('Check this option to specify minimum text length by characters or word count.', 'everest-forms'),
146 ),
147 false
148 ),
149 );
150 $this->field_element('row', $field, $args);
151
152 // Minimum length controls.
153 $count = $this->field_element(
154 'text',
155 $field,
156 array(
157 'type' => 'number',
158 'class' => 'small-text',
159 'slug' => 'min_length_count',
160 'attrs' => array(
161 'min' => 1,
162 'step' => 1,
163 'pattern' => '[0-9]',
164 ),
165 'value' => !empty($field['min_length_count']) ? absint($field['min_length_count']) : 1,
166 ),
167 false
168 );
169
170 $mode = $this->field_element(
171 'select',
172 $field,
173 array(
174 'slug' => 'min_length_mode',
175 'class' => 'min-length-select',
176 'value' => !empty($field['min_length_mode']) ? esc_attr($field['min_length_mode']) : 'characters',
177 'options' => array(
178 'characters' => esc_html__('Characters', 'everest-forms'),
179 'words' => esc_html__('Words Count', 'everest-forms'),
180 ),
181 ),
182 false
183 );
184 $args = array(
185 'slug' => 'min_length_controls',
186 'class' => !isset($field['min_length_enabled']) ? 'everest-forms-hidden' : '',
187 'content' => $count . $mode,
188 );
189 $this->field_element('row', $field, $args);
190 }
191
192 /**
193 * Enqueue shortcode scripts.
194 *
195 * @param array $atts Shortcode Attributes.
196 */
197 public function load_assets($atts)
198 {
199 $form_id = isset($atts['id']) ? wp_unslash($atts['id']) : ''; // WPCS: CSRF ok, input var ok, sanitization ok.
200 $form_obj = evf()->form->get($form_id);
201 $form_data = !empty($form_obj->post_content) ? evf_decode($form_obj->post_content) : '';
202
203 // Leave only fields with limit.
204 if (!empty($form_data['form_fields'])) {
205 $form_fields = array_filter($form_data['form_fields'], array($this, 'field_is_limit'));
206
207 if (count($form_fields)) {
208 wp_enqueue_script('everest-forms-text-limit');
209 }
210 }
211 }
212
213 /**
214 * Field preview inside the builder.
215 *
216 * @since 1.0.0
217 *
218 * @param array $field Field data and settings.
219 */
220 public function field_preview($field)
221 {
222 $placeholder = !empty($field['placeholder']) ? esc_attr($field['placeholder']) : '';
223
224 // Label.
225 $this->field_preview_option('label', $field);
226
227 // Primary input.
228 echo '<textarea placeholder="' . esc_attr($placeholder) . '" class="widefat" disabled></textarea>';
229
230 // Description.
231 $this->field_preview_option('description', $field);
232 }
233
234 /**
235 * Field display on the form front-end.
236 *
237 * @since 1.0.0
238 *
239 * @param array $field Field Data.
240 * @param array $field_atts Field attributes.
241 * @param array $form_data All Form Data.
242 */
243 public function field_display($field, $field_atts, $form_data)
244 {
245 // Define data.
246 $value = '';
247 $primary = $field['properties']['inputs']['primary'];
248
249 if (isset($primary['attr']['value'])) {
250 $value = evf_sanitize_textarea_field($primary['attr']['value']);
251 unset($primary['attr']['value']);
252 }
253
254 // Limit length.
255 if (isset($field['limit_enabled'])) {
256 $limit_count = isset($field['limit_count']) ? absint($field['limit_count']) : 0;
257 $limit_mode = isset($field['limit_mode']) ? sanitize_key($field['limit_mode']) : 'characters';
258
259 $primary['data']['form-id'] = $form_data['id'];
260 $primary['data']['field-id'] = $field['id'];
261
262 if ('characters' === $limit_mode) {
263 $primary['class'][] = 'everest-forms-limit-characters-enabled';
264 $primary['attr']['maxlength'] = $limit_count;
265 $primary['data']['text-limit'] = $limit_count;
266 } else {
267 $primary['class'][] = 'everest-forms-limit-words-enabled';
268 $primary['data']['text-limit'] = $limit_count;
269 }
270 }
271
272 // Minimum length.
273 if (isset($field['min_length_enabled'])) {
274 $min_length_count = isset($field['min_length_count']) ? absint($field['min_length_count']) : 0;
275 $min_length_mode = isset($field['min_length_mode']) ? sanitize_key($field['min_length_mode']) : 'characters';
276
277 $primary['data']['form-id'] = $form_data['id'];
278 $primary['data']['field-id'] = $field['id'];
279
280 if ('characters' === $min_length_mode) {
281 $primary['class'][] = 'everest-forms-min-characters-length-enabled';
282 $primary['attr']['minlength'] = $min_length_count;
283 $primary['data']['text-min-length'] = $min_length_count;
284 } else {
285 $primary['class'][] = 'everest-forms-min-words-length-enabled';
286 $primary['data']['text-min-length'] = $min_length_count;
287 }
288 }
289
290 // Primary field.
291 printf(
292 '<textarea %s %s >%s</textarea>',
293 evf_html_attributes($primary['id'], $primary['class'], $primary['data'], $primary['attr']),
294 esc_attr($primary['required']),
295 esc_html($value)
296 );
297 }
298 }
299