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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 11 years ago akismet.php 11 years ago captcha.php 11 years ago checkbox.php 11 years ago date.php 11 years ago file.php 11 years ago flamingo.php 11 years ago jetpack.php 12 years ago listo.php 12 years ago number.php 11 years ago quiz.php 11 years ago response.php 11 years ago select.php 11 years ago submit.php 11 years ago text.php 11 years ago textarea.php 11 years ago
textarea.php
158 lines
1 <?php
2 /**
3 ** A base module for [textarea] and [textarea*]
4 **/
5
6 /* Shortcode handler */
7
8 add_action( 'wpcf7_init', 'wpcf7_add_shortcode_textarea' );
9
10 function wpcf7_add_shortcode_textarea() {
11 wpcf7_add_shortcode( array( 'textarea', 'textarea*' ),
12 'wpcf7_textarea_shortcode_handler', true );
13 }
14
15 function wpcf7_textarea_shortcode_handler( $tag ) {
16 $tag = new WPCF7_Shortcode( $tag );
17
18 if ( empty( $tag->name ) )
19 return '';
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 $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['class'] = $tag->get_class_option( $class );
34 $atts['id'] = $tag->get_id_option();
35 $atts['tabindex'] = $tag->get_option( 'tabindex', 'int', true );
36
37 if ( $tag->has_option( 'readonly' ) )
38 $atts['readonly'] = 'readonly';
39
40 if ( $tag->is_required() )
41 $atts['aria-required'] = 'true';
42
43 $atts['aria-invalid'] = $validation_error ? 'true' : 'false';
44
45 $value = (string) reset( $tag->values );
46
47 if ( '' !== $tag->content )
48 $value = $tag->content;
49
50 if ( $tag->has_option( 'placeholder' ) || $tag->has_option( 'watermark' ) ) {
51 $atts['placeholder'] = $value;
52 $value = '';
53 }
54
55 $value = wpcf7_get_hangover( $tag->name, $value );
56
57 $atts['name'] = $tag->name;
58
59 $atts = wpcf7_format_atts( $atts );
60
61 $html = sprintf(
62 '<span class="wpcf7-form-control-wrap %1$s"><textarea %2$s>%3$s</textarea>%4$s</span>',
63 sanitize_html_class( $tag->name ), $atts,
64 esc_textarea( $value ), $validation_error );
65
66 return $html;
67 }
68
69
70 /* Validation filter */
71
72 add_filter( 'wpcf7_validate_textarea', 'wpcf7_textarea_validation_filter', 10, 2 );
73 add_filter( 'wpcf7_validate_textarea*', 'wpcf7_textarea_validation_filter', 10, 2 );
74
75 function wpcf7_textarea_validation_filter( $result, $tag ) {
76 $tag = new WPCF7_Shortcode( $tag );
77
78 $type = $tag->type;
79 $name = $tag->name;
80
81 $value = isset( $_POST[$name] ) ? (string) $_POST[$name] : '';
82
83 if ( 'textarea*' == $type ) {
84 if ( '' == $value ) {
85 $result['valid'] = false;
86 $result['reason'][$name] = wpcf7_get_message( 'invalid_required' );
87 }
88 }
89
90 if ( isset( $result['reason'][$name] ) && $id = $tag->get_id_option() ) {
91 $result['idref'][$name] = $id;
92 }
93
94 return $result;
95 }
96
97
98 /* Tag generator */
99
100 add_action( 'admin_init', 'wpcf7_add_tag_generator_textarea', 20 );
101
102 function wpcf7_add_tag_generator_textarea() {
103 if ( ! function_exists( 'wpcf7_add_tag_generator' ) )
104 return;
105
106 wpcf7_add_tag_generator( 'textarea', __( 'Text area', 'contact-form-7' ),
107 'wpcf7-tg-pane-textarea', 'wpcf7_tg_pane_textarea' );
108 }
109
110 function wpcf7_tg_pane_textarea( $contact_form ) {
111 ?>
112 <div id="wpcf7-tg-pane-textarea" class="hidden">
113 <form action="">
114 <table>
115 <tr><td><input type="checkbox" name="required" />&nbsp;<?php echo esc_html( __( 'Required field?', 'contact-form-7' ) ); ?></td></tr>
116 <tr><td><?php echo esc_html( __( 'Name', 'contact-form-7' ) ); ?><br /><input type="text" name="name" class="tg-name oneline" /></td><td></td></tr>
117 </table>
118
119 <table>
120 <tr>
121 <td><code>id</code> (<?php echo esc_html( __( 'optional', 'contact-form-7' ) ); ?>)<br />
122 <input type="text" name="id" class="idvalue oneline option" /></td>
123
124 <td><code>class</code> (<?php echo esc_html( __( 'optional', 'contact-form-7' ) ); ?>)<br />
125 <input type="text" name="class" class="classvalue oneline option" /></td>
126 </tr>
127
128 <tr>
129 <td><code>cols</code> (<?php echo esc_html( __( 'optional', 'contact-form-7' ) ); ?>)<br />
130 <input type="number" name="cols" class="numeric oneline option" min="1" /></td>
131
132 <td><code>rows</code> (<?php echo esc_html( __( 'optional', 'contact-form-7' ) ); ?>)<br />
133 <input type="number" name="rows" class="numeric oneline option" min="1" /></td>
134 </tr>
135
136 <tr>
137 <td><code>maxlength</code> (<?php echo esc_html( __( 'optional', 'contact-form-7' ) ); ?>)<br />
138 <input type="number" name="maxlength" class="numeric oneline option" min="1" /></td>
139 </tr>
140
141 <tr>
142 <td><?php echo esc_html( __( 'Default value', 'contact-form-7' ) ); ?> (<?php echo esc_html( __( 'optional', 'contact-form-7' ) ); ?>)<br /><input type="text" name="values" class="oneline" /></td>
143
144 <td>
145 <br /><input type="checkbox" name="placeholder" class="option" />&nbsp;<?php echo esc_html( __( 'Use this text as placeholder?', 'contact-form-7' ) ); ?>
146 </td>
147 </tr>
148 </table>
149
150 <div class="tg-tag"><?php echo esc_html( __( "Copy this code and paste it into the form left.", 'contact-form-7' ) ); ?><br /><input type="text" name="textarea" class="tag wp-ui-text-highlight code" readonly="readonly" onfocus="this.select()" /></div>
151
152 <div class="tg-mail-tag"><?php echo esc_html( __( "And, put this code into the Mail fields below.", 'contact-form-7' ) ); ?><br /><input type="text" class="mail-tag wp-ui-text-highlight code" readonly="readonly" onfocus="this.select()" /></div>
153 </form>
154 </div>
155 <?php
156 }
157
158 ?>