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.1 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 11 years ago akismet.php 11 years ago captcha.php 11 years ago checkbox.php 11 years ago count.php 11 years ago date.php 11 years ago file.php 11 years ago flamingo.php 11 years ago jetpack.php 11 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
date.php
224 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_id_option();
35 $atts['tabindex'] = $tag->get_option( 'tabindex', 'int', true );
36 $atts['min'] = $tag->get_date_option( 'min' );
37 $atts['max'] = $tag->get_date_option( 'max' );
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 $value = $tag->get_default_option( $value );
56
57 $value = wpcf7_get_hangover( $tag->name, $value );
58
59 $atts['value'] = $value;
60
61 if ( wpcf7_support_html5() ) {
62 $atts['type'] = $tag->basetype;
63 } else {
64 $atts['type'] = 'text';
65 }
66
67 $atts['name'] = $tag->name;
68
69 $atts = wpcf7_format_atts( $atts );
70
71 $html = sprintf(
72 '<span class="wpcf7-form-control-wrap %1$s"><input %2$s />%3$s</span>',
73 sanitize_html_class( $tag->name ), $atts, $validation_error );
74
75 return $html;
76 }
77
78
79 /* Validation filter */
80
81 add_filter( 'wpcf7_validate_date', 'wpcf7_date_validation_filter', 10, 2 );
82 add_filter( 'wpcf7_validate_date*', 'wpcf7_date_validation_filter', 10, 2 );
83
84 function wpcf7_date_validation_filter( $result, $tag ) {
85 $tag = new WPCF7_Shortcode( $tag );
86
87 $name = $tag->name;
88
89 $min = $tag->get_date_option( 'min' );
90 $max = $tag->get_date_option( 'max' );
91
92 $value = isset( $_POST[$name] )
93 ? trim( strtr( (string) $_POST[$name], "\n", " " ) )
94 : '';
95
96 if ( $tag->is_required() && '' == $value ) {
97 $result->invalidate( $tag, wpcf7_get_message( 'invalid_required' ) );
98 } elseif ( '' != $value && ! wpcf7_is_date( $value ) ) {
99 $result->invalidate( $tag, wpcf7_get_message( 'invalid_date' ) );
100 } elseif ( '' != $value && ! empty( $min ) && $value < $min ) {
101 $result->invalidate( $tag, wpcf7_get_message( 'date_too_early' ) );
102 } elseif ( '' != $value && ! empty( $max ) && $max < $value ) {
103 $result->invalidate( $tag, wpcf7_get_message( 'date_too_late' ) );
104 }
105
106 return $result;
107 }
108
109
110 /* Messages */
111
112 add_filter( 'wpcf7_messages', 'wpcf7_date_messages' );
113
114 function wpcf7_date_messages( $messages ) {
115 return array_merge( $messages, array(
116 'invalid_date' => array(
117 'description' => __( "Date format that the sender entered is invalid", 'contact-form-7' ),
118 'default' => __( 'Date format seems invalid.', 'contact-form-7' )
119 ),
120
121 'date_too_early' => array(
122 'description' => __( "Date is earlier than minimum limit", 'contact-form-7' ),
123 'default' => __( 'This date is too early.', 'contact-form-7' )
124 ),
125
126 'date_too_late' => array(
127 'description' => __( "Date is later than maximum limit", 'contact-form-7' ),
128 'default' => __( 'This date is too late.', 'contact-form-7' )
129 ) ) );
130 }
131
132
133 /* Tag generator */
134
135 add_action( 'admin_init', 'wpcf7_add_tag_generator_date', 19 );
136
137 function wpcf7_add_tag_generator_date() {
138 $tag_generator = WPCF7_TagGenerator::get_instance();
139 $tag_generator->add( 'date', __( 'date', 'contact-form-7' ),
140 'wpcf7_tag_generator_date' );
141 }
142
143 function wpcf7_tag_generator_date( $contact_form, $args = '' ) {
144 $args = wp_parse_args( $args, array() );
145 $type = 'date';
146
147 $description = __( "Generate a form-tag for a date input field. For more details, see %s.", 'contact-form-7' );
148
149 $desc_link = wpcf7_link( __( 'http://contactform7.com/date-field/', 'contact-form-7' ), __( 'Date Field', 'contact-form-7' ) );
150
151 ?>
152 <div class="control-box">
153 <fieldset>
154 <legend><?php echo sprintf( esc_html( $description ), $desc_link ); ?></legend>
155
156 <table class="form-table">
157 <tbody>
158 <tr>
159 <th scope="row"><?php echo esc_html( __( 'Field type', 'contact-form-7' ) ); ?></th>
160 <td>
161 <fieldset>
162 <legend class="screen-reader-text"><?php echo esc_html( __( 'Field type', 'contact-form-7' ) ); ?></legend>
163 <label><input type="checkbox" name="required" /> <?php echo esc_html( __( 'Required field', 'contact-form-7' ) ); ?></label>
164 </fieldset>
165 </td>
166 </tr>
167
168 <tr>
169 <th scope="row"><label for="<?php echo esc_attr( $args['content'] . '-name' ); ?>"><?php echo esc_html( __( 'Name', 'contact-form-7' ) ); ?></label></th>
170 <td><input type="text" name="name" class="tg-name oneline" id="<?php echo esc_attr( $args['content'] . '-name' ); ?>" /></td>
171 </tr>
172
173 <tr>
174 <th scope="row"><label for="<?php echo esc_attr( $args['content'] . '-values' ); ?>"><?php echo esc_html( __( 'Default value', 'contact-form-7' ) ); ?></label></th>
175 <td><input type="text" name="values" class="oneline" id="<?php echo esc_attr( $args['content'] . '-values' ); ?>" /><br />
176 <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>
177 </tr>
178
179 <tr>
180 <th scope="row"><?php echo esc_html( __( 'Range', 'contact-form-7' ) ); ?></th>
181 <td>
182 <fieldset>
183 <legend class="screen-reader-text"><?php echo esc_html( __( 'Range', 'contact-form-7' ) ); ?></legend>
184 <label>
185 <?php echo esc_html( __( 'Min', 'contact-form-7' ) ); ?>
186 <input type="date" name="min" class="date option" />
187 </label>
188 &ndash;
189 <label>
190 <?php echo esc_html( __( 'Max', 'contact-form-7' ) ); ?>
191 <input type="date" name="max" class="date option" />
192 </label>
193 </fieldset>
194 </td>
195 </tr>
196
197 <tr>
198 <th scope="row"><label for="<?php echo esc_attr( $args['content'] . '-id' ); ?>"><?php echo esc_html( __( 'Id attribute', 'contact-form-7' ) ); ?></label></th>
199 <td><input type="text" name="id" class="idvalue oneline option" id="<?php echo esc_attr( $args['content'] . '-id' ); ?>" /></td>
200 </tr>
201
202 <tr>
203 <th scope="row"><label for="<?php echo esc_attr( $args['content'] . '-class' ); ?>"><?php echo esc_html( __( 'Class attribute', 'contact-form-7' ) ); ?></label></th>
204 <td><input type="text" name="class" class="classvalue oneline option" id="<?php echo esc_attr( $args['content'] . '-class' ); ?>" /></td>
205 </tr>
206 </tbody>
207 </table>
208 </fieldset>
209 </div>
210
211 <div class="insert-box">
212 <input type="text" name="<?php echo $type; ?>" class="tag code" readonly="readonly" onfocus="this.select()" />
213
214 <div class="submitbox">
215 <input type="button" class="button button-primary insert-tag" value="<?php echo esc_attr( __( 'Insert Tag', 'contact-form-7' ) ); ?>" />
216 </div>
217
218 <br class="clear" />
219
220 <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>
221 </div>
222 <?php
223 }
224