... | ... |
@@ -12,12 +12,21 @@ jQuery(document).ready(function(){ |
12 | 12 |
var day = jQuery('select[name="rc_day"]').val(); |
13 | 13 |
var hour = jQuery('select[name="rc_hour"]').val(); |
14 | 14 |
var min = jQuery('select[name="rc_minutes"]').val(); |
15 |
- newDate = new Date(year, month - 1, day, hour, min); |
|
15 |
+ var newDate = new Date(year, month - 1, day, hour, min); |
|
16 |
+ var now = new Date(); |
|
17 |
+ var flg = false; |
|
16 | 18 |
if(newDate.getFullYear() != year || (1 + newDate.getMonth()) != month || newDate.getDate() != day || newDate.getMinutes() != min){ |
17 |
- jQuery('.rc-datetime-wrap').addClass('form-invalid'); |
|
18 |
- return false; |
|
19 |
+ flg = false; |
|
20 |
+ } else if (newDate.getTime() < now.getTime()) { |
|
21 |
+ flg = false; |
|
19 | 22 |
} else { |
23 |
+ flg = true; |
|
24 |
+ } |
|
25 |
+ if(flg === true){ |
|
20 | 26 |
jQuery('.rc-datetime-wrap').removeClass('form-invalid'); |
27 |
+ } else { |
|
28 |
+ jQuery('.rc-datetime-wrap').addClass('form-invalid'); |
|
29 |
+ return false; |
|
21 | 30 |
} |
22 | 31 |
jQuery('.rc-datetime > b').html(year + "/" + month + "/" + day + " @ " + hour + ":" + min); |
23 | 32 |
jQuery('#rc_year_cr').val(year); |
... | ... |
@@ -3,7 +3,7 @@ Contributors: gips-nita |
3 | 3 |
Tags: post, update content, update post, update page, schedule update, reserve update, reservation update, rucy, Rucy |
4 | 4 |
Requires at least: 3.5+ |
5 | 5 |
Tested up to: 3.9 |
6 |
-Stable tag: 0.1.2 |
|
6 |
+Stable tag: 0.2.0 |
|
7 | 7 |
License: GPLv2 or later |
8 | 8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html |
9 | 9 |
|
... | ... |
@@ -37,6 +37,12 @@ You can install this plugin directly from your WordPress dashboard: |
37 | 37 |
|
38 | 38 |
== Changelog == |
39 | 39 |
|
40 |
+= 0.2.0 = |
|
41 |
+* 2014-06-13 |
|
42 |
+* fixed Bugs. |
|
43 |
+* change input type reservation datetime. |
|
44 |
+* add check validation reservation datetime is past. |
|
45 |
+ |
|
40 | 46 |
= 0.1.2 = |
41 | 47 |
* 2014-05-04 |
42 | 48 |
* add reservation datetime post updated messages. |
... | ... |
@@ -73,10 +73,10 @@ function add_rucy_metabox_out() |
73 | 73 |
$reserv_date = $rcMetas['date']; |
74 | 74 |
if("" == $reserv_date) |
75 | 75 |
{ |
76 |
- $reserv_date = date('Y-m-d H:i:s'); |
|
76 |
+ $reserv_date = date_i18n('Y-m-d H:i:s'); |
|
77 | 77 |
} |
78 | 78 |
$reserv_date_arr = getdate(strtotime($reserv_date)); |
79 |
- $current_y = date('Y',$reserv_date_arr[0]); |
|
79 |
+ $current_y = date_i18n('Y'); |
|
80 | 80 |
$reserv_content = $rcMetas['content']; |
81 | 81 |
if("" == $reserv_content) |
82 | 82 |
{ |
... | ... |
@@ -89,7 +89,7 @@ function add_rucy_metabox_out() |
89 | 89 |
<input type="checkbox" name="<?php echo $rc_accept_name; ?>" value="1" <?php echo ($reserv_accept == "1") ? "checked" : ""; ?>> <?php _e('Accept reserve update content.',RC_TXT_DOMAIN) ?> |
90 | 90 |
</label> |
91 | 91 |
<div class="rc-datetime" id="timestamp"> |
92 |
- <?php _e('UpdateTime',RC_TXT_DOMAIN) ?>:<b><?php echo date("Y/m/d @ H:i", strtotime($reserv_date)); ?></b> |
|
92 |
+ <?php _e('UpdateTime',RC_TXT_DOMAIN) ?>:<b><?php echo date_i18n("Y/m/d @ H:i", strtotime($reserv_date)); ?></b> |
|
93 | 93 |
</div> |
94 | 94 |
<a href="#edit-reservdate" class="edit-timestamp rc-datetime-edit"><?php _e('Edit') ?></a> |
95 | 95 |
<div class="rc-datetime-wrap"> |
... | ... |
@@ -97,7 +97,7 @@ function add_rucy_metabox_out() |
97 | 97 |
<?php |
98 | 98 |
for($y = $current_y; $y <= ($current_y + 3); $y++) |
99 | 99 |
{ |
100 |
- $ySelected = ($y == date('Y',$reserv_date_arr[0])) ? "selected" : ""; |
|
100 |
+ $ySelected = ($y == date_i18n('Y',$reserv_date_arr[0])) ? "selected" : ""; |
|
101 | 101 |
echo '<option value="'.$y.'" '.$ySelected.'>'.$y.'</option>'; |
102 | 102 |
} |
103 | 103 |
?> |
... | ... |
@@ -108,7 +108,7 @@ function add_rucy_metabox_out() |
108 | 108 |
for($i=1;$i<=12;$i++) |
109 | 109 |
{ |
110 | 110 |
$m = sprintf("%02d",$i); |
111 |
- $selected = ($m == date('m',$reserv_date_arr[0])) ? "selected" : ""; |
|
111 |
+ $selected = ($m == date_i18n('m',$reserv_date_arr[0])) ? "selected" : ""; |
|
112 | 112 |
echo '<option value="'.$m.'" '.$selected.'>'.$m.'</option>'; |
113 | 113 |
} |
114 | 114 |
?> |
... | ... |
@@ -117,7 +117,7 @@ function add_rucy_metabox_out() |
117 | 117 |
<?php |
118 | 118 |
for($d=1;$d<=31;$d++){ |
119 | 119 |
$d = sprintf("%02d",$d); |
120 |
- $dSelected = ($d == date('d',$reserv_date_arr[0])) ? "selected" : ""; |
|
120 |
+ $dSelected = ($d == date_i18n('d',$reserv_date_arr[0])) ? "selected" : ""; |
|
121 | 121 |
echo '<option value="'.$d.'" '.$dSelected.'>'.$d.'</option>'; |
122 | 122 |
} |
123 | 123 |
?> |
... | ... |
@@ -127,7 +127,7 @@ function add_rucy_metabox_out() |
127 | 127 |
<?php |
128 | 128 |
for($h=0;$h<=23;$h++){ |
129 | 129 |
$h = sprintf("%02d",$h); |
130 |
- $hSelected = ($h == date('H',$reserv_date_arr[0])) ? "selected" : ""; |
|
130 |
+ $hSelected = ($h == date_i18n('H',$reserv_date_arr[0])) ? "selected" : ""; |
|
131 | 131 |
echo '<option value="'.$h.'" '.$hSelected.'>'.$h.'</option>'; |
132 | 132 |
} |
133 | 133 |
?> |
... | ... |
@@ -137,7 +137,7 @@ function add_rucy_metabox_out() |
137 | 137 |
<?php |
138 | 138 |
for($min=0;$min<=59;$min++){ |
139 | 139 |
$min = sprintf("%02d",$min); |
140 |
- $minSelected = ($min == date('i',$reserv_date_arr[0])) ? "selected" : ""; |
|
140 |
+ $minSelected = ($min == date_i18n('i',$reserv_date_arr[0])) ? "selected" : ""; |
|
141 | 141 |
echo '<option value="'.$min.'" '.$minSelected.'>'.$min.'</option>'; |
142 | 142 |
} |
143 | 143 |
?> |
... | ... |
@@ -147,11 +147,11 @@ function add_rucy_metabox_out() |
147 | 147 |
</div> |
148 | 148 |
<?php |
149 | 149 |
$dateArr = array( |
150 |
- 'rc_year' => date('Y',$reserv_date_arr[0]), |
|
151 |
- 'rc_month' => date('m',$reserv_date_arr[0]), |
|
152 |
- 'rc_day' => date('d',$reserv_date_arr[0]), |
|
153 |
- 'rc_hour' => date('H',$reserv_date_arr[0]), |
|
154 |
- 'rc_minutes' => date('i',$reserv_date_arr[0]) |
|
150 |
+ 'rc_year' => date_i18n('Y',$reserv_date_arr[0]), |
|
151 |
+ 'rc_month' => date_i18n('m',$reserv_date_arr[0]), |
|
152 |
+ 'rc_day' => date_i18n('d',$reserv_date_arr[0]), |
|
153 |
+ 'rc_hour' => date_i18n('H',$reserv_date_arr[0]), |
|
154 |
+ 'rc_minutes' => date_i18n('i',$reserv_date_arr[0]) |
|
155 | 155 |
); |
156 | 156 |
foreach ($dateArr as $k => $v) |
157 | 157 |
{ |
... | ... |
@@ -183,28 +183,26 @@ function savePostmeta($post_id) |
183 | 183 |
$date = mktime($_POST['rc_hour'], $_POST['rc_minutes'], 00, $_POST['rc_month'], $_POST['rc_day'], $_POST['rc_year']); |
184 | 184 |
if($date) |
185 | 185 |
{ |
186 |
- $_POST[$rcKeys['date']] = date('Y-m-d H:i:s',$date); |
|
186 |
+ $_POST[$rcKeys['date']] = date_i18n('Y-m-d H:i:s',$date); |
|
187 | 187 |
} else { |
188 | 188 |
$_POST[$rcKeys['date']] = ""; |
189 | 189 |
} |
190 |
- if(!isset($_POST[$rcKeys['accept']])){ |
|
190 |
+ if(!isset($_POST[$rcKeys['accept']]) || $_POST[$rcKeys['accept']] != "1"){ |
|
191 | 191 |
$_POST[$rcKeys['accept']] = "0"; |
192 |
- } else if($_POST[$rcKeys['accept']] != "1"){ |
|
193 |
- $_POST[$rcKeys['accept']] = "0"; |
|
194 | 192 |
} |
195 | 193 |
} |
194 |
+ foreach ($rcKeys as $key => $val) |
|
195 |
+ { |
|
196 |
+ savePostMetaBase($post_id, $val); |
|
197 |
+ } |
|
196 | 198 |
if($_POST[$rcKeys['accept']] == "1") |
197 | 199 |
{ |
198 |
- foreach ($rcKeys as $key => $val) |
|
199 |
- { |
|
200 |
- savePostMetaBase($post_id, $val); |
|
201 |
- } |
|
202 | 200 |
$reservDate = strtotime(get_gmt_from_date($_POST[$rcKeys['date']]) . " GMT"); |
203 | 201 |
if(in_array($_POST['post_type'], $acceptPostType) || $_POST['post_type'] != 'revision') |
204 | 202 |
{ |
205 | 203 |
wp_schedule_single_event($reservDate, RC_CRON_HOOK, array($post_id)); |
206 | 204 |
} |
207 |
- } else if($_POST[$rcKeys['accept']] == "0") { |
|
205 |
+ } else if($_POST[$rcKeys['accept']] == "0" || !isset ($_POST[$rcKeys['accept']])) { |
|
208 | 206 |
// delete schedule |
209 | 207 |
wp_clear_scheduled_hook(RC_CRON_HOOK, array($post_id)); |
210 | 208 |
} |
... | ... |
@@ -236,7 +234,7 @@ function savePostMetaBase($post_id, $post_metakey) |
236 | 236 |
} |
237 | 237 |
|
238 | 238 |
// update post for wp-cron |
239 |
-add_action('wp_reserv_content_update', 'updateReservedContent','10',1); |
|
239 |
+add_action('rucy_update_reserved_content', 'updateReservedContent','10',1); |
|
240 | 240 |
function updateReservedContent($post_id) |
241 | 241 |
{ |
242 | 242 |
$rcMetas = getRcMetas($post_id); |
... | ... |
@@ -248,12 +246,12 @@ function updateReservedContent($post_id) |
248 | 248 |
); |
249 | 249 |
wp_update_post($updates,true); |
250 | 250 |
} |
251 |
- wp_clear_scheduled_hook(RC_CRON_HOOK, array($post_id)); |
|
252 | 251 |
$dels = getRcMetas(); |
253 | 252 |
foreach ($dels as $key => $del) |
254 | 253 |
{ |
255 | 254 |
delete_post_meta($post_id, $del); |
256 | 255 |
} |
256 |
+ wp_clear_scheduled_hook(RC_CRON_HOOK, array($post_id)); |
|
257 | 257 |
} |
258 | 258 |
|
259 | 259 |
// add update message |
... | ... |
@@ -268,7 +266,7 @@ function addRcMessage($messages) |
268 | 268 |
$rcMetas = getRcMetas($post_ID); |
269 | 269 |
if("1" == $rcMetas['accept']) |
270 | 270 |
{ |
271 |
- $addMessageDate = date('Y/m/d @ H:i', strtotime($rcMetas['date'])); |
|
271 |
+ $addMessageDate = date_i18n('Y/m/d @ H:i', strtotime($rcMetas['date'])); |
|
272 | 272 |
$str = __('registered reservation update content _RC_DATETIME_',RC_TXT_DOMAIN); |
273 | 273 |
$addMessage = '<br>' . strtr($str, array('_RC_DATETIME_' => $addMessageDate)); |
274 | 274 |
// published |
... | ... |
@@ -465,6 +463,11 @@ if(function_exists('register_uninstall_hook')) |
465 | 465 |
{ |
466 | 466 |
register_uninstall_hook(__FILE__, 'goodbyeRucy'); |
467 | 467 |
} |
468 |
+// deactivation |
|
469 |
+if(function_exists('register_deactivation_hook')) |
|
470 |
+{ |
|
471 |
+ register_deactivation_hook(__FILE__, 'goodbyeRucy'); |
|
472 |
+} |
|
468 | 473 |
|
469 | 474 |
function goodbyeRucy() |
470 | 475 |
{ |
... | ... |
@@ -482,8 +485,21 @@ function goodbyeRucy() |
482 | 482 |
} |
483 | 483 |
|
484 | 484 |
// link to setting |
485 |
-add_filter('plugin_action_links_' . plugin_basename(__FILE__), 'helloRucy'); |
|
486 |
-function helloRucy($links){ |
|
485 |
+add_filter('plugin_action_links_' . plugin_basename(__FILE__), 'hiRucy'); |
|
486 |
+function hiRucy($links) |
|
487 |
+{ |
|
487 | 488 |
$links[] = '<a href="' . get_admin_url(null, 'options-general.php?page=rucy') . '">' . __('Settings') . '</a>'; |
488 | 489 |
return $links; |
490 |
+} |
|
491 |
+ |
|
492 |
+// activate plugin action |
|
493 |
+register_activation_hook(plugin_basename(__FILE__), 'helloRucy'); |
|
494 |
+function helloRucy() |
|
495 |
+{ |
|
496 |
+ $rc_setting = get_option(RC_SETTING_OPTION_KEY); |
|
497 |
+ if(!$rc_setting) |
|
498 |
+ { |
|
499 |
+ $basicPostTypes = RC_POSTTYPE_DEFAULT; |
|
500 |
+ update_option(RC_SETTING_OPTION_KEY, $basicPostTypes); |
|
501 |
+ } |
|
489 | 502 |
} |
490 | 503 |
\ No newline at end of file |