Version Description
- Added inline option
- Fixed tag generator
- Fixed date format when localized
Download this release
Release Info
Developer | shockware |
Plugin | Contact Form 7 Datepicker |
Version | 2.1 |
Comparing to | |
See all releases |
Code changes from version 2.0 to 2.1
- contact-form-7-datepicker.php +1 -1
- date-module.php +33 -19
- date-tag-generator.php +23 -31
- datepicker.php +2 -2
- readme.txt +10 -4
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.
|
8 |
Author URI: https://github.com/relu/
|
9 |
*/
|
10 |
|
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 |
|
date-module.php
CHANGED
@@ -42,38 +42,43 @@ class ContactForm7Datepicker_Date {
|
|
42 |
if ($validation_error)
|
43 |
$class_att .= ' wpcf7-not-valid';
|
44 |
|
|
|
|
|
45 |
$dpOptions = array();
|
46 |
foreach ($options as $option) {
|
47 |
-
if (preg_match('%^id:([-
|
48 |
$id_att = $matches[1];
|
49 |
-
} elseif (preg_match('%^class:([-
|
50 |
$class_att .= " $matches[1]";
|
51 |
-
} elseif (preg_match('%^(
|
52 |
$size_att = (int) $matches[1];
|
53 |
$maxlen_att = (int) $matches[2];
|
54 |
} elseif (preg_match('%^tabindex:(\d+)$%i', $option, $matches)) {
|
55 |
$tabindex_att = (int) $matches[1];
|
56 |
-
} elseif (preg_match('%^date-format:([-_
|
57 |
$dpOptions['dateFormat'] = str_replace('_', ' ', $matches[1]);
|
58 |
-
} elseif (preg_match('%^(min|max)-date:([-_
|
59 |
$dpOptions[$matches[1] . 'Date'] = $matches[2];
|
60 |
} elseif (preg_match('%^first-day:(\d)$%', $option, $matches)) {
|
61 |
$dpOptions['firstDay'] = (int) $matches[1];
|
62 |
-
} elseif (preg_match('%^animate:(
|
63 |
$dpOptions['showAnim'] = $matches[1];
|
64 |
-
} elseif (preg_match('%^change-month
|
65 |
-
$dpOptions['changeMonth'] =
|
66 |
-
} elseif (preg_match('%^change-year
|
67 |
-
$dpOptions['changeYear'] =
|
68 |
-
} elseif (preg_match('%^year-range:(
|
69 |
$dpOptions['yearRange'] = "{$matches[1]}:{$matches[2]}";
|
70 |
-
} elseif (preg_match('%^months:(
|
71 |
$dpOptions['numberOfMonths'] = (int) $matches[1];
|
72 |
-
} elseif (preg_match('%^buttons
|
73 |
-
$dpOptions['showButtonPanel'] =
|
|
|
|
|
|
|
74 |
}
|
75 |
|
76 |
-
|
77 |
}
|
78 |
|
79 |
$value = reset($values);
|
@@ -107,19 +112,28 @@ class ContactForm7Datepicker_Date {
|
|
107 |
if ($title_att)
|
108 |
$atts .= ' title="' . trim(esc_attr($title_att)) . '"';
|
109 |
|
110 |
-
$
|
|
|
|
|
|
|
|
|
111 |
esc_attr($name),
|
112 |
esc_attr($value),
|
113 |
-
$
|
114 |
);
|
115 |
|
116 |
-
|
|
|
|
|
|
|
|
|
|
|
117 |
|
118 |
return sprintf('<span class="wpcf7-form-control-wrap %s">%s %s</span>%s',
|
119 |
esc_attr($name),
|
120 |
$input,
|
121 |
$validation_error,
|
122 |
-
$dp->generate_code()
|
123 |
);
|
124 |
}
|
125 |
|
42 |
if ($validation_error)
|
43 |
$class_att .= ' wpcf7-not-valid';
|
44 |
|
45 |
+
$inline = false;
|
46 |
+
|
47 |
$dpOptions = array();
|
48 |
foreach ($options as $option) {
|
49 |
+
if (preg_match('%^id:([-_\w\d]+)$%i', $option, $matches)) {
|
50 |
$id_att = $matches[1];
|
51 |
+
} elseif (preg_match('%^class:([-_\w\d]+)$%i', $option, $matches)) {
|
52 |
$class_att .= " $matches[1]";
|
53 |
+
} elseif (preg_match('%^(\d*)[/x](\d*)$%i', $option, $matches)) {
|
54 |
$size_att = (int) $matches[1];
|
55 |
$maxlen_att = (int) $matches[2];
|
56 |
} elseif (preg_match('%^tabindex:(\d+)$%i', $option, $matches)) {
|
57 |
$tabindex_att = (int) $matches[1];
|
58 |
+
} elseif (preg_match('%^date-format:([-_/\.\w\d]+)$%i', $option, $matches)) {
|
59 |
$dpOptions['dateFormat'] = str_replace('_', ' ', $matches[1]);
|
60 |
+
} elseif (preg_match('%^(min|max)-date:([-_/\.\w\d]+)$%i', $option, $matches)) {
|
61 |
$dpOptions[$matches[1] . 'Date'] = $matches[2];
|
62 |
} elseif (preg_match('%^first-day:(\d)$%', $option, $matches)) {
|
63 |
$dpOptions['firstDay'] = (int) $matches[1];
|
64 |
+
} elseif (preg_match('%^animate:(\w+)$%i', $option, $matches)) {
|
65 |
$dpOptions['showAnim'] = $matches[1];
|
66 |
+
} elseif (preg_match('%^change-month$%i', $option, $matches)) {
|
67 |
+
$dpOptions['changeMonth'] = true;
|
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)) {
|
75 |
+
$dpOptions['showButtonPanel'] = true;
|
76 |
+
} elseif (preg_match('%inline$%', $option, $matches)) {
|
77 |
+
$inline = true;
|
78 |
+
$dpOptions['altField'] = "#{$name}_alt";
|
79 |
}
|
80 |
|
81 |
+
do_action_ref_array('cf7_datepicker_attr_match', array($dpOptions), $option);
|
82 |
}
|
83 |
|
84 |
$value = reset($values);
|
112 |
if ($title_att)
|
113 |
$atts .= ' title="' . trim(esc_attr($title_att)) . '"';
|
114 |
|
115 |
+
$input_type = $inline ? 'hidden' : 'text';
|
116 |
+
$input_atts = $inline ? "id=\"{$name}_alt\"" : $atts;
|
117 |
+
|
118 |
+
$input = sprintf('<input type="%s" name="%s" value="%s" %s/>',
|
119 |
+
$input_type,
|
120 |
esc_attr($name),
|
121 |
esc_attr($value),
|
122 |
+
$input_atts
|
123 |
);
|
124 |
|
125 |
+
if ($inline)
|
126 |
+
$input .= sprintf('<div id="%s_datepicker" %s></div>', $name, $atts);
|
127 |
+
|
128 |
+
$dp_selector = $inline ? '#' . $name . '_datepicker' : $name;
|
129 |
+
|
130 |
+
$dp = new CF7_DatePicker($dp_selector, $dpOptions);
|
131 |
|
132 |
return sprintf('<span class="wpcf7-form-control-wrap %s">%s %s</span>%s',
|
133 |
esc_attr($name),
|
134 |
$input,
|
135 |
$validation_error,
|
136 |
+
$dp->generate_code($inline)
|
137 |
);
|
138 |
}
|
139 |
|
date-tag-generator.php
CHANGED
@@ -59,11 +59,12 @@
|
|
59 |
<tr>
|
60 |
<td>
|
61 |
<code>first-day</code><br />
|
62 |
-
<input type="
|
63 |
-
<
|
64 |
-
|
65 |
-
|
66 |
-
|
|
|
67 |
</td>
|
68 |
<td>
|
69 |
<code>animate</code><br />
|
@@ -74,44 +75,35 @@
|
|
74 |
|
75 |
<tr>
|
76 |
<td>
|
77 |
-
<code>change-month</code
|
78 |
-
<input type="text" name="change-month" class="option" style="display: none" />
|
79 |
-
<select id="change-month">
|
80 |
-
<option value="true"><?php _e('True'); ?></option>
|
81 |
-
<option value="false"><?php _e('False'); ?></option>
|
82 |
-
</select>
|
83 |
</td>
|
84 |
</tr>
|
85 |
|
86 |
<tr>
|
87 |
<td>
|
88 |
-
<code>change-year</code
|
89 |
-
<input type="text" name="change-year" class="option" style="display: none" />
|
90 |
-
<select id="change-year">
|
91 |
-
<option value="true"><?php _e('True'); ?></option>
|
92 |
-
<option value="false" selected="selected"><?php _e('False'); ?></option>
|
93 |
-
</select>
|
94 |
</td>
|
95 |
<td>
|
96 |
<code>year-range</code><br />
|
97 |
-
<input type="text" name="year-range" class="option" style="display: none"/>
|
98 |
-
<input size="4" type="text" name="year-range-start" class="numeric" /> -
|
99 |
-
<input size="4"type="text" name="year-range-end" class="numeric" />
|
100 |
</td>
|
101 |
</tr>
|
102 |
|
103 |
<tr>
|
104 |
<td>
|
105 |
<code>months</code><br />
|
106 |
-
<input type="text" size="2" name="months" class="option"/>
|
|
|
|
|
|
|
107 |
</td>
|
|
|
|
|
|
|
108 |
<td>
|
109 |
-
<code>
|
110 |
-
<input type="text" name="buttons" class="option" style="display: none" />
|
111 |
-
<select id="buttons">
|
112 |
-
<option value="true"><?php _e('True'); ?></option>
|
113 |
-
<option value="false" selected="selected"><?php _e('False'); ?></option>
|
114 |
-
</select>
|
115 |
</td>
|
116 |
</tr>
|
117 |
|
@@ -134,23 +126,23 @@
|
|
134 |
|
135 |
<script type="text/javascript">
|
136 |
jQuery(function($){
|
137 |
-
$('select'
|
138 |
var $this = $(this),
|
139 |
value = $this.val();
|
140 |
|
141 |
if (! value)
|
142 |
return;
|
143 |
|
144 |
-
$('input[name="'+$this.attr('id')+'"]').val(value);
|
145 |
});
|
146 |
|
147 |
-
$('
|
148 |
var value = $('input[name="year-range-start"]').val() + '-' + $('input[name="year-range-end"]').val();
|
149 |
|
150 |
if (! value)
|
151 |
return;
|
152 |
|
153 |
-
$('
|
154 |
});
|
155 |
});
|
156 |
</script>
|
59 |
<tr>
|
60 |
<td>
|
61 |
<code>first-day</code><br />
|
62 |
+
<input type="checkbox" id="first-day-sunday" name="first-day:0" class="option exclusive" />
|
63 |
+
<label for="first-day-sunday"><?php _e('Sunday'); ?></label>
|
64 |
+
|
65 |
+
|
66 |
+
<input type="checkbox" value="1" id="first-day-monday" name="first-day:1" class="option exclusive" />
|
67 |
+
<label for="first-day-monday"><?php _e('Monday'); ?></label>
|
68 |
</td>
|
69 |
<td>
|
70 |
<code>animate</code><br />
|
75 |
|
76 |
<tr>
|
77 |
<td>
|
78 |
+
<label><code>change-month</code> <input type="checkbox" name="change-month" id="change-month" class="option" /></label>
|
|
|
|
|
|
|
|
|
|
|
79 |
</td>
|
80 |
</tr>
|
81 |
|
82 |
<tr>
|
83 |
<td>
|
84 |
+
<label><code>change-year</code> <input type="checkbox" name="change-year" id="change-year" class="option" /></label>
|
|
|
|
|
|
|
|
|
|
|
85 |
</td>
|
86 |
<td>
|
87 |
<code>year-range</code><br />
|
88 |
+
<input type="text" id="year-range" name="year-range" class="option" style="display: none;" />
|
89 |
+
<input size="4" type="text" name="year-range-start" class="year-range numeric" /> -
|
90 |
+
<input size="4"type="text" name="year-range-end" class="year-range numeric" />
|
91 |
</td>
|
92 |
</tr>
|
93 |
|
94 |
<tr>
|
95 |
<td>
|
96 |
<code>months</code><br />
|
97 |
+
<input type="text" size="2" name="months" class="option numeric"/>
|
98 |
+
</td>
|
99 |
+
<td>
|
100 |
+
<label><code>buttons</code> <input type="checkbox" name="buttons" class="option" /></label>
|
101 |
</td>
|
102 |
+
</tr>
|
103 |
+
|
104 |
+
<tr>
|
105 |
<td>
|
106 |
+
<label><code>inline</code> <input type="checkbox" name="inline" class="option" /></label>
|
|
|
|
|
|
|
|
|
|
|
107 |
</td>
|
108 |
</tr>
|
109 |
|
126 |
|
127 |
<script type="text/javascript">
|
128 |
jQuery(function($){
|
129 |
+
$(document).on('change', 'select', function(){
|
130 |
var $this = $(this),
|
131 |
value = $this.val();
|
132 |
|
133 |
if (! value)
|
134 |
return;
|
135 |
|
136 |
+
$('input[name="'+$this.attr('id')+'"]').val(value).trigger('change');
|
137 |
});
|
138 |
|
139 |
+
$(document).on('keyup', '.year-range', function(){
|
140 |
var value = $('input[name="year-range-start"]').val() + '-' + $('input[name="year-range-end"]').val();
|
141 |
|
142 |
if (! value)
|
143 |
return;
|
144 |
|
145 |
+
$('#year-range').val(value);
|
146 |
});
|
147 |
});
|
148 |
</script>
|
datepicker.php
CHANGED
@@ -110,8 +110,8 @@ class CF7_DatePicker {
|
|
110 |
public function generate_code($inline = false) {
|
111 |
$selector = ($inline) ? "$('$this->input_name')" : "$('input[name=\"{$this->input_name}\"]')";
|
112 |
|
113 |
-
$out =
|
114 |
-
$out .=
|
115 |
|
116 |
$out = "jQuery(function($){ $out });";
|
117 |
|
110 |
public function generate_code($inline = false) {
|
111 |
$selector = ($inline) ? "$('$this->input_name')" : "$('input[name=\"{$this->input_name}\"]')";
|
112 |
|
113 |
+
$out = self::_regionalize($selector);
|
114 |
+
$out .= "{$selector}.datepicker({$this->options_encode()});\n";
|
115 |
|
116 |
$out = "jQuery(function($){ $out });";
|
117 |
|
readme.txt
CHANGED
@@ -1,10 +1,11 @@
|
|
1 |
=== Plugin Name ===
|
2 |
Contributors: shockware
|
3 |
-
Donate link:
|
4 |
Tags: wordpress, datepicker, calendar, contact form 7, forms, jqueryui
|
5 |
-
Requires at least:
|
6 |
-
Tested up to:
|
7 |
-
Stable tag: 2.
|
|
|
|
|
8 |
|
9 |
Easily add a date field using jQuery UI's datepicker to your CF7 forms.
|
10 |
This plugin depends on Contact Form 7.
|
@@ -33,6 +34,11 @@ You can [open an issue on github](https://github.com/relu/contact-form-7-datepic
|
|
33 |
|
34 |
== Changelog ==
|
35 |
|
|
|
|
|
|
|
|
|
|
|
36 |
= 2.0 =
|
37 |
* Complete rewrite, using jquery-ui's datepicker
|
38 |
|
1 |
=== Plugin Name ===
|
2 |
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 |
|
10 |
Easily add a date field using jQuery UI's datepicker to your CF7 forms.
|
11 |
This plugin depends on Contact Form 7.
|
34 |
|
35 |
== Changelog ==
|
36 |
|
37 |
+
= 2.1 =
|
38 |
+
* Added inline option
|
39 |
+
* Fixed tag generator
|
40 |
+
* Fixed date format when localized
|
41 |
+
|
42 |
= 2.0 =
|
43 |
* Complete rewrite, using jquery-ui's datepicker
|
44 |
|