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 3.9 3.9-beta 3.9.1 3.9.2 3.9.3 4.0 4.0.1 4.0.2 4.0.3 4.1 4.1-beta 4.1.1 4.1.2 4.2 4.2-beta 4.2.1 4.2.2 4.3 4.3.1 4.4 4.4.1 4.4.2 4.5 4.5.1 4.6 4.6.1 4.7 4.8 4.8.1 4.9 4.9.1 4.9.2 5.0 5.0.1
contact-form-7 / modules / textarea.php
contact-form-7 / modules Last commit date
akismet 11 months ago constant-contact 9 months ago recaptcha 9 months ago sendinblue 9 months ago stripe 9 months ago turnstile 9 months ago acceptance.php 11 months ago checkbox.php 9 months ago count.php 1 year ago date.php 9 months ago disallowed-list.php 9 months ago doi-helper.php 4 years ago file.php 11 months ago flamingo.php 9 months ago hidden.php 7 years ago listo.php 2 years ago number.php 9 months ago quiz.php 11 months ago really-simple-captcha.php 9 months ago reflection.php 3 years ago response.php 6 years ago select.php 9 months ago submit.php 11 months ago text.php 9 months ago textarea.php 11 months ago
textarea.php
224 lines
1 <?php
2 /**
3 ** A base module for [textarea] and [textarea*]
4 **/
5
6 /* form_tag handler */
7
8 add_action( 'wpcf7_init', 'wpcf7_add_form_tag_textarea', 10, 0 );
9
10 function wpcf7_add_form_tag_textarea() {
11 wpcf7_add_form_tag( array( 'textarea', 'textarea*' ),
12 'wpcf7_textarea_form_tag_handler', array( 'name-attr' => true )
13 );
14 }
15
16 function wpcf7_textarea_form_tag_handler( $tag ) {
17 if ( empty( $tag->name ) ) {
18 return '';
19 }
20
21 $validation_error = wpcf7_get_validation_error( $tag->name );
22
23 $class = wpcf7_form_controls_class( $tag->type );
24
25 if ( $validation_error ) {
26 $class .= ' wpcf7-not-valid';
27 }
28
29 $atts = array();
30
31 $atts['cols'] = $tag->get_cols_option( '40' );
32 $atts['rows'] = $tag->get_rows_option( '10' );
33 $atts['maxlength'] = $tag->get_maxlength_option( '2000' );
34 $atts['minlength'] = $tag->get_minlength_option();
35
36 if ( $atts['maxlength'] and $atts['minlength']
37 and $atts['maxlength'] < $atts['minlength'] ) {
38 unset( $atts['maxlength'], $atts['minlength'] );
39 }
40
41 $atts['class'] = $tag->get_class_option( $class );
42 $atts['id'] = $tag->get_id_option();
43 $atts['tabindex'] = $tag->get_option( 'tabindex', 'signed_int', true );
44 $atts['readonly'] = $tag->has_option( 'readonly' );
45
46 $atts['autocomplete'] = $tag->get_option(
47 'autocomplete', '[-0-9a-zA-Z]+', true
48 );
49
50 if ( $tag->is_required() ) {
51 $atts['aria-required'] = 'true';
52 }
53
54 if ( $validation_error ) {
55 $atts['aria-invalid'] = 'true';
56 $atts['aria-describedby'] = wpcf7_get_validation_error_reference(
57 $tag->name
58 );
59 } else {
60 $atts['aria-invalid'] = 'false';
61 }
62
63 $value = empty( $tag->content )
64 ? (string) reset( $tag->values )
65 : $tag->content;
66
67 if ( $tag->has_option( 'placeholder' )
68 or $tag->has_option( 'watermark' ) ) {
69 $atts['placeholder'] = $value;
70 $value = '';
71 }
72
73 $value = $tag->get_default_option( $value );
74
75 $value = wpcf7_get_hangover( $tag->name, $value );
76
77 $atts['name'] = $tag->name;
78
79 $html = sprintf(
80 '<span class="wpcf7-form-control-wrap" data-name="%1$s"><textarea %2$s>%3$s</textarea>%4$s</span>',
81 esc_attr( $tag->name ),
82 wpcf7_format_atts( $atts ),
83 esc_textarea( $value ),
84 $validation_error
85 );
86
87 return $html;
88 }
89
90
91 add_action(
92 'wpcf7_swv_create_schema',
93 'wpcf7_swv_add_textarea_rules',
94 10, 2
95 );
96
97 function wpcf7_swv_add_textarea_rules( $schema, $contact_form ) {
98 $tags = $contact_form->scan_form_tags( array(
99 'basetype' => array( 'textarea' ),
100 ) );
101
102 foreach ( $tags as $tag ) {
103 if ( $tag->is_required() ) {
104 $schema->add_rule(
105 wpcf7_swv_create_rule( 'required', array(
106 'field' => $tag->name,
107 'error' => wpcf7_get_message( 'invalid_required' ),
108 ) )
109 );
110 }
111
112 if ( $minlength = $tag->get_minlength_option() ) {
113 $schema->add_rule(
114 wpcf7_swv_create_rule( 'minlength', array(
115 'field' => $tag->name,
116 'threshold' => absint( $minlength ),
117 'error' => wpcf7_get_message( 'invalid_too_short' ),
118 ) )
119 );
120 }
121
122 if ( $maxlength = $tag->get_maxlength_option( '2000' ) ) {
123 $schema->add_rule(
124 wpcf7_swv_create_rule( 'maxlength', array(
125 'field' => $tag->name,
126 'threshold' => absint( $maxlength ),
127 'error' => wpcf7_get_message( 'invalid_too_long' ),
128 ) )
129 );
130 }
131 }
132 }
133
134
135 /* Tag generator */
136
137 add_action( 'wpcf7_admin_init', 'wpcf7_add_tag_generator_textarea', 20, 0 );
138
139 function wpcf7_add_tag_generator_textarea() {
140 $tag_generator = WPCF7_TagGenerator::get_instance();
141
142 $tag_generator->add( 'textarea',
143 __( 'text area', 'contact-form-7' ),
144 'wpcf7_tag_generator_textarea',
145 array( 'version' => '2' )
146 );
147 }
148
149 function wpcf7_tag_generator_textarea( $contact_form, $options ) {
150 $field_types = array(
151 'textarea' => array(
152 'display_name' => __( 'Text area', 'contact-form-7' ),
153 'heading' => __( 'Text area form-tag generator', 'contact-form-7' ),
154 'description' => __( 'Generates a form-tag for a <a href="https://contactform7.com/text-fields/">multi-line plain text input area</a>.', 'contact-form-7' ),
155 ),
156 );
157
158 $tgg = new WPCF7_TagGeneratorGenerator( $options['content'] );
159
160 $formatter = new WPCF7_HTMLFormatter();
161
162 $formatter->append_start_tag( 'header', array(
163 'class' => 'description-box',
164 ) );
165
166 $formatter->append_start_tag( 'h3' );
167
168 $formatter->append_preformatted(
169 esc_html( $field_types['textarea']['heading'] )
170 );
171
172 $formatter->end_tag( 'h3' );
173
174 $formatter->append_start_tag( 'p' );
175
176 $formatter->append_preformatted(
177 wp_kses_data( $field_types['textarea']['description'] )
178 );
179
180 $formatter->end_tag( 'header' );
181
182 $formatter->append_start_tag( 'div', array(
183 'class' => 'control-box',
184 ) );
185
186 $formatter->call_user_func( static function () use ( $tgg, $field_types ) {
187 $tgg->print( 'field_type', array(
188 'with_required' => true,
189 'select_options' => array(
190 'textarea' => $field_types['textarea']['display_name'],
191 ),
192 ) );
193
194 $tgg->print( 'field_name' );
195
196 $tgg->print( 'class_attr' );
197
198 $tgg->print( 'min_max', array(
199 'title' => __( 'Length', 'contact-form-7' ),
200 'min_option' => 'minlength:',
201 'max_option' => 'maxlength:',
202 ) );
203
204 $tgg->print( 'default_value', array(
205 'with_placeholder' => true,
206 'use_content' => true,
207 ) );
208 } );
209
210 $formatter->end_tag( 'div' );
211
212 $formatter->append_start_tag( 'footer', array(
213 'class' => 'insert-box',
214 ) );
215
216 $formatter->call_user_func( static function () use ( $tgg, $field_types ) {
217 $tgg->print( 'insert_box_content' );
218
219 $tgg->print( 'mail_tag_tip' );
220 } );
221
222 $formatter->print();
223 }
224