Post Expirator - Version 1.4.1

Version Description

Download this release

Release Info

Developer axelseaa
Plugin Icon 128x128 Post Expirator
Version 1.4.1
Comparing to
See all releases

Code changes from version 1.4 to 1.4.1

Files changed (2) hide show
  1. post-expirator.php +126 -102
  2. readme.txt +10 -6
post-expirator.php CHANGED
@@ -4,14 +4,20 @@ Plugin Name: Post Expirator
4
  Plugin URI: http://wordpress.org/extend/plugins/post-expirator/
5
  Description: Allows you to add an expiration date to posts which you can configure to either delete the post or change it to a draft.
6
  Author: Aaron Axelsen
7
- Version: 1.4
8
- Author URI: http://www.frozenpc.net
 
 
9
  */
10
 
 
 
 
 
11
  // Default Values
12
- $expirationdateDefaultDateFormat = 'l F jS, Y';
13
- $expirationdateDefaultTimeFormat = 'g:ia';
14
- $expirationdateDefaultFooterContents = 'Post expires at EXPIRATIONTIME on EXPIRATIONDATE';
15
  $expirationdateDefaultFooterStyle = 'font-style: italic;';
16
 
17
  // Detect WPMU
@@ -32,7 +38,7 @@ function postExpiratorTimezoneSetup() {
32
  function postExpiratorAddCronMinutes($array) {
33
  $array['postexpiratorminute'] = array(
34
  'interval' => 60,
35
- 'display' => __('Once a Minute')
36
  );
37
  return $array;
38
  }
@@ -43,8 +49,11 @@ add_filter('cron_schedules','postExpiratorAddCronMinutes');
43
  */
44
  function postExpirationAdminNotice() {
45
  if (postExpiratorCronStatus() === false) {
46
- echo '<div class="error fade" style="background-color:red;"><p><strong>Post Expirator cron schedules need to be reset.
47
- <a href="'.admin_url('options-general.php?page=post-expirator.php&tab=upgrade').'" style="color: blue;">Click here to reset</a></strong></p></div>';
 
 
 
48
  }
49
  }
50
  add_action('admin_notices','postExpirationAdminNotice');
@@ -55,7 +64,8 @@ add_action('admin_notices','postExpirationAdminNotice');
55
  function expirationdate_delete_expired_posts() {
56
  global $wpdb;
57
  postExpiratorTimezoneSetup();
58
- $result = $wpdb->get_results('select post_id, meta_value from ' . $wpdb->postmeta . ' as postmeta, '.$wpdb->posts.' as posts where postmeta.post_id = posts.ID AND posts.post_status = "publish" AND postmeta.meta_key = "expiration-date" AND postmeta.meta_value <= "' . mktime() . '"');
 
59
  if (!empty($result)) foreach ($result as $a) {
60
  $post_result = $wpdb->get_var('select post_type from ' . $wpdb->posts .' where ID = '. $a->post_id);
61
  if ($post_result == 'post') {
@@ -124,7 +134,7 @@ register_deactivation_hook (__FILE__, 'expirationdate_deactivate');
124
  * adds an 'Expires' column to the post display table.
125
  */
126
  function expirationdate_add_column ($columns) {
127
- $columns['expirationdate'] = 'Expires <br/><span style="font-size: 0.8em; font-weight: normal;">(YYYY/MM/DD HH:MM)</span>';
128
  return $columns;
129
  }
130
  add_filter ('manage_posts_columns', 'expirationdate_add_column');
@@ -140,27 +150,30 @@ function expirationdate_show_value ($column_name) {
140
  postExpiratorTimezoneSetup();
141
  $query = "SELECT meta_value FROM $wpdb->postmeta WHERE meta_key = \"expiration-date\" AND post_id=$id";
142
  $ed = $wpdb->get_var($query);
143
- echo ($ed ? date('Y/m/d H:i',$ed) : "Never");
144
  }
145
  }
146
  add_action ('manage_posts_custom_column', 'expirationdate_show_value');
147
  add_action ('manage_pages_custom_column', 'expirationdate_show_value');
148
 
149
  /**
150
- * Add's hooks to get the meta box added to post
151
  */
152
- function expirationdate_meta_post() {
153
- add_meta_box('expirationdatediv', __('Post Expirator'), 'expirationdate_meta_box', 'post', 'advanced', 'high');
154
  }
155
- add_action ('dbx_post_advanced','expirationdate_meta_post');
156
 
157
  /**
158
- * Add's hooks to get the meta box added to page
159
  */
160
- function expirationdate_meta_page() {
161
- add_meta_box('expirationdatediv', __('Post Expirator'), 'expirationdate_meta_box', 'page', 'advanced', 'high');
 
 
 
162
  }
163
- add_action ('edit_page_form','expirationdate_meta_page');
164
 
165
  /**
166
  * Actually adds the meta box
@@ -189,45 +202,55 @@ function expirationdate_meta_box($post) {
189
 
190
  $rv = array();
191
  $rv[] = '<p><input type="checkbox" name="enable-expirationdate" id="enable-expirationdate" value="checked"'.$enabled.' onclick="expirationdate_ajax_add_meta(\'enable-expirationdate\')" />';
192
- $rv[] = '<label for="enable-expirationdate">Enable Post Expiration</label></p>';
193
  $rv[] = '<table><tr>';
194
- $rv[] = '<th style="text-align: left;">Month</th>';
195
- $rv[] = '<th style="text-align: left;">Day</th>';
196
- $rv[] = '<th style="text-align: left;">Year</th>';
197
- $rv[] = '<th style="text-align: left;"></th>';
198
- $rv[] = '<th style="text-align: left;">Hour (24 Hour Format)</th>';
199
- $rv[] = '<th style="text-align: left;">Minute</th>';
200
  $rv[] = '</tr><tr>';
201
- $rv[] = '<td>';
202
- $rv[] = '<select name="expirationdate_month" id="expirationdate_month"'.$disabled.'">';
203
- for($i = 1; $i <= 12; $i++) {
204
- if ($defaultmonth == date('F',mktime(0, 0, 0, $i, 1, date("Y"))))
205
- $selected = ' selected="selected"';
206
- else
207
- $selected = '';
208
- $rv[] = '<option value="'.date('m',mktime(0, 0, 0, $i, 1, date("Y"))).'"'.$selected.'>'.date('F',mktime(0, 0, 0, $i, 1, date("Y"))).'</option>';
209
- }
210
- $rv[] = '</select>';
211
- $rv[] = '</td><td>';
212
- $rv[] = '<input type="text" id="expirationdate_day" name="expirationdate_day" value="'.$defaultday.'" size="2"'.$disabled.'" />,';
 
213
  $rv[] = '</td><td>';
214
- $rv[] = '<select name="expirationdate_year" id="expirationdate_year"'.$disabled.'">';
215
- $currentyear = date('Y');
216
- if ($defaultyear < $currentyear)
217
- $currentyear = $defaultyear;
218
- for($i = $currentyear; $i < $currentyear + 8; $i++) {
219
- if ($i == $defaultyear)
220
- $selected = ' selected="selected"';
221
- else
222
- $selected = '';
223
- $rv[] = '<option'.$selected.'>'.($i).'</option>';
224
- }
225
- $rv[] = '</select>';
226
- $rv[] = '</td><td>@</td><td>';
227
- $rv[] = '<input type="text" id="expirationdate_hour" name="expirationdate_hour" value="'.$defaulthour.'" size="2"'.$disabled.'" />';
228
  $rv[] = '</td><td>';
229
- $rv[] = '<input type="text" id="expirationdate_minute" name="expirationdate_minute" value="'.$defaultminute.'" size="2"'.$disabled.'" />';
230
- $rv[] = '<input type="hidden" name="expirationdate_formcheck" value="true" />';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
231
  $rv[] = '</td></tr></table>';
232
 
233
  $rv[] = '<div id="expirationdate_ajax_result"></div>';
@@ -284,7 +307,7 @@ function expirationdate_ajax_add_meta(expireenable) {
284
  mysack.setVar( "action", "expirationdate_ajax" );
285
  mysack.setVar( "enable", enable );
286
  mysack.encVar( "cookie", document.cookie, false );
287
- mysack.onError = function() { alert('Ajax error in looking up elevation' )};
288
  mysack.runAJAX();
289
 
290
  return true;
@@ -325,6 +348,7 @@ function expirationdate_update_post_meta($id) {
325
  postExpiratorTimezoneSetup();
326
  // Format Date
327
  $ts = mktime($hour,$minute,0,$month,$day,$year);
 
328
  // Update Post Meta
329
  delete_post_meta($id, 'expiration-date');
330
  update_post_meta($id, 'expiration-date', $ts, true);
@@ -338,10 +362,10 @@ add_action('save_post','expirationdate_update_post_meta');
338
  * Build the menu for the options page
339
  */
340
  function postExpiratorMenuTabs($tab) {
341
- echo '<h2>'._('Post Expirator Options').'</h2>';
342
  echo '<p>';
343
- echo '<a href="'.admin_url('options-general.php?page=post-expirator.php&tab=general').'"'.(empty($tab) || $tab == 'general' ? ' style="font-weight: bold; text-decoration:none;"' : '').'>General Settings</a> | ';
344
- echo '<a href="'.admin_url('options-general.php?page=post-expirator.php&tab=upgrade').'"'.($tab == 'upgrade' ? ' style="font-weight: bold; text-decoration:none;"' : '').'>Upgrade</a>';
345
  echo '</p><hr/>';
346
  }
347
 
@@ -365,7 +389,7 @@ function postExpiratorMenu() {
365
  * Hook's to add plugin page menu
366
  */
367
  function postExpiratorPluginMenu() {
368
- add_submenu_page('options-general.php','Post Expirator Options','Post Expirator',9,basename(__FILE__),'postExpiratorMenu');
369
  }
370
  add_action('admin_menu', 'postExpiratorPluginMenu');
371
 
@@ -382,7 +406,9 @@ function postExpiratorMenuGeneral() {
382
  update_option('expirationdateDisplayFooter',$_POST['expired-display-footer']);
383
  update_option('expirationdateFooterContents',$_POST['expired-footer-contents']);
384
  update_option('expirationdateFooterStyle',$_POST['expired-footer-style']);
385
- echo "<div id='message' class='updated fade'><p>Saved Options!</p></div>";
 
 
386
  }
387
 
388
  // Get Option
@@ -431,79 +457,76 @@ function postExpiratorMenuGeneral() {
431
 
432
  ?>
433
  <p>
434
- The post expirator plugin sets a custom meta value, and then optionally allows you to select if you want the post
435
- changed to a draft status or deleted when it expires.
436
  </p>
437
- <p>Valid [postexpiration] attributes:
 
438
  <ul>
439
- <li>type - defaults to full - valid options are full,date,time</li>
440
- <li>dateformat - format set here will override the value set on the settings page</li>
441
- <li>timeformat - format set here will override the value set on the settings page</li>
442
  </ul>
443
  </p>
444
  <form method="post" id="expirationdate_save_options">
445
- <h3>Defaults</h3>
446
  <table class="form-table">
447
  <tr valign-"top">
448
- <th scope="row"><label for="expired-post-status">Set Post To:</label></th>
449
  <td>
450
  <select name="expired-post-status" id="expired-post-status">
451
- <option<?php if ($expirationdateExpiredPostStatus == 'Draft'){ echo ' selected="selected"';}?>>Draft</option>
452
- <option<?php if ($expirationdateExpiredPostStatus == 'Delete'){ echo ' selected="selected"';}?>>Delete</option>
453
  </select>
454
  <br/>
455
- Select whether the post should be deleted or changed to a draft at expiration time.
456
  </td>
457
  </tr>
458
  <tr valign-"top">
459
- <th scope="row"><label for="expired-page-status">Set Page To:</label></th>
460
  <td>
461
  <select name="expired-page-status" id="expired-page-status">
462
- <option<?php if ($expirationdateExpiredPageStatus == 'Draft'){ echo ' selected="selected"';}?>>Draft</option>
463
- <option<?php if ($expirationdateExpiredPageStatus == 'Delete'){ echo ' selected="selected"';}?>>Delete</option>
464
  </select>
465
  <br/>
466
- Select whether the page should be deleted or changed to a draft at expiration time.
467
  </td>
468
  </tr>
469
  <tr valign-"top">
470
- <th scope="row"><label for="expired-default-date-format">Date Format:</label></th>
471
  <td>
472
  <input type="text" name="expired-default-date-format" id="expired-default-date-format" value="<?php echo $expirationdateDefaultDateFormat ?>" size="25" /> (<?php echo date("$expirationdateDefaultDateFormat") ?>)
473
  <br/>
474
- The default format to use when displaying the expiration date within a post using the [postexpirator]
475
- shortcode or within the footer. For information on valid formatting options, see: <a href="http://us2.php.net/manual/en/function.date.php" target="_blank">PHP Date Function</a>.
476
  </td>
477
  </tr>
478
  <tr valign-"top">
479
- <th scope="row"><label for="expired-default-time-format">Time Format:</label></th>
480
  <td>
481
  <input type="text" name="expired-default-time-format" id="expired-default-time-format" value="<?php echo $expirationdateDefaultTimeFormat ?>" size="25" /> (<?php echo date("$expirationdateDefaultTimeFormat") ?>)
482
  <br/>
483
- The default format to use when displaying the expiration time within a post using the [postexpirator]
484
- shortcode or within the footer. For information on valid formatting options, see: <a href="http://us2.php.net/manual/en/function.date.php" target="_blank">PHP Date Function</a>.
485
  </td>
486
  </tr>
487
  </table>
488
- <h3>Post Footer Display</h3>
489
- <p>Enabling this below will display the expiration date automatically at the end of any post which is set to expire.</p>
490
  <table class="form-table">
491
  <tr valign-"top">
492
- <th scope="row">Show in post footer?</th>
493
  <td>
494
- <input type="radio" name="expired-display-footer" id="expired-display-footer-true" value="1" <?php echo $expireddisplayfooterenabled ?>/> <label for="expired-display-footer-true">Enabled</label>
495
- <input type="radio" name="expired-display-footer" id="expired-display-footer-false" value="0" <?php echo $expireddisplayfooterdisabled ?>/> <label for="expired-display-footer-false">Disabled</label>
496
  <br/>
497
- This will enable or disable displaying the post expiration date in the post footer.
498
  </td>
499
  </tr>
500
  <tr valign-"top">
501
- <th scope="row"><label for="expired-footer-contents">Footer Contents:</label></th>
502
  <td>
503
  <textarea id="expired-footer-contents" name="expired-footer-contents" rows="3" cols="50"><?php echo $expirationdateFooterContents; ?></textarea>
504
  <br/>
505
- Enter the text you would like to appear at the bottom of every post that will expire. The following placeholders will be replaced
506
- with the post expiration date in the following format:
507
  <ul>
508
  <li>EXPIRATIONFULL -> <?php echo date("$expirationdateDefaultDateFormat $expirationdateDefaultTimeFormat") ?></li>
509
  <li>EXPIRATIONDATE -> <?php echo date("$expirationdateDefaultDateFormat") ?></li>
@@ -512,17 +535,17 @@ function postExpiratorMenuGeneral() {
512
  </td>
513
  </tr>
514
  <tr valign-"top">
515
- <th scope="row"><label for="expired-footer-style">Footer Style:</label></th>
516
  <td>
517
  <input type="text" name="expired-footer-style" id="expired-footer-style" value="<?php echo $expirationdateFooterStyle ?>" size="25" />
518
- (<span style="<?php echo $expirationdateFooterStyle ?>">This post will expire on <?php echo date("$expirationdateDefaultDateFormat $expirationdateDefaultTimeFormat"); ?></span>)
519
  <br/>
520
- The inline css which will be used to style the footer text.
521
  </td>
522
  </tr>
523
  </table>
524
  <p class="submit">
525
- <input type="submit" name="expirationdateSave" value="Save" />
526
  </p>
527
  </form>
528
  <?php
@@ -565,26 +588,26 @@ function postExpiratorResetCron() {
565
  function postExpiratorMenuUpgrade() {
566
  if (isset($_POST['reset-cron-schedules'])) {
567
  postExpiratorResetCron();
568
- echo "<div id='message' class='updated fade'><p>Reset Cron Scheules!</p></div>";
569
  }
570
 
571
  $status = postExpiratorCronStatus();
572
  if ($status)
573
- $cronstatus = '<span style="color:green">OK</span>';
574
  else
575
- $cronstatus = '<span style="color:red">RESET NEEDED</span>';
576
 
577
  ?>
578
  <form method="post" id="postExpiratorMenuUpgrade">
579
- <h3>Upgrade</h3>
580
  <table class="form-table">
581
  <tr valign-"top">
582
- <th scope="row"><label for="reset-cron-schedules">Reset Cron Schedules:</label></th>
583
  <td>
584
- <input type="submit" name="reset-cron-schedules" id="reset-cron-schedules" value="Reset" />
585
- Status: <?php echo $cronstatus; ?>
586
  <br/>
587
- Resets the cron scheduler and removes any old or stray entries.
588
  </td>
589
  </tr>
590
  </table>
@@ -637,6 +660,7 @@ function postexpirator_add_footer($text) {
637
  if ($displayFooter === false || $displayFooter == 0)
638
  return $text;
639
 
 
640
  $expirationdatets = get_post_meta($post->ID,'expiration-date',true);
641
  if (!is_numeric($expirationdatets))
642
  return $text;
4
  Plugin URI: http://wordpress.org/extend/plugins/post-expirator/
5
  Description: Allows you to add an expiration date to posts which you can configure to either delete the post or change it to a draft.
6
  Author: Aaron Axelsen
7
+ Version: 1.4.1
8
+ Author URI: http://postexpirator.tuxdocs.net/
9
+ Translation: Thierry (http://palijn.info)
10
+ Text Domain: post-expirator
11
  */
12
 
13
+ /* Load translation, if it exists */
14
+ $plugin_dir = basename(dirname(__FILE__));
15
+ load_plugin_textdomain( 'post-expirator', null, $plugin_dir.'/languages/' );
16
+
17
  // Default Values
18
+ $expirationdateDefaultDateFormat = __('l F jS, Y','post-expirator');
19
+ $expirationdateDefaultTimeFormat = __('g:ia','post-expirator');
20
+ $expirationdateDefaultFooterContents = __('Post expires at EXPIRATIONTIME on EXPIRATIONDATE','post-expirator');
21
  $expirationdateDefaultFooterStyle = 'font-style: italic;';
22
 
23
  // Detect WPMU
38
  function postExpiratorAddCronMinutes($array) {
39
  $array['postexpiratorminute'] = array(
40
  'interval' => 60,
41
+ 'display' => __('Once a Minute','post-expirator')
42
  );
43
  return $array;
44
  }
49
  */
50
  function postExpirationAdminNotice() {
51
  if (postExpiratorCronStatus() === false) {
52
+ echo '<div class="error fade" style="background-color:red;"><p><strong>';
53
+ _e('Post Expirator cron schedules need to be reset','post-expirator');
54
+ echo('<a href="'.admin_url('options-general.php?page=post-expirator.php&tab=upgrade').'" style="color: blue;">');
55
+ _e('Click here to reset','post-expirator');
56
+ echo('</a></strong></p></div>');
57
  }
58
  }
59
  add_action('admin_notices','postExpirationAdminNotice');
64
  function expirationdate_delete_expired_posts() {
65
  global $wpdb;
66
  postExpiratorTimezoneSetup();
67
+ $time_delete = time();
68
+ $result = $wpdb->get_results('select post_id, meta_value from ' . $wpdb->postmeta . ' as postmeta, '.$wpdb->posts.' as posts where postmeta.post_id = posts.ID AND posts.post_status = "publish" AND postmeta.meta_key = "expiration-date" AND postmeta.meta_value <= "' . $time_delete . '"');
69
  if (!empty($result)) foreach ($result as $a) {
70
  $post_result = $wpdb->get_var('select post_type from ' . $wpdb->posts .' where ID = '. $a->post_id);
71
  if ($post_result == 'post') {
134
  * adds an 'Expires' column to the post display table.
135
  */
136
  function expirationdate_add_column ($columns) {
137
+ $columns['expirationdate'] = __('Expires','post-expirator').'<br/><span style="font-size: 0.8em; font-weight: normal;">(YYYY/MM/DD HH:MM)</span>';
138
  return $columns;
139
  }
140
  add_filter ('manage_posts_columns', 'expirationdate_add_column');
150
  postExpiratorTimezoneSetup();
151
  $query = "SELECT meta_value FROM $wpdb->postmeta WHERE meta_key = \"expiration-date\" AND post_id=$id";
152
  $ed = $wpdb->get_var($query);
153
+ echo ($ed ? date('Y/m/d H:i',$ed) : __("Never",'post-expirator'));
154
  }
155
  }
156
  add_action ('manage_posts_custom_column', 'expirationdate_show_value');
157
  add_action ('manage_pages_custom_column', 'expirationdate_show_value');
158
 
159
  /**
160
+ * Adds hooks to get the meta box added to page
161
  */
162
+ function expirationdate_meta_page() {
163
+ add_meta_box('expirationdatediv', __('Post Expirator','post-expirator'), 'expirationdate_meta_box', 'page', 'advanced', 'high');
164
  }
165
+ add_action ('edit_page_form','expirationdate_meta_page');
166
 
167
  /**
168
+ * Adds hooks to get the meta box added to custom post types
169
  */
170
+ function expirationdate_meta_custom() {
171
+ $custom_post_types = get_post_types();
172
+ foreach ($custom_post_types as $t) {
173
+ add_meta_box('expirationdatediv', __('Post Expirator','post-expirator'), 'expirationdate_meta_box', $t, 'advanced', 'high');
174
+ }
175
  }
176
+ add_action ('edit_form_advanced','expirationdate_meta_custom');
177
 
178
  /**
179
  * Actually adds the meta box
202
 
203
  $rv = array();
204
  $rv[] = '<p><input type="checkbox" name="enable-expirationdate" id="enable-expirationdate" value="checked"'.$enabled.' onclick="expirationdate_ajax_add_meta(\'enable-expirationdate\')" />';
205
+ $rv[] = '<label for="enable-expirationdate">'.__('Enable Post Expiration','post-expirator').'</label></p>';
206
  $rv[] = '<table><tr>';
207
+ $rv[] = '<th style="text-align: left;">'.__('Year','post-expirator').'</th>';
208
+ $rv[] = '<th style="text-align: left;">'.__('Month','post-expirator').'</th>';
209
+ $rv[] = '<th style="text-align: left;">'.__('Day','post-expirator').'</th>';
 
 
 
210
  $rv[] = '</tr><tr>';
211
+ $rv[] = '<td>';
212
+ $rv[] = '<select name="expirationdate_year" id="expirationdate_year"'.$disabled.'">';
213
+ $currentyear = date('Y');
214
+ if ($defaultyear < $currentyear)
215
+ $currentyear = $defaultyear;
216
+ for($i = $currentyear; $i < $currentyear + 8; $i++) {
217
+ if ($i == $defaultyear)
218
+ $selected = ' selected="selected"';
219
+ else
220
+ $selected = '';
221
+ $rv[] = '<option'.$selected.'>'.($i).'</option>';
222
+ }
223
+ $rv[] = '</select>';
224
  $rv[] = '</td><td>';
225
+ $rv[] = '<select name="expirationdate_month" id="expirationdate_month"'.$disabled.'">';
226
+ for($i = 1; $i <= 12; $i++) {
227
+ if ($defaultmonth == date('F',mktime(0, 0, 0, $i, 1, date("Y"))))
228
+ $selected = ' selected="selected"';
229
+ else
230
+ $selected = '';
231
+ $rv[] = '<option value="'.date('m',mktime(0, 0, 0, $i, 1, date("Y"))).'"'.$selected.'>'.date(__('F','post-expirator'),mktime(0, 0, 0, $i, 1, date("Y"))).'</option>';
232
+ }
233
+ $rv[] = '</select>';
 
 
 
 
 
234
  $rv[] = '</td><td>';
235
+ $rv[] = '<input type="text" id="expirationdate_day" name="expirationdate_day" value="'.$defaultday.'" size="2"'.$disabled.'" />,';
236
+ $rv[] = '</td></tr><tr>';
237
+ $rv[] = '<th style="text-align: left;"></th>';
238
+ $rv[] = '<th style="text-align: left;">'.__('Hour','post-expirator').'('.date('T',mktime(0, 0, 0, $i, 1, date("Y"))).')</th>';
239
+ $rv[] = '<th style="text-align: left;">'.__('Minute','post-expirator').'</th>';
240
+ $rv[] = '</tr><tr>';
241
+ $rv[] = '<td>@</td><td>';
242
+ /* $rv[] = '<input type="text" id="expirationdate_hour" name="expirationdate_hour" value="'.$defaulthour.'" size="2"'.$disabled.'" />'; */
243
+ $rv[] = '<select name="expirationdate_hour" id="expirationdate_hour"'.$disabled.'">';
244
+ for($i = 1; $i <= 24; $i++) {
245
+ if ($defaulthour == date('H',mktime($i, 0, 0, date("n"), date("j"), date("Y"))))
246
+ $selected = ' selected="selected"';
247
+ else
248
+ $selected = '';
249
+ $rv[] = '<option value="'.date('H',mktime($i, 0, 0, date("n"), date("j"), date("Y"))).'"'.$selected.'>'.date(__('H','post-expirator'),mktime($i, 0, 0, date("n"), date("j"), date("Y"))).'</option>';
250
+ }
251
+ $rv[] = '</td><td>';
252
+ $rv[] = '<input type="text" id="expirationdate_minute" name="expirationdate_minute" value="'.$defaultminute.'" size="2"'.$disabled.'" />';
253
+ $rv[] = '<input type="hidden" name="expirationdate_formcheck" value="true" />';
254
  $rv[] = '</td></tr></table>';
255
 
256
  $rv[] = '<div id="expirationdate_ajax_result"></div>';
307
  mysack.setVar( "action", "expirationdate_ajax" );
308
  mysack.setVar( "enable", enable );
309
  mysack.encVar( "cookie", document.cookie, false );
310
+ mysack.onError = function() { alert('Ajax error in enabling post expiration' )};
311
  mysack.runAJAX();
312
 
313
  return true;
348
  postExpiratorTimezoneSetup();
349
  // Format Date
350
  $ts = mktime($hour,$minute,0,$month,$day,$year);
351
+
352
  // Update Post Meta
353
  delete_post_meta($id, 'expiration-date');
354
  update_post_meta($id, 'expiration-date', $ts, true);
362
  * Build the menu for the options page
363
  */
364
  function postExpiratorMenuTabs($tab) {
365
+ echo '<h2>'.__('Post Expirator Options','post-expirator').'</h2>';
366
  echo '<p>';
367
+ echo '<a href="'.admin_url('options-general.php?page=post-expirator.php&tab=general').'"'.(empty($tab) || $tab == 'general' ? ' style="font-weight: bold; text-decoration:none;"' : '>').__('General Settings','post-expirator').'</a> | ';
368
+ echo '<a href="'.admin_url('options-general.php?page=post-expirator.php&tab=upgrade').'"'.($tab == 'upgrade' ? ' style="font-weight: bold; text-decoration:none;"' : '').'>'.__('Upgrade','post-expirator').'</a>';
369
  echo '</p><hr/>';
370
  }
371
 
389
  * Hook's to add plugin page menu
390
  */
391
  function postExpiratorPluginMenu() {
392
+ add_submenu_page('options-general.php',__('Post Expirator Options','post-expirator'),__('Post Expirator','post-expirator'),9,basename(__FILE__),'postExpiratorMenu');
393
  }
394
  add_action('admin_menu', 'postExpiratorPluginMenu');
395
 
406
  update_option('expirationdateDisplayFooter',$_POST['expired-display-footer']);
407
  update_option('expirationdateFooterContents',$_POST['expired-footer-contents']);
408
  update_option('expirationdateFooterStyle',$_POST['expired-footer-style']);
409
+ echo "<div id='message' class='updated fade'><p>";
410
+ _e('Saved Options!','post-expirator');
411
+ echo "</p></div>";
412
  }
413
 
414
  // Get Option
457
 
458
  ?>
459
  <p>
460
+ <?php _e('The post expirator plugin sets a custom meta value, and then optionally allows you to select if you want the post changed to a draft status or deleted when it expires.','post-expirator'); ?>
 
461
  </p>
462
+ <p>
463
+ <?php _e('Valid [postexpiration] attributes:','post-expirator'); ?>
464
  <ul>
465
+ <li><?php _e('type - defaults to full - valid options are full,date,time','post-expirator');?></li>
466
+ <li><?php _e('dateformat - format set here will override the value set on the settings page','post-expirator');?></li>
467
+ <li><?php _e('timeformat - format set here will override the value set on the settings page','post-expirator');?></li>
468
  </ul>
469
  </p>
470
  <form method="post" id="expirationdate_save_options">
471
+ <h3><?php _e('Defaults','post-expirator'); ?></h3>
472
  <table class="form-table">
473
  <tr valign-"top">
474
+ <th scope="row"><label for="expired-post-status"><?php _e('Set Post To:','post-expirator'); ?></label></th>
475
  <td>
476
  <select name="expired-post-status" id="expired-post-status">
477
+ <option <?php if ($expirationdateExpiredPostStatus == 'Draft'){ echo 'selected="selected"';} ?> value="Draft"><?php _e('Draft','post-expirator');?></option>
478
+ <option <?php if ($expirationdateExpiredPostStatus == 'Delete'){ echo 'selected="selected"';} ?> value="Delete"><?php _e('Delete','post-expirator');?></option>
479
  </select>
480
  <br/>
481
+ <?php _e('Select whether the post should be deleted or changed to a draft at expiration time.','post-expirator');?>
482
  </td>
483
  </tr>
484
  <tr valign-"top">
485
+ <th scope="row"><label for="expired-page-status"><?php _e('Set Page To:','post-expirator');?></label></th>
486
  <td>
487
  <select name="expired-page-status" id="expired-page-status">
488
+ <option<?php if ($expirationdateExpiredPageStatus == 'Draft'){ echo ' selected="selected"';}?> value="Draft"><?php _e('Draft','post-expirator');?></option>
489
+ <option<?php if ($expirationdateExpiredPageStatus == 'Delete'){ echo ' selected="selected"';}?> value="Delete"><?php _e('Delete','post-expirator');?></option>
490
  </select>
491
  <br/>
492
+ <?php _e('Select whether the page should be deleted or changed to a draft at expiration time.','post-expirator');?>
493
  </td>
494
  </tr>
495
  <tr valign-"top">
496
+ <th scope="row"><label for="expired-default-date-format"><?php _e('Date Format:','post-expirator');?></label></th>
497
  <td>
498
  <input type="text" name="expired-default-date-format" id="expired-default-date-format" value="<?php echo $expirationdateDefaultDateFormat ?>" size="25" /> (<?php echo date("$expirationdateDefaultDateFormat") ?>)
499
  <br/>
500
+ <?php _e('The default format to use when displaying the expiration date within a post using the [postexpirator] shortcode or within the footer. For information on valid formatting options, see: <a href="http://us2.php.net/manual/en/function.date.php" target="_blank">PHP Date Function</a>.','post-expirator'); ?>
 
501
  </td>
502
  </tr>
503
  <tr valign-"top">
504
+ <th scope="row"><label for="expired-default-time-format"><?php _e('Time Format:','post-expirator');?></label></th>
505
  <td>
506
  <input type="text" name="expired-default-time-format" id="expired-default-time-format" value="<?php echo $expirationdateDefaultTimeFormat ?>" size="25" /> (<?php echo date("$expirationdateDefaultTimeFormat") ?>)
507
  <br/>
508
+ <?php _e('The default format to use when displaying the expiration time within a post using the [postexpirator] shortcode or within the footer. For information on valid formatting options, see: <a href="http://us2.php.net/manual/en/function.date.php" target="_blank">PHP Date Function</a>.','post-expirator'); ?>
 
509
  </td>
510
  </tr>
511
  </table>
512
+ <h3><?php _e('Post Footer Display','post-expirator');?></h3>
513
+ <p><?php _e('Enabling this below will display the expiration date automatically at the end of any post which is set to expire.','post-expirator');?></p>
514
  <table class="form-table">
515
  <tr valign-"top">
516
+ <th scope="row"><?php _e('Show in post footer?','post-expirator');?></th>
517
  <td>
518
+ <input type="radio" name="expired-display-footer" id="expired-display-footer-true" value="1" <?php echo $expireddisplayfooterenabled ?>/> <label for="expired-display-footer-true"><?php _e('Enabled','post-expirator');?></label>
519
+ <input type="radio" name="expired-display-footer" id="expired-display-footer-false" value="0" <?php echo $expireddisplayfooterdisabled ?>/> <label for="expired-display-footer-false"><?php _e('Disabled','post-expirator');?></label>
520
  <br/>
521
+ <?php _e('This will enable or disable displaying the post expiration date in the post footer.','post-expirator');?>
522
  </td>
523
  </tr>
524
  <tr valign-"top">
525
+ <th scope="row"><label for="expired-footer-contents"><?php _e('Footer Contents:','post-expirator');?></label></th>
526
  <td>
527
  <textarea id="expired-footer-contents" name="expired-footer-contents" rows="3" cols="50"><?php echo $expirationdateFooterContents; ?></textarea>
528
  <br/>
529
+ <?php _e('Enter the text you would like to appear at the bottom of every post that will expire. The following placeholders will be replaced with the post expiration date in the following format:','post-expirator');?>
 
530
  <ul>
531
  <li>EXPIRATIONFULL -> <?php echo date("$expirationdateDefaultDateFormat $expirationdateDefaultTimeFormat") ?></li>
532
  <li>EXPIRATIONDATE -> <?php echo date("$expirationdateDefaultDateFormat") ?></li>
535
  </td>
536
  </tr>
537
  <tr valign-"top">
538
+ <th scope="row"><label for="expired-footer-style"><?php _e('Footer Style:','post-expirator');?></label></th>
539
  <td>
540
  <input type="text" name="expired-footer-style" id="expired-footer-style" value="<?php echo $expirationdateFooterStyle ?>" size="25" />
541
+ (<span style="<?php echo $expirationdateFooterStyle ?>"><?php _e('This post will expire on','post-expirator');?> <?php echo date("$expirationdateDefaultDateFormat $expirationdateDefaultTimeFormat"); ?></span>)
542
  <br/>
543
+ <?php _e('The inline css which will be used to style the footer text.','post-expirator');?>
544
  </td>
545
  </tr>
546
  </table>
547
  <p class="submit">
548
+ <input type="submit" name="expirationdateSave" value="<?php _e('Save','post-expirator');?>" />
549
  </p>
550
  </form>
551
  <?php
588
  function postExpiratorMenuUpgrade() {
589
  if (isset($_POST['reset-cron-schedules'])) {
590
  postExpiratorResetCron();
591
+ echo "<div id='message' class='updated fade'><p>"; _e('Cron Schedules Reset!','post-expirator'); echo "</p></div>";
592
  }
593
 
594
  $status = postExpiratorCronStatus();
595
  if ($status)
596
+ $cronstatus = '<span style="color:green">'.__('OK','post-expirator').'</span>';
597
  else
598
+ $cronstatus = '<span style="color:red">'.__('RESET NEEDED','post-expirator').'</span>';
599
 
600
  ?>
601
  <form method="post" id="postExpiratorMenuUpgrade">
602
+ <h3><?php _e('Upgrade','post-expirator');?></h3>
603
  <table class="form-table">
604
  <tr valign-"top">
605
+ <th scope="row"><label for="reset-cron-schedules"><?php _e('Reset Cron Schedules:','post-expirator');?></label></th>
606
  <td>
607
+ <input type="submit" name="reset-cron-schedules" id="reset-cron-schedules" value="<?php _e('Reset','post-expirator');?>" />
608
+ <?php _e('Status:','post-expirator');?> <?php echo $cronstatus; ?>
609
  <br/>
610
+ <?php _e('Resets the cron scheduler and removes any old or stray entries.','post-expirator');?>
611
  </td>
612
  </tr>
613
  </table>
660
  if ($displayFooter === false || $displayFooter == 0)
661
  return $text;
662
 
663
+ postExpiratorTimezoneSetup();
664
  $expirationdatets = get_post_meta($post->ID,'expiration-date',true);
665
  if (!is_numeric($expirationdatets))
666
  return $text;
readme.txt CHANGED
@@ -1,9 +1,9 @@
1
  === Post Expirator ===
2
  Contributors: axelseaa
3
  Tags: expire, posts, pages, schedule
4
- Requires at least: 2.8
5
- Tested up to: 3.0
6
- Stable tag: 1.4
7
 
8
  Allows you to add an expiration date (minute) to posts which you can configure to either delete the post or change it to a draft.
9
 
@@ -23,8 +23,6 @@ default display format. See the [PHP Date Function](http://us2.php.net/manual/e
23
  * dateformat - format set here will override the value set on the settings page
24
  * timeformat - format set here will override the value set on the settings page
25
 
26
- Note on upgrading to 1.4: After upgrading, you may need to reset the cron schedules. Following onscreen notice if prompted. Previously scheduled posts will not be updated, they will be deleted referncing the old timezone setting. If you wish to update them, you will need to manually update the expiration time.
27
-
28
  == Wordpress MU ==
29
 
30
  This plugin is compataibile with Wordpress MU 1.5+, however currently it will not work in the mu-plugins folder due to the plugin activation
@@ -43,6 +41,13 @@ This section describes how to install the plugin and get it working.
43
 
44
  == Changelog ==
45
 
 
 
 
 
 
 
 
46
  **Version 1.4**
47
 
48
  NOTE: After upgrading, you may need to reset the cron schedules. Following onscreen notice if prompted. Previously scheduled posts will not be updated, they will be deleted referncing the old timezone setting. If you wish to update them, you will need to manually update the expiration time.
@@ -79,4 +84,3 @@ NOTE: After upgrading, you may need to reset the cron schedules. Following onsc
79
  **Version 1.0**
80
 
81
  * Initial Release
82
-
1
  === Post Expirator ===
2
  Contributors: axelseaa
3
  Tags: expire, posts, pages, schedule
4
+ Requires at least: 2.9
5
+ Tested up to: 3.1
6
+ Stable tag: 1.4.1
7
 
8
  Allows you to add an expiration date (minute) to posts which you can configure to either delete the post or change it to a draft.
9
 
23
  * dateformat - format set here will override the value set on the settings page
24
  * timeformat - format set here will override the value set on the settings page
25
 
 
 
26
  == Wordpress MU ==
27
 
28
  This plugin is compataibile with Wordpress MU 1.5+, however currently it will not work in the mu-plugins folder due to the plugin activation
41
 
42
  == Changelog ==
43
 
44
+ **Version 1.4.1**
45
+
46
+ * Added support for custom post types (Thanks Thierry)
47
+ * Added i18n support (Thanks Thierry)
48
+ * Fixed issue where expiration date was not shown in the correct timezone in the footer
49
+ * Fixed issue where on some systems the expiration did not happen when scheduled
50
+
51
  **Version 1.4**
52
 
53
  NOTE: After upgrading, you may need to reset the cron schedules. Following onscreen notice if prompted. Previously scheduled posts will not be updated, they will be deleted referncing the old timezone setting. If you wish to update them, you will need to manually update the expiration time.
84
  **Version 1.0**
85
 
86
  * Initial Release