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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 / date.php
contact-form-7 / modules Last commit date
acceptance.php 12 years ago akismet.php 13 years ago captcha.php 12 years ago checkbox.php 12 years ago date.php 12 years ago file.php 12 years ago flamingo.php 12 years ago jetpack.php 12 years ago number.php 12 years ago quiz.php 12 years ago response.php 15 years ago select.php 12 years ago special-mail-tags.php 13 years ago submit.php 12 years ago text.php 12 years ago textarea.php 12 years ago
date.php
203 lines
1 <?php
2 /**
3 ** A base module for the following types of tags:
4 ** [date] and [date*] # Date
5 **/
6
7 /* Shortcode handler */
8
9 add_action( 'wpcf7_init', 'wpcf7_add_shortcode_date' );
10
11 function wpcf7_add_shortcode_date() {
12 wpcf7_add_shortcode( array( 'date', 'date*' ),
13 'wpcf7_date_shortcode_handler', true );
14 }
15
16 function wpcf7_date_shortcode_handler( $tag ) {
17 $tag = new WPCF7_Shortcode( $tag );
18
19 if ( empty( $tag->name ) )
20 return '';
21
22 $validation_error = wpcf7_get_validation_error( $tag->name );
23
24 $class = wpcf7_form_controls_class( $tag->type );
25
26 $class .= ' wpcf7-validates-as-date';
27
28 if ( $validation_error )
29 $class .= ' wpcf7-not-valid';
30
31 $atts = array();
32
33 $atts['class'] = $tag->get_class_option( $class );
34 $atts['id'] = $tag->get_option( 'id', 'id', true );
35 $atts['tabindex'] = $tag->get_option( 'tabindex', 'int', true );
36 $atts['min'] = $tag->get_option( 'min', 'date', true );
37 $atts['max'] = $tag->get_option( 'max', 'date', true );
38 $atts['step'] = $tag->get_option( 'step', 'int', true );
39
40 if ( $tag->has_option( 'readonly' ) )
41 $atts['readonly'] = 'readonly';
42
43 if ( $tag->is_required() )
44 $atts['aria-required'] = 'true';
45
46 $atts['aria-invalid'] = $validation_error ? 'true' : 'false';
47
48 $value = (string) reset( $tag->values );
49
50 if ( $tag->has_option( 'placeholder' ) || $tag->has_option( 'watermark' ) ) {
51 $atts['placeholder'] = $value;
52 $value = '';
53 }
54
55 if ( wpcf7_is_posted() && isset( $_POST[$tag->name] ) )
56 $value = stripslashes_deep( $_POST[$tag->name] );
57
58 $atts['value'] = $value;
59
60 if ( wpcf7_support_html5() ) {
61 $atts['type'] = $tag->basetype;
62 } else {
63 $atts['type'] = 'text';
64 }
65
66 $atts['name'] = $tag->name;
67
68 $atts = wpcf7_format_atts( $atts );
69
70 $html = sprintf(
71 '<span class="wpcf7-form-control-wrap %1$s"><input %2$s />%3$s</span>',
72 $tag->name, $atts, $validation_error );
73
74 return $html;
75 }
76
77
78 /* Validation filter */
79
80 add_filter( 'wpcf7_validate_date', 'wpcf7_date_validation_filter', 10, 2 );
81 add_filter( 'wpcf7_validate_date*', 'wpcf7_date_validation_filter', 10, 2 );
82
83 function wpcf7_date_validation_filter( $result, $tag ) {
84 $tag = new WPCF7_Shortcode( $tag );
85
86 $name = $tag->name;
87
88 $min = $tag->get_option( 'min', 'date', true );
89 $max = $tag->get_option( 'max', 'date', true );
90
91 $value = isset( $_POST[$name] )
92 ? trim( strtr( (string) $_POST[$name], "\n", " " ) )
93 : '';
94
95 if ( $tag->is_required() && '' == $value ) {
96 $result['valid'] = false;
97 $result['reason'][$name] = wpcf7_get_message( 'invalid_required' );
98 } elseif ( '' != $value && ! wpcf7_is_date( $value ) ) {
99 $result['valid'] = false;
100 $result['reason'][$name] = wpcf7_get_message( 'invalid_date' );
101 } elseif ( '' != $value && ! empty( $min ) && $value < $min ) {
102 $result['valid'] = false;
103 $result['reason'][$name] = wpcf7_get_message( 'date_too_early' );
104 } elseif ( '' != $value && ! empty( $max ) && $max < $value ) {
105 $result['valid'] = false;
106 $result['reason'][$name] = wpcf7_get_message( 'date_too_late' );
107 }
108
109 return $result;
110 }
111
112
113 /* Messages */
114
115 add_filter( 'wpcf7_messages', 'wpcf7_date_messages' );
116
117 function wpcf7_date_messages( $messages ) {
118 return array_merge( $messages, array(
119 'invalid_date' => array(
120 'description' => __( "Date format that the sender entered is invalid", 'contact-form-7' ),
121 'default' => __( 'Date format seems invalid.', 'contact-form-7' )
122 ),
123
124 'date_too_early' => array(
125 'description' => __( "Date is earlier than minimum limit", 'contact-form-7' ),
126 'default' => __( 'This date is too early.', 'contact-form-7' )
127 ),
128
129 'date_too_late' => array(
130 'description' => __( "Date is later than maximum limit", 'contact-form-7' ),
131 'default' => __( 'This date is too late.', 'contact-form-7' )
132 ) ) );
133 }
134
135
136 /* Tag generator */
137
138 add_action( 'admin_init', 'wpcf7_add_tag_generator_date', 19 );
139
140 function wpcf7_add_tag_generator_date() {
141 if ( ! function_exists( 'wpcf7_add_tag_generator' ) )
142 return;
143
144 wpcf7_add_tag_generator( 'date', __( 'Date', 'contact-form-7' ),
145 'wpcf7-tg-pane-date', 'wpcf7_tg_pane_date' );
146 }
147
148 function wpcf7_tg_pane_date( &$contact_form ) {
149 wpcf7_tg_pane_date_and_relatives( 'date' );
150 }
151
152 function wpcf7_tg_pane_date_and_relatives( $type = 'date' ) {
153 if ( ! in_array( $type, array() ) )
154 $type = 'date';
155
156 ?>
157 <div id="wpcf7-tg-pane-<?php echo $type; ?>" class="hidden">
158 <form action="">
159 <table>
160 <tr><td><input type="checkbox" name="required" />&nbsp;<?php echo esc_html( __( 'Required field?', 'contact-form-7' ) ); ?></td></tr>
161 <tr><td><?php echo esc_html( __( 'Name', 'contact-form-7' ) ); ?><br /><input type="text" name="name" class="tg-name oneline" /></td><td></td></tr>
162 </table>
163
164 <table>
165 <tr>
166 <td><code>id</code> (<?php echo esc_html( __( 'optional', 'contact-form-7' ) ); ?>)<br />
167 <input type="text" name="id" class="idvalue oneline option" /></td>
168
169 <td><code>class</code> (<?php echo esc_html( __( 'optional', 'contact-form-7' ) ); ?>)<br />
170 <input type="text" name="class" class="classvalue oneline option" /></td>
171 </tr>
172
173 <tr>
174 <td><code>min</code> (<?php echo esc_html( __( 'optional', 'contact-form-7' ) ); ?>)<br />
175 <input type="date" name="min" class="date oneline option" /></td>
176
177 <td><code>max</code> (<?php echo esc_html( __( 'optional', 'contact-form-7' ) ); ?>)<br />
178 <input type="date" name="max" class="date oneline option" /></td>
179 </tr>
180
181 <tr>
182 <td><code>step</code> (<?php echo esc_html( __( 'optional', 'contact-form-7' ) ); ?>)<br />
183 <input type="number" name="step" class="numeric oneline option" min="1" /></td>
184 </tr>
185
186 <tr>
187 <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>
188
189 <td>
190 <br /><input type="checkbox" name="placeholder" class="option" />&nbsp;<?php echo esc_html( __( 'Use this text as placeholder?', 'contact-form-7' ) ); ?>
191 </td>
192 </tr>
193 </table>
194
195 <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="<?php echo $type; ?>" class="tag wp-ui-text-highlight code" readonly="readonly" onfocus="this.select()" /></div>
196
197 <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>
198 </form>
199 </div>
200 <?php
201 }
202
203 ?>