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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
acceptance.php 7 years ago akismet.php 7 years ago checkbox.php 7 years ago constant-contact.php 7 years ago count.php 7 years ago date.php 7 years ago file.php 7 years ago flamingo.php 7 years ago hidden.php 7 years ago listo.php 9 years ago number.php 7 years ago quiz.php 7 years ago really-simple-captcha.php 7 years ago recaptcha.php 7 years ago response.php 7 years ago select.php 7 years ago submit.php 7 years ago text.php 7 years ago textarea.php 7 years ago
textarea.php
199 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 function wpcf7_textarea_form_tag_handler( $tag ) {
16 if ( empty( $tag->name ) ) {
17 return '';
18 }
19
20 $validation_error = wpcf7_get_validation_error( $tag->name );
21
22 $class = wpcf7_form_controls_class( $tag->type );
23
24 if ( $validation_error ) {
25 $class .= ' wpcf7-not-valid';
26 }
27
28 $atts = array();
29
30 $atts['cols'] = $tag->get_cols_option( '40' );
31 $atts['rows'] = $tag->get_rows_option( '10' );
32 $atts['maxlength'] = $tag->get_maxlength_option();
33 $atts['minlength'] = $tag->get_minlength_option();
34
35 if ( $atts['maxlength'] and $atts['minlength']
36 and $atts['maxlength'] < $atts['minlength'] ) {
37 unset( $atts['maxlength'], $atts['minlength'] );
38 }
39
40 $atts['class'] = $tag->get_class_option( $class );
41 $atts['id'] = $tag->get_id_option();
42 $atts['tabindex'] = $tag->get_option( 'tabindex', 'signed_int', true );
43
44 $atts['autocomplete'] = $tag->get_option( 'autocomplete',
45 '[-0-9a-zA-Z]+', true );
46
47 if ( $tag->has_option( 'readonly' ) ) {
48 $atts['readonly'] = 'readonly';
49 }
50
51 if ( $tag->is_required() ) {
52 $atts['aria-required'] = 'true';
53 }
54
55 $atts['aria-invalid'] = $validation_error ? 'true' : 'false';
56
57 $value = empty( $tag->content )
58 ? (string) reset( $tag->values )
59 : $tag->content;
60
61 if ( $tag->has_option( 'placeholder' )
62 or $tag->has_option( 'watermark' ) ) {
63 $atts['placeholder'] = $value;
64 $value = '';
65 }
66
67 $value = $tag->get_default_option( $value );
68
69 $value = wpcf7_get_hangover( $tag->name, $value );
70
71 $atts['name'] = $tag->name;
72
73 $atts = wpcf7_format_atts( $atts );
74
75 $html = sprintf(
76 '<span class="wpcf7-form-control-wrap %1$s"><textarea %2$s>%3$s</textarea>%4$s</span>',
77 sanitize_html_class( $tag->name ), $atts,
78 esc_textarea( $value ), $validation_error );
79
80 return $html;
81 }
82
83
84 /* Validation filter */
85
86 add_filter( 'wpcf7_validate_textarea',
87 'wpcf7_textarea_validation_filter', 10, 2 );
88 add_filter( 'wpcf7_validate_textarea*',
89 'wpcf7_textarea_validation_filter', 10, 2 );
90
91 function wpcf7_textarea_validation_filter( $result, $tag ) {
92 $type = $tag->type;
93 $name = $tag->name;
94
95 $value = isset( $_POST[$name] ) ? (string) $_POST[$name] : '';
96
97 if ( $tag->is_required() and '' == $value ) {
98 $result->invalidate( $tag, wpcf7_get_message( 'invalid_required' ) );
99 }
100
101 if ( '' !== $value ) {
102 $maxlength = $tag->get_maxlength_option();
103 $minlength = $tag->get_minlength_option();
104
105 if ( $maxlength and $minlength
106 and $maxlength < $minlength ) {
107 $maxlength = $minlength = null;
108 }
109
110 $code_units = wpcf7_count_code_units( stripslashes( $value ) );
111
112 if ( false !== $code_units ) {
113 if ( $maxlength and $maxlength < $code_units ) {
114 $result->invalidate( $tag, wpcf7_get_message( 'invalid_too_long' ) );
115 } elseif ( $minlength and $code_units < $minlength ) {
116 $result->invalidate( $tag, wpcf7_get_message( 'invalid_too_short' ) );
117 }
118 }
119 }
120
121 return $result;
122 }
123
124
125 /* Tag generator */
126
127 add_action( 'wpcf7_admin_init', 'wpcf7_add_tag_generator_textarea', 20, 0 );
128
129 function wpcf7_add_tag_generator_textarea() {
130 $tag_generator = WPCF7_TagGenerator::get_instance();
131 $tag_generator->add( 'textarea', __( 'text area', 'contact-form-7' ),
132 'wpcf7_tag_generator_textarea' );
133 }
134
135 function wpcf7_tag_generator_textarea( $contact_form, $args = '' ) {
136 $args = wp_parse_args( $args, array() );
137 $type = 'textarea';
138
139 $description = __( "Generate a form-tag for a multi-line text input field. For more details, see %s.", 'contact-form-7' );
140
141 $desc_link = wpcf7_link( __( 'https://contactform7.com/text-fields/', 'contact-form-7' ), __( 'Text Fields', 'contact-form-7' ) );
142
143 ?>
144 <div class="control-box">
145 <fieldset>
146 <legend><?php echo sprintf( esc_html( $description ), $desc_link ); ?></legend>
147
148 <table class="form-table">
149 <tbody>
150 <tr>
151 <th scope="row"><?php echo esc_html( __( 'Field type', 'contact-form-7' ) ); ?></th>
152 <td>
153 <fieldset>
154 <legend class="screen-reader-text"><?php echo esc_html( __( 'Field type', 'contact-form-7' ) ); ?></legend>
155 <label><input type="checkbox" name="required" /> <?php echo esc_html( __( 'Required field', 'contact-form-7' ) ); ?></label>
156 </fieldset>
157 </td>
158 </tr>
159
160 <tr>
161 <th scope="row"><label for="<?php echo esc_attr( $args['content'] . '-name' ); ?>"><?php echo esc_html( __( 'Name', 'contact-form-7' ) ); ?></label></th>
162 <td><input type="text" name="name" class="tg-name oneline" id="<?php echo esc_attr( $args['content'] . '-name' ); ?>" /></td>
163 </tr>
164
165 <tr>
166 <th scope="row"><label for="<?php echo esc_attr( $args['content'] . '-values' ); ?>"><?php echo esc_html( __( 'Default value', 'contact-form-7' ) ); ?></label></th>
167 <td><input type="text" name="values" class="oneline" id="<?php echo esc_attr( $args['content'] . '-values' ); ?>" /><br />
168 <label><input type="checkbox" name="placeholder" class="option" /> <?php echo esc_html( __( 'Use this text as the placeholder of the field', 'contact-form-7' ) ); ?></label></td>
169 </tr>
170
171 <tr>
172 <th scope="row"><label for="<?php echo esc_attr( $args['content'] . '-id' ); ?>"><?php echo esc_html( __( 'Id attribute', 'contact-form-7' ) ); ?></label></th>
173 <td><input type="text" name="id" class="idvalue oneline option" id="<?php echo esc_attr( $args['content'] . '-id' ); ?>" /></td>
174 </tr>
175
176 <tr>
177 <th scope="row"><label for="<?php echo esc_attr( $args['content'] . '-class' ); ?>"><?php echo esc_html( __( 'Class attribute', 'contact-form-7' ) ); ?></label></th>
178 <td><input type="text" name="class" class="classvalue oneline option" id="<?php echo esc_attr( $args['content'] . '-class' ); ?>" /></td>
179 </tr>
180
181 </tbody>
182 </table>
183 </fieldset>
184 </div>
185
186 <div class="insert-box">
187 <input type="text" name="<?php echo $type; ?>" class="tag code" readonly="readonly" onfocus="this.select()" />
188
189 <div class="submitbox">
190 <input type="button" class="button button-primary insert-tag" value="<?php echo esc_attr( __( 'Insert Tag', 'contact-form-7' ) ); ?>" />
191 </div>
192
193 <br class="clear" />
194
195 <p class="description mail-tag"><label for="<?php echo esc_attr( $args['content'] . '-mailtag' ); ?>"><?php echo sprintf( esc_html( __( "To use the value input through this field in a mail field, you need to insert the corresponding mail-tag (%s) into the field on the Mail tab.", 'contact-form-7' ) ), '<strong><span class="mail-tag"></span></strong>' ); ?><input type="text" class="mail-tag code hidden" readonly="readonly" id="<?php echo esc_attr( $args['content'] . '-mailtag' ); ?>" /></label></p>
196 </div>
197 <?php
198 }
199