Post Expirator - Version 1.1

Version Description

Download this release

Release Info

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

Code changes from version 1.0 to 1.1

Files changed (2) hide show
  1. post-expirator.php +8 -4
  2. readme.txt +10 -0
post-expirator.php CHANGED
@@ -4,16 +4,17 @@ Plugin Name: Post Expirator
4
  Plugin URI: http://wordpress.org/extend/plugins/post-expirator/
5
  Description: Allows you to add an expiration date (hourly) to posts which you can configure to either delete the post or change it to a draft.
6
  Author: Aaron Axelsen
7
- Version: 1.0
8
  Author URI: http://www.frozenpc.net
9
  */
10
 
 
11
  /**
12
  * Function that does the actualy deleting - called by wp_cron
13
  */
14
  function expirationdate_delete_expired_posts() {
15
  global $wpdb;
16
- $result = $wpdb->get_results('select post_id from ' . $wpdb->postmeta . ' where meta_key = "expiration-date" AND meta_value < "' . mktime() . '"');
17
  foreach ($result as $a) {
18
  $post_result = $wpdb->get_var('select post_type from ' . $wpdb->posts .' where ID = '. $a->post_id);
19
  if ($post_result == 'post') {
@@ -26,8 +27,11 @@ function expirationdate_delete_expired_posts() {
26
 
27
  if ($expiredStatus == 'delete')
28
  wp_delete_post($a->post_id);
29
- else
30
  wp_update_post(array('ID' => $a->post_id, 'post_status' => 'draft'));
 
 
 
31
  }
32
  }
33
  add_action ('expirationdate_delete_'.$current_blog->blog_id, 'expirationdate_delete_expired_posts');
@@ -119,7 +123,7 @@ function expirationdate_meta_box($post) {
119
 
120
  $rv = array();
121
  $rv[] = '<p><input type="checkbox" name="enable-expirationdate" id="enable-expirationdate" value="checked"'.$enabled.' onclick="expirationdate_ajax_add_meta(\'enable-expirationdate\')" />';
122
- $rv[] = '<label for="enable-expirationdate">Enable Post Expiration</labael></p>';
123
  $rv[] = '<table><tr>';
124
  $rv[] = '<th style="text-align: left;">Month</th>';
125
  $rv[] = '<th style="text-align: left;">Day</th>';
4
  Plugin URI: http://wordpress.org/extend/plugins/post-expirator/
5
  Description: Allows you to add an expiration date (hourly) to posts which you can configure to either delete the post or change it to a draft.
6
  Author: Aaron Axelsen
7
+ Version: 1.1
8
  Author URI: http://www.frozenpc.net
9
  */
10
 
11
+
12
  /**
13
  * Function that does the actualy deleting - called by wp_cron
14
  */
15
  function expirationdate_delete_expired_posts() {
16
  global $wpdb;
17
+ $result = $wpdb->get_results('select post_id, meta_value from ' . $wpdb->postmeta . ' where meta_key = "expiration-date" AND meta_value < "' . mktime() . '"');
18
  foreach ($result as $a) {
19
  $post_result = $wpdb->get_var('select post_type from ' . $wpdb->posts .' where ID = '. $a->post_id);
20
  if ($post_result == 'post') {
27
 
28
  if ($expiredStatus == 'delete')
29
  wp_delete_post($a->post_id);
30
+ else {
31
  wp_update_post(array('ID' => $a->post_id, 'post_status' => 'draft'));
32
+ delete_post_meta($a->post_id, 'expiration-date');
33
+ update_post_meta($a->post_id, 'expiration-date', $a->meta_value, true);
34
+ }
35
  }
36
  }
37
  add_action ('expirationdate_delete_'.$current_blog->blog_id, 'expirationdate_delete_expired_posts');
123
 
124
  $rv = array();
125
  $rv[] = '<p><input type="checkbox" name="enable-expirationdate" id="enable-expirationdate" value="checked"'.$enabled.' onclick="expirationdate_ajax_add_meta(\'enable-expirationdate\')" />';
126
+ $rv[] = '<label for="enable-expirationdate">Enable Post Expiration</label></p>';
127
  $rv[] = '<table><tr>';
128
  $rv[] = '<th style="text-align: left;">Month</th>';
129
  $rv[] = '<th style="text-align: left;">Day</th>';
readme.txt CHANGED
@@ -31,3 +31,13 @@ This section describes how to install the plugin and get it working.
31
  1. Upload `plugin-name.php` to the `/wp-content/plugins/` directory
32
  2. Activate the plugin through the 'Plugins' menu in WordPress
33
 
 
 
 
 
 
 
 
 
 
 
31
  1. Upload `plugin-name.php` to the `/wp-content/plugins/` directory
32
  2. Activate the plugin through the 'Plugins' menu in WordPress
33
 
34
+ == Changelog ==
35
+
36
+ **Version 1.1**
37
+
38
+ * Expired posts retain expiration date
39
+
40
+ **Version 1.0**
41
+
42
+ * Initial Release
43
+