Contact Form 7 Datepicker - Version 2.2

Version Description

  • Added basic date validation
  • Fixed watermark
Download this release

Release Info

Developer shockware
Plugin Icon wp plugin Contact Form 7 Datepicker
Version 2.2
Comparing to
See all releases

Code changes from version 2.1 to 2.2

contact-form-7-datepicker.php CHANGED
@@ -4,7 +4,7 @@ Plugin Name: Contact Form 7 Datepicker
4
Plugin URI: https://github.com/relu/contact-form-7-datepicker/
5
Description: Easily add a date field using jQuery UI's datepicker to your CF7 forms. This plugin depends on Contact Form 7.
6
Author: Aurel Canciu
7
- Version: 2.1
8
Author URI: https://github.com/relu/
9
*/
10
@@ -53,7 +53,7 @@ class ContactForm7Datepicker {
53
}
54
55
public static function enqueue_js() {
56
- wp_enqueue_script('jquery-ui-datepicker');
57
58
$regional = CF7_DatePicker::get_regional_match();
59
@@ -64,8 +64,8 @@ class ContactForm7Datepicker {
64
'jquery-ui-' . $regional,
65
'http://ajax.googleapis.com/ajax/libs/jqueryui/1/i18n/jquery.ui.datepicker-' . $regional . '.min.js',
66
array('jquery-ui-datepicker'),
67
- '',
68
- false
69
);
70
}
71
4
Plugin URI: https://github.com/relu/contact-form-7-datepicker/
5
Description: Easily add a date field using jQuery UI's datepicker to your CF7 forms. This plugin depends on Contact Form 7.
6
Author: Aurel Canciu
7
+ Version: 2.2
8
Author URI: https://github.com/relu/
9
*/
10
53
}
54
55
public static function enqueue_js() {
56
+ wp_enqueue_script('jquery-ui-datepicker', null, null, null, true);
57
58
$regional = CF7_DatePicker::get_regional_match();
59
64
'jquery-ui-' . $regional,
65
'http://ajax.googleapis.com/ajax/libs/jqueryui/1/i18n/jquery.ui.datepicker-' . $regional . '.min.js',
66
array('jquery-ui-datepicker'),
67
+ null,
68
+ true
69
);
70
}
71
date-module.php CHANGED
@@ -15,6 +15,9 @@ class ContactForm7Datepicker_Date {
15
16
// Tag generator
17
add_action('load-toplevel_page_wpcf7', array(__CLASS__, 'tag_generator'));
18
}
19
20
public static function shortcode_handler($tag) {
@@ -68,7 +71,7 @@ class ContactForm7Datepicker_Date {
68
} elseif (preg_match('%^change-year$%i', $option, $matches)) {
69
$dpOptions['changeYear'] = true;
70
} elseif (preg_match('%^year-range:(\d+)-?(\d+)?$%', $option, $matches)) {
71
- $dpOptions['yearRange'] = "{$matches[1]}:{$matches[2]}";
72
} elseif (preg_match('%^months:(\d+)$%', $option, $matches)) {
73
$dpOptions['numberOfMonths'] = (int) $matches[1];
74
} elseif (preg_match('%^buttons$%', $option, $matches)) {
@@ -83,7 +86,7 @@ class ContactForm7Datepicker_Date {
83
84
$value = reset($values);
85
86
- if (wpcf7_script_is() && preg_grep('%^waremark$%', $options)) {
87
$class_att .= ' wpcf7-use-title-as-watermark';
88
$title_att .= " $value";
89
$value = '';
@@ -143,11 +146,17 @@ class ContactForm7Datepicker_Date {
143
144
$value = trim($_POST[$name]);
145
146
- if ('date*' == $type && '' == $value) {
147
$result['valid'] = false;
148
$result['reason'][$name] = wpcf7_get_message('invalid_required');
149
}
150
151
return $result;
152
}
153
@@ -170,6 +179,14 @@ class ContactForm7Datepicker_Date {
170
}
171
}
172
173
174
private static function animate_dropdown() {
175
$effects = array(
@@ -196,4 +213,8 @@ class ContactForm7Datepicker_Date {
196
197
echo $html;
198
}
199
}
15
16
// Tag generator
17
add_action('load-toplevel_page_wpcf7', array(__CLASS__, 'tag_generator'));
18
+
19
+ // Messages
20
+ add_filter('wpcf7_messages', array(__CLASS__, 'messages'));
21
}
22
23
public static function shortcode_handler($tag) {
71
} elseif (preg_match('%^change-year$%i', $option, $matches)) {
72
$dpOptions['changeYear'] = true;
73
} elseif (preg_match('%^year-range:(\d+)-?(\d+)?$%', $option, $matches)) {
74
+ $dpOptions['yearRange'] = $matches[1] . ':' . @$matches[2];
75
} elseif (preg_match('%^months:(\d+)$%', $option, $matches)) {
76
$dpOptions['numberOfMonths'] = (int) $matches[1];
77
} elseif (preg_match('%^buttons$%', $option, $matches)) {
86
87
$value = reset($values);
88
89
+ if (wpcf7_script_is() && preg_grep('%^watermark$%', $options)) {
90
$class_att .= ' wpcf7-use-title-as-watermark';
91
$title_att .= " $value";
92
$value = '';
146
147
$value = trim($_POST[$name]);
148
149
+ if ('date*' == $type && empty($value)) {
150
$result['valid'] = false;
151
$result['reason'][$name] = wpcf7_get_message('invalid_required');
152
}
153
154
+ // TODO: Implement date format verification
155
+ if (! empty($value) && ! self::is_valid_date($value)) {
156
+ $result['valid'] = false;
157
+ $result['reason'][$name] = wpcf7_get_message('invalid_date');
158
+ }
159
+
160
return $result;
161
}
162
179
}
180
}
181
182
+ public static function messages($messages) {
183
+ $messages['invalid_date'] = array(
184
+ 'description' => __('The date that the sender entered is invalid'),
185
+ 'default' => __('Invalid date supplied.'),
186
+ );
187
+
188
+ return $messages;
189
+ }
190
191
private static function animate_dropdown() {
192
$effects = array(
213
214
echo $html;
215
}
216
+
217
+ private static function is_valid_date($value) {
218
+ return strtotime($value) ? true : false;
219
+ }
220
}
datepicker.php CHANGED
@@ -9,11 +9,11 @@ class CF7_DatePicker {
9
'maxDate' => '',
10
'firstDay' => '',
11
'defaultDate' => '',
12
- 'showAnim' => 'show',
13
'changeMonth' => '',
14
'changeYear' => '',
15
'yearRange' => '',
16
- 'numberOfMonths' => 1,
17
'showButtonPanel' => '',
18
);
19
9
'maxDate' => '',
10
'firstDay' => '',
11
'defaultDate' => '',
12
+ 'showAnim' => '',
13
'changeMonth' => '',
14
'changeYear' => '',
15
'yearRange' => '',
16
+ 'numberOfMonths' => '',
17
'showButtonPanel' => '',
18
);
19
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: shockware
3
Tags: wordpress, datepicker, calendar, contact form 7, forms, jqueryui
4
Requires at least: 2.9
5
Tested up to: 3.5
6
- Stable tag: 2.1
7
License: GPLv2 or later
8
License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
@@ -34,6 +34,10 @@ You can [open an issue on github](https://github.com/relu/contact-form-7-datepic
34
35
== Changelog ==
36
37
= 2.1 =
38
* Added inline option
39
* Fixed tag generator
3
Tags: wordpress, datepicker, calendar, contact form 7, forms, jqueryui
4
Requires at least: 2.9
5
Tested up to: 3.5
6
+ Stable tag: 2.2
7
License: GPLv2 or later
8
License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
34
35
== Changelog ==
36
37
+ = 2.2 =
38
+ * Added basic date validation
39
+ * Fixed watermark
40
+
41
= 2.1 =
42
* Added inline option
43
* Fixed tag generator