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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 8 months ago acceptance.php 11 months ago checkbox.php 9 months ago count.php 1 year ago date.php 7 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 7 months ago quiz.php 11 months ago really-simple-captcha.php 6 months ago reflection.php 3 years ago response.php 6 years ago select.php 7 months ago submit.php 11 months ago text.php 7 months ago textarea.php 7 months ago
textarea.php
222 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 (
37 $atts['maxlength'] and $atts['minlength'] and
38 $atts['maxlength'] < $atts['minlength']
39 ) {
40 unset( $atts['maxlength'], $atts['minlength'] );
41 }
42
43 $atts['class'] = $tag->get_class_option( $class );
44 $atts['id'] = $tag->get_id_option();
45 $atts['tabindex'] = $tag->get_option( 'tabindex', 'signed_int', true );
46 $atts['readonly'] = $tag->has_option( 'readonly' );
47 $atts['autocomplete'] = $tag->get_autocomplete_option();
48
49 if ( $tag->is_required() ) {
50 $atts['aria-required'] = 'true';
51 }
52
53 if ( $validation_error ) {
54 $atts['aria-invalid'] = 'true';
55 $atts['aria-describedby'] = wpcf7_get_validation_error_reference(
56 $tag->name
57 );
58 } else {
59 $atts['aria-invalid'] = 'false';
60 }
61
62 $value = empty( $tag->content )
63 ? (string) reset( $tag->values )
64 : $tag->content;
65
66 if ( $tag->has_option( 'placeholder' ) or $tag->has_option( 'watermark' ) ) {
67 $atts['placeholder'] = $value;
68 $value = '';
69 }
70
71 $value = $tag->get_default_option( $value );
72
73 $value = wpcf7_get_hangover( $tag->name, $value );
74
75 $atts['name'] = $tag->name;
76
77 $html = sprintf(
78 '<span class="wpcf7-form-control-wrap" data-name="%1$s"><textarea %2$s>%3$s</textarea>%4$s</span>',
79 esc_attr( $tag->name ),
80 wpcf7_format_atts( $atts ),
81 esc_textarea( $value ),
82 $validation_error
83 );
84
85 return $html;
86 }
87
88
89 add_action(
90 'wpcf7_swv_create_schema',
91 'wpcf7_swv_add_textarea_rules',
92 10, 2
93 );
94
95 function wpcf7_swv_add_textarea_rules( $schema, $contact_form ) {
96 $tags = $contact_form->scan_form_tags( array(
97 'basetype' => array( 'textarea' ),
98 ) );
99
100 foreach ( $tags as $tag ) {
101 if ( $tag->is_required() ) {
102 $schema->add_rule(
103 wpcf7_swv_create_rule( 'required', array(
104 'field' => $tag->name,
105 'error' => wpcf7_get_message( 'invalid_required' ),
106 ) )
107 );
108 }
109
110 if ( $minlength = $tag->get_minlength_option() ) {
111 $schema->add_rule(
112 wpcf7_swv_create_rule( 'minlength', array(
113 'field' => $tag->name,
114 'threshold' => absint( $minlength ),
115 'error' => wpcf7_get_message( 'invalid_too_short' ),
116 ) )
117 );
118 }
119
120 if ( $maxlength = $tag->get_maxlength_option( '2000' ) ) {
121 $schema->add_rule(
122 wpcf7_swv_create_rule( 'maxlength', array(
123 'field' => $tag->name,
124 'threshold' => absint( $maxlength ),
125 'error' => wpcf7_get_message( 'invalid_too_long' ),
126 ) )
127 );
128 }
129 }
130 }
131
132
133 /* Tag generator */
134
135 add_action( 'wpcf7_admin_init', 'wpcf7_add_tag_generator_textarea', 20, 0 );
136
137 function wpcf7_add_tag_generator_textarea() {
138 $tag_generator = WPCF7_TagGenerator::get_instance();
139
140 $tag_generator->add( 'textarea',
141 __( 'text area', 'contact-form-7' ),
142 'wpcf7_tag_generator_textarea',
143 array( 'version' => '2' )
144 );
145 }
146
147 function wpcf7_tag_generator_textarea( $contact_form, $options ) {
148 $field_types = array(
149 'textarea' => array(
150 'display_name' => __( 'Text area', 'contact-form-7' ),
151 'heading' => __( 'Text area form-tag generator', 'contact-form-7' ),
152 'description' => __( 'Generates a form-tag for a <a href="https://contactform7.com/text-fields/">multi-line plain text input area</a>.', 'contact-form-7' ),
153 ),
154 );
155
156 $tgg = new WPCF7_TagGeneratorGenerator( $options['content'] );
157
158 $formatter = new WPCF7_HTMLFormatter();
159
160 $formatter->append_start_tag( 'header', array(
161 'class' => 'description-box',
162 ) );
163
164 $formatter->append_start_tag( 'h3' );
165
166 $formatter->append_preformatted(
167 esc_html( $field_types['textarea']['heading'] )
168 );
169
170 $formatter->end_tag( 'h3' );
171
172 $formatter->append_start_tag( 'p' );
173
174 $formatter->append_preformatted(
175 wp_kses_data( $field_types['textarea']['description'] )
176 );
177
178 $formatter->end_tag( 'header' );
179
180 $formatter->append_start_tag( 'div', array(
181 'class' => 'control-box',
182 ) );
183
184 $formatter->call_user_func( static function () use ( $tgg, $field_types ) {
185 $tgg->print( 'field_type', array(
186 'with_required' => true,
187 'select_options' => array(
188 'textarea' => $field_types['textarea']['display_name'],
189 ),
190 ) );
191
192 $tgg->print( 'field_name' );
193
194 $tgg->print( 'class_attr' );
195
196 $tgg->print( 'min_max', array(
197 'title' => __( 'Length', 'contact-form-7' ),
198 'min_option' => 'minlength:',
199 'max_option' => 'maxlength:',
200 ) );
201
202 $tgg->print( 'default_value', array(
203 'with_placeholder' => true,
204 'use_content' => true,
205 ) );
206 } );
207
208 $formatter->end_tag( 'div' );
209
210 $formatter->append_start_tag( 'footer', array(
211 'class' => 'insert-box',
212 ) );
213
214 $formatter->call_user_func( static function () use ( $tgg, $field_types ) {
215 $tgg->print( 'insert_box_content' );
216
217 $tgg->print( 'mail_tag_tip' );
218 } );
219
220 $formatter->print();
221 }
222