Post Expirator - Version 1.5

Version Description

Download this release

Release Info

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

Code changes from version 1.4.3 to 1.5

Files changed (4) hide show
  1. languages/post-expirator.pot +96 -69
  2. post-expirator.php +169 -34
  3. readme.txt +16 -15
  4. style.css +9 -0
languages/post-expirator.pot CHANGED
@@ -1,14 +1,14 @@
1
- # Copyright (C) 2010 Post Expirator
2
# This file is distributed under the same license as the Post Expirator package.
3
msgid ""
4
msgstr ""
5
- "Project-Id-Version: Post Expirator 1.4.2\n"
6
"Report-Msgid-Bugs-To: http://wordpress.org/tag/post-expirator\n"
7
- "POT-Creation-Date: 2011-01-02 02:13:36+00:00\n"
8
"MIME-Version: 1.0\n"
9
"Content-Type: text/plain; charset=UTF-8\n"
10
"Content-Transfer-Encoding: 8bit\n"
11
- "PO-Revision-Date: 2010-MO-DA HO:MI+ZONE\n"
12
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
13
"Language-Team: LANGUAGE <LL@li.org>\n"
14
@@ -24,142 +24,148 @@ msgstr ""
24
msgid "Post expires at EXPIRATIONTIME on EXPIRATIONDATE"
25
msgstr ""
26
27
- #: post-expirator.php:41
28
msgid "Once a Minute"
29
msgstr ""
30
31
- #: post-expirator.php:53
32
msgid "Post Expirator cron schedules need to be reset"
33
msgstr ""
34
35
- #: post-expirator.php:55
36
msgid "Click here to reset"
37
msgstr ""
38
39
- #: post-expirator.php:137
40
msgid "Expires"
41
msgstr ""
42
43
- #: post-expirator.php:153
44
msgid "Never"
45
msgstr ""
46
47
- #. #-#-#-#-# plugin.pot (Post Expirator 1.4.2) #-#-#-#-#
48
#. Plugin Name of the plugin/theme
49
- #: post-expirator.php:163 post-expirator.php:173 post-expirator.php:393
50
msgid "Post Expirator"
51
msgstr ""
52
53
- #: post-expirator.php:205
54
msgid "Enable Post Expiration"
55
msgstr ""
56
57
- #: post-expirator.php:207
58
msgid "Year"
59
msgstr ""
60
61
- #: post-expirator.php:208
62
msgid "Month"
63
msgstr ""
64
65
- #: post-expirator.php:209
66
msgid "Day"
67
msgstr ""
68
69
- #: post-expirator.php:231
70
- msgid "F"
71
- msgstr ""
72
-
73
- #: post-expirator.php:238
74
msgid "Hour"
75
msgstr ""
76
77
- #: post-expirator.php:239
78
msgid "Minute"
79
msgstr ""
80
81
- #: post-expirator.php:249
82
msgid "H"
83
msgstr ""
84
85
- #: post-expirator.php:365 post-expirator.php:393
86
msgid "Post Expirator Options"
87
msgstr ""
88
89
- #: post-expirator.php:368
90
msgid "General Settings"
91
msgstr ""
92
93
- #: post-expirator.php:369 post-expirator.php:603
94
msgid "Upgrade"
95
msgstr ""
96
97
- #: post-expirator.php:411
98
msgid "Saved Options!"
99
msgstr ""
100
101
- #: post-expirator.php:461
102
msgid ""
103
"The post expirator plugin sets a custom meta value, and then optionally "
104
"allows you to select if you want the post changed to a draft status or "
105
"deleted when it expires."
106
msgstr ""
107
108
- #: post-expirator.php:464
109
msgid "Valid [postexpiration] attributes:"
110
msgstr ""
111
112
- #: post-expirator.php:466
113
msgid "type - defaults to full - valid options are full,date,time"
114
msgstr ""
115
116
- #: post-expirator.php:467
117
msgid ""
118
"dateformat - format set here will override the value set on the settings page"
119
msgstr ""
120
121
- #: post-expirator.php:468
122
msgid ""
123
"timeformat - format set here will override the value set on the settings page"
124
msgstr ""
125
126
- #: post-expirator.php:472
127
msgid "Defaults"
128
msgstr ""
129
130
- #: post-expirator.php:475
131
msgid "Set Post To:"
132
msgstr ""
133
134
- #: post-expirator.php:478 post-expirator.php:489
135
msgid "Draft"
136
msgstr ""
137
138
- #: post-expirator.php:479 post-expirator.php:490
139
msgid "Delete"
140
msgstr ""
141
142
- #: post-expirator.php:482
143
msgid ""
144
"Select whether the post should be deleted or changed to a draft at "
145
"expiration time."
146
msgstr ""
147
148
- #: post-expirator.php:486
149
msgid "Set Page To:"
150
msgstr ""
151
152
- #: post-expirator.php:493
153
msgid ""
154
"Select whether the page should be deleted or changed to a draft at "
155
"expiration time."
156
msgstr ""
157
158
- #: post-expirator.php:497
159
msgid "Date Format:"
160
msgstr ""
161
162
- #: post-expirator.php:501
163
msgid ""
164
"The default format to use when displaying the expiration date within a post "
165
"using the [postexpirator] shortcode or within the footer. For information "
@@ -167,11 +173,11 @@ msgid ""
167
"function.date.php\" target=\"_blank\">PHP Date Function</a>."
168
msgstr ""
169
170
- #: post-expirator.php:505
171
msgid "Time Format:"
172
msgstr ""
173
174
- #: post-expirator.php:509
175
msgid ""
176
"The default format to use when displaying the expiration time within a post "
177
"using the [postexpirator] shortcode or within the footer. For information "
@@ -179,86 +185,106 @@ msgid ""
179
"function.date.php\" target=\"_blank\">PHP Date Function</a>."
180
msgstr ""
181
182
- #: post-expirator.php:513
183
msgid "Post Footer Display"
184
msgstr ""
185
186
- #: post-expirator.php:514
187
msgid ""
188
"Enabling this below will display the expiration date automatically at the "
189
"end of any post which is set to expire."
190
msgstr ""
191
192
- #: post-expirator.php:517
193
msgid "Show in post footer?"
194
msgstr ""
195
196
- #: post-expirator.php:519
197
- msgid "Enabled"
198
- msgstr ""
199
-
200
- #: post-expirator.php:520
201
- msgid "Disabled"
202
- msgstr ""
203
-
204
- #: post-expirator.php:522
205
msgid ""
206
"This will enable or disable displaying the post expiration date in the post "
207
"footer."
208
msgstr ""
209
210
- #: post-expirator.php:526
211
msgid "Footer Contents:"
212
msgstr ""
213
214
- #: post-expirator.php:530
215
msgid ""
216
"Enter the text you would like to appear at the bottom of every post that "
217
"will expire. The following placeholders will be replaced with the post "
218
"expiration date in the following format:"
219
msgstr ""
220
221
- #: post-expirator.php:539
222
msgid "Footer Style:"
223
msgstr ""
224
225
- #: post-expirator.php:542
226
msgid "This post will expire on"
227
msgstr ""
228
229
- #: post-expirator.php:544
230
msgid "The inline css which will be used to style the footer text."
231
msgstr ""
232
233
- #: post-expirator.php:549
234
msgid "Save"
235
msgstr ""
236
237
- #: post-expirator.php:592
238
msgid "Cron Schedules Reset!"
239
msgstr ""
240
241
- #: post-expirator.php:597
242
msgid "OK"
243
msgstr ""
244
245
- #: post-expirator.php:599
246
msgid "RESET NEEDED"
247
msgstr ""
248
249
- #: post-expirator.php:606
250
msgid "Reset Cron Schedules:"
251
msgstr ""
252
253
- #: post-expirator.php:608
254
msgid "Reset"
255
msgstr ""
256
257
- #: post-expirator.php:609
258
msgid "Status:"
259
msgstr ""
260
261
- #: post-expirator.php:611
262
msgid "Resets the cron scheduler and removes any old or stray entries."
263
msgstr ""
264
@@ -268,8 +294,9 @@ msgstr ""
268
269
#. Description of the plugin/theme
270
msgid ""
271
- "Allows you to add an expiration date to posts which you can configure to "
272
- "either delete the post or change it to a draft."
273
msgstr ""
274
275
#. Author of the plugin/theme
1
+ # Copyright (C) 2012 Post Expirator
2
# This file is distributed under the same license as the Post Expirator package.
3
msgid ""
4
msgstr ""
5
+ "Project-Id-Version: Post Expirator 1.5\n"
6
"Report-Msgid-Bugs-To: http://wordpress.org/tag/post-expirator\n"
7
+ "POT-Creation-Date: 2012-02-26 16:23:06+00:00\n"
8
"MIME-Version: 1.0\n"
9
"Content-Type: text/plain; charset=UTF-8\n"
10
"Content-Transfer-Encoding: 8bit\n"
11
+ "PO-Revision-Date: 2012-MO-DA HO:MI+ZONE\n"
12
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
13
"Language-Team: LANGUAGE <LL@li.org>\n"
14
24
msgid "Post expires at EXPIRATIONTIME on EXPIRATIONDATE"
25
msgstr ""
26
27
+ #: post-expirator.php:44
28
msgid "Once a Minute"
29
msgstr ""
30
31
+ #: post-expirator.php:56
32
msgid "Post Expirator cron schedules need to be reset"
33
msgstr ""
34
35
+ #: post-expirator.php:58
36
msgid "Click here to reset"
37
msgstr ""
38
39
+ #: post-expirator.php:156
40
msgid "Expires"
41
msgstr ""
42
43
+ #: post-expirator.php:172
44
msgid "Never"
45
msgstr ""
46
47
+ #. #-#-#-#-# plugin.pot (Post Expirator 1.5) #-#-#-#-#
48
#. Plugin Name of the plugin/theme
49
+ #: post-expirator.php:184 post-expirator.php:186 post-expirator.php:439
50
msgid "Post Expirator"
51
msgstr ""
52
53
+ #: post-expirator.php:218
54
msgid "Enable Post Expiration"
55
msgstr ""
56
57
+ #: post-expirator.php:220
58
msgid "Year"
59
msgstr ""
60
61
+ #: post-expirator.php:221
62
msgid "Month"
63
msgstr ""
64
65
+ #: post-expirator.php:222
66
msgid "Day"
67
msgstr ""
68
69
+ #: post-expirator.php:251
70
msgid "Hour"
71
msgstr ""
72
73
+ #: post-expirator.php:252
74
msgid "Minute"
75
msgstr ""
76
77
+ #: post-expirator.php:262
78
msgid "H"
79
msgstr ""
80
81
+ #: post-expirator.php:273
82
+ msgid "Expiration Categories"
83
+ msgstr ""
84
+
85
+ #: post-expirator.php:283
86
+ msgid ""
87
+ "Setting an expiration category will change the category at expiration time, "
88
+ "and override the default post action"
89
+ msgstr ""
90
+
91
+ #: post-expirator.php:411 post-expirator.php:439
92
msgid "Post Expirator Options"
93
msgstr ""
94
95
+ #: post-expirator.php:414
96
msgid "General Settings"
97
msgstr ""
98
99
+ #: post-expirator.php:415 post-expirator.php:690
100
msgid "Upgrade"
101
msgstr ""
102
103
+ #: post-expirator.php:459
104
msgid "Saved Options!"
105
msgstr ""
106
107
+ #: post-expirator.php:520
108
msgid ""
109
"The post expirator plugin sets a custom meta value, and then optionally "
110
"allows you to select if you want the post changed to a draft status or "
111
"deleted when it expires."
112
msgstr ""
113
114
+ #: post-expirator.php:523
115
msgid "Valid [postexpiration] attributes:"
116
msgstr ""
117
118
+ #: post-expirator.php:525
119
msgid "type - defaults to full - valid options are full,date,time"
120
msgstr ""
121
122
+ #: post-expirator.php:526
123
msgid ""
124
"dateformat - format set here will override the value set on the settings page"
125
msgstr ""
126
127
+ #: post-expirator.php:527
128
msgid ""
129
"timeformat - format set here will override the value set on the settings page"
130
msgstr ""
131
132
+ #: post-expirator.php:531
133
msgid "Defaults"
134
msgstr ""
135
136
+ #: post-expirator.php:534
137
msgid "Set Post To:"
138
msgstr ""
139
140
+ #: post-expirator.php:537 post-expirator.php:548
141
msgid "Draft"
142
msgstr ""
143
144
+ #: post-expirator.php:538 post-expirator.php:549
145
msgid "Delete"
146
msgstr ""
147
148
+ #: post-expirator.php:541
149
msgid ""
150
"Select whether the post should be deleted or changed to a draft at "
151
"expiration time."
152
msgstr ""
153
154
+ #: post-expirator.php:545
155
msgid "Set Page To:"
156
msgstr ""
157
158
+ #: post-expirator.php:552
159
msgid ""
160
"Select whether the page should be deleted or changed to a draft at "
161
"expiration time."
162
msgstr ""
163
164
+ #: post-expirator.php:556
165
msgid "Date Format:"
166
msgstr ""
167
168
+ #: post-expirator.php:560
169
msgid ""
170
"The default format to use when displaying the expiration date within a post "
171
"using the [postexpirator] shortcode or within the footer. For information "
173
"function.date.php\" target=\"_blank\">PHP Date Function</a>."
174
msgstr ""
175
176
+ #: post-expirator.php:564
177
msgid "Time Format:"
178
msgstr ""
179
180
+ #: post-expirator.php:568
181
msgid ""
182
"The default format to use when displaying the expiration time within a post "
183
"using the [postexpirator] shortcode or within the footer. For information "
185
"function.date.php\" target=\"_blank\">PHP Date Function</a>."
186
msgstr ""
187
188
+ #: post-expirator.php:572
189
+ msgid "Category Expiration"
190
+ msgstr ""
191
+
192
+ #: post-expirator.php:575
193
+ msgid "Enable Post Expiration to Category?"
194
+ msgstr ""
195
+
196
+ #: post-expirator.php:577 post-expirator.php:606
197
+ msgid "Enabled"
198
+ msgstr ""
199
+
200
+ #: post-expirator.php:578 post-expirator.php:607
201
+ msgid "Disabled"
202
+ msgstr ""
203
+
204
+ #: post-expirator.php:580
205
+ msgid "This will enable or disable the ability to expire a post to a category."
206
+ msgstr ""
207
+
208
+ #: post-expirator.php:584
209
+ msgid "Default Expiration Category"
210
+ msgstr ""
211
+
212
+ #: post-expirator.php:595
213
+ msgid "Set's the default expiration category for the post."
214
+ msgstr ""
215
+
216
+ #: post-expirator.php:600
217
msgid "Post Footer Display"
218
msgstr ""
219
220
+ #: post-expirator.php:601
221
msgid ""
222
"Enabling this below will display the expiration date automatically at the "
223
"end of any post which is set to expire."
224
msgstr ""
225
226
+ #: post-expirator.php:604
227
msgid "Show in post footer?"
228
msgstr ""
229
230
+ #: post-expirator.php:609
231
msgid ""
232
"This will enable or disable displaying the post expiration date in the post "
233
"footer."
234
msgstr ""
235
236
+ #: post-expirator.php:613
237
msgid "Footer Contents:"
238
msgstr ""
239
240
+ #: post-expirator.php:617
241
msgid ""
242
"Enter the text you would like to appear at the bottom of every post that "
243
"will expire. The following placeholders will be replaced with the post "
244
"expiration date in the following format:"
245
msgstr ""
246
247
+ #: post-expirator.php:626
248
msgid "Footer Style:"
249
msgstr ""
250
251
+ #: post-expirator.php:629
252
msgid "This post will expire on"
253
msgstr ""
254
255
+ #: post-expirator.php:631
256
msgid "The inline css which will be used to style the footer text."
257
msgstr ""
258
259
+ #: post-expirator.php:636
260
msgid "Save"
261
msgstr ""
262
263
+ #: post-expirator.php:679
264
msgid "Cron Schedules Reset!"
265
msgstr ""
266
267
+ #: post-expirator.php:684
268
msgid "OK"
269
msgstr ""
270
271
+ #: post-expirator.php:686
272
msgid "RESET NEEDED"
273
msgstr ""
274
275
+ #: post-expirator.php:693
276
msgid "Reset Cron Schedules:"
277
msgstr ""
278
279
+ #: post-expirator.php:695
280
msgid "Reset"
281
msgstr ""
282
283
+ #: post-expirator.php:696
284
msgid "Status:"
285
msgstr ""
286
287
+ #: post-expirator.php:698
288
msgid "Resets the cron scheduler and removes any old or stray entries."
289
msgstr ""
290
294
295
#. Description of the plugin/theme
296
msgid ""
297
+ "Allows you to add an expiration date (minute) to posts which you can "
298
+ "configure to either delete the post, change it to a draft, or update the "
299
+ "post categories at expiration time."
300
msgstr ""
301
302
#. Author of the plugin/theme
post-expirator.php CHANGED
@@ -2,9 +2,9 @@
2
/*
3
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.3
8
Author URI: http://postexpirator.tuxdocs.net/
9
Translation: Thierry (http://palijn.info)
10
Text Domain: post-expirator
@@ -62,7 +62,7 @@ function postExpirationAdminNotice() {
62
add_action('admin_notices','postExpirationAdminNotice');
63
64
/**
65
- * Function that does the actualy deleting - called by wp_cron
66
*/
67
function expirationdate_delete_expired_posts() {
68
global $wpdb;
@@ -70,6 +70,10 @@ function expirationdate_delete_expired_posts() {
70
$time_delete = time();
71
$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 . '"');
72
if (!empty($result)) foreach ($result as $a) {
73
$post_result = $wpdb->get_var('select post_type from ' . $wpdb->posts .' where ID = '. $a->post_id);
74
if ($post_result == 'post') {
75
$expiredStatus = strtolower(get_option('expirationdateExpiredPostStatus'));
@@ -79,13 +83,23 @@ function expirationdate_delete_expired_posts() {
79
$expiredStatus = 'draft';
80
}
81
82
- if ($expiredStatus == 'delete')
83
- wp_delete_post($a->post_id);
84
- else {
85
- wp_update_post(array('ID' => $a->post_id, 'post_status' => 'draft'));
86
- delete_post_meta($a->post_id, 'expiration-date');
87
- update_post_meta($a->post_id, 'expiration-date', $a->meta_value, true);
88
}
89
}
90
}
91
if (postExpirator_is_wpmu())
@@ -105,6 +119,7 @@ function expirationdate_activate () {
105
update_option('expirationdateFooterContents',$expirationdateDefaultFooterContents);
106
update_option('expirationdateFooterStyle',$expirationdateDefaultFooterStyle);
107
update_option('expirationdateDisplayFooter',0);
108
postExpiratorTimezoneSetup();
109
110
if (postExpirator_is_wpmu())
@@ -126,6 +141,7 @@ function expirationdate_deactivate () {
126
delete_option('expirationdateDisplayFooter');
127
delete_option('expirationdateFooterContents');
128
delete_option('expirationdateFooterStyle');
129
if (postExpirator_is_wpmu())
130
wp_clear_scheduled_hook('expirationdate_delete_'.$current_blog->blog_id);
131
else
@@ -160,23 +176,16 @@ add_action ('manage_posts_custom_column', 'expirationdate_show_value');
160
add_action ('manage_pages_custom_column', 'expirationdate_show_value');
161
162
/**
163
- * Adds hooks to get the meta box added to page
164
- */
165
- function expirationdate_meta_page() {
166
- add_meta_box('expirationdatediv', __('Post Expirator','post-expirator'), 'expirationdate_meta_box', 'page', 'advanced', 'high');
167
- }
168
- add_action ('edit_page_form','expirationdate_meta_page');
169
-
170
- /**
171
- * Adds hooks to get the meta box added to custom post types
172
*/
173
function expirationdate_meta_custom() {
174
- $custom_post_types = get_post_types();
175
- foreach ($custom_post_types as $t) {
176
- add_meta_box('expirationdatediv', __('Post Expirator','post-expirator'), 'expirationdate_meta_box', $t, 'advanced', 'high');
177
- }
178
}
179
- add_action ('edit_form_advanced','expirationdate_meta_custom');
180
181
/**
182
* Actually adds the meta box
@@ -192,13 +201,14 @@ function expirationdate_meta_box($post) {
192
$defaultyear = date('Y');
193
$defaultminute = date('i');
194
$disabled = 'disabled="disabled"';
195
} else {
196
$defaultmonth = date('F',$expirationdatets);
197
$defaultday = date('d',$expirationdatets);
198
$defaultyear = date('Y',$expirationdatets);
199
$defaulthour = date('H',$expirationdatets);
200
$defaultminute = date('i',$expirationdatets);
201
-
202
$enabled = ' checked="checked"';
203
$disabled = '';
204
}
@@ -212,7 +222,7 @@ function expirationdate_meta_box($post) {
212
$rv[] = '<th style="text-align: left;">'.__('Day','post-expirator').'</th>';
213
$rv[] = '</tr><tr>';
214
$rv[] = '<td>';
215
- $rv[] = '<select name="expirationdate_year" id="expirationdate_year"'.$disabled.'">';
216
$currentyear = date('Y');
217
if ($defaultyear < $currentyear)
218
$currentyear = $defaultyear;
@@ -225,25 +235,25 @@ function expirationdate_meta_box($post) {
225
}
226
$rv[] = '</select>';
227
$rv[] = '</td><td>';
228
- $rv[] = '<select name="expirationdate_month" id="expirationdate_month"'.$disabled.'">';
229
for($i = 1; $i <= 12; $i++) {
230
if ($defaultmonth == date('F',mktime(0, 0, 0, $i, 1, date("Y"))))
231
$selected = ' selected="selected"';
232
else
233
$selected = '';
234
- $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>';
235
}
236
$rv[] = '</select>';
237
$rv[] = '</td><td>';
238
- $rv[] = '<input type="text" id="expirationdate_day" name="expirationdate_day" value="'.$defaultday.'" size="2"'.$disabled.'" />,';
239
$rv[] = '</td></tr><tr>';
240
$rv[] = '<th style="text-align: left;"></th>';
241
$rv[] = '<th style="text-align: left;">'.__('Hour','post-expirator').'('.date('T',mktime(0, 0, 0, $i, 1, date("Y"))).')</th>';
242
$rv[] = '<th style="text-align: left;">'.__('Minute','post-expirator').'</th>';
243
$rv[] = '</tr><tr>';
244
$rv[] = '<td>@</td><td>';
245
- /* $rv[] = '<input type="text" id="expirationdate_hour" name="expirationdate_hour" value="'.$defaulthour.'" size="2"'.$disabled.'" />'; */
246
- $rv[] = '<select name="expirationdate_hour" id="expirationdate_hour"'.$disabled.'">';
247
for($i = 1; $i <= 24; $i++) {
248
if ($defaulthour == date('H',mktime($i, 0, 0, date("n"), date("j"), date("Y"))))
249
$selected = ' selected="selected"';
@@ -252,13 +262,27 @@ function expirationdate_meta_box($post) {
252
$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>';
253
}
254
$rv[] = '</td><td>';
255
- $rv[] = '<input type="text" id="expirationdate_minute" name="expirationdate_minute" value="'.$defaultminute.'" size="2"'.$disabled.'" />';
256
$rv[] = '<input type="hidden" name="expirationdate_formcheck" value="true" />';
257
$rv[] = '</td></tr></table>';
258
259
- $rv[] = '<div id="expirationdate_ajax_result"></div>';
260
261
- echo implode("\n",$rv);
262
}
263
264
/**
@@ -296,12 +320,22 @@ function expirationdate_ajax_add_meta(expireenable) {
296
document.getElementById('expirationdate_year').disabled = false;
297
document.getElementById('expirationdate_hour').disabled = false;
298
document.getElementById('expirationdate_minute').disabled = false;
299
} else {
300
document.getElementById('expirationdate_month').disabled = true;
301
document.getElementById('expirationdate_day').disabled = true;
302
document.getElementById('expirationdate_year').disabled = true;
303
document.getElementById('expirationdate_hour').disabled = true;
304
document.getElementById('expirationdate_minute').disabled = true;
305
var enable = 'false';
306
}
307
@@ -346,17 +380,26 @@ function expirationdate_update_post_meta($id) {
346
$year = $_POST['expirationdate_year'];
347
$hour = $_POST['expirationdate_hour'];
348
$minute = $_POST['expirationdate_minute'];
349
-
350
if (isset($_POST['enable-expirationdate'])) {
351
postExpiratorTimezoneSetup();
352
// Format Date
353
$ts = mktime($hour,$minute,0,$month,$day,$year);
354
355
// Update Post Meta
356
delete_post_meta($id, 'expiration-date');
357
update_post_meta($id, 'expiration-date', $ts, true);
358
} else {
359
delete_post_meta($id, 'expiration-date');
360
}
361
}
362
add_action('save_post','expirationdate_update_post_meta');
@@ -410,6 +453,8 @@ function postExpiratorMenuGeneral() {
410
update_option('expirationdateDisplayFooter',$_POST['expired-display-footer']);
411
update_option('expirationdateFooterContents',$_POST['expired-footer-contents']);
412
update_option('expirationdateFooterStyle',$_POST['expired-footer-style']);
413
echo "<div id='message' class='updated fade'><p>";
414
_e('Saved Options!','post-expirator');
415
echo "</p></div>";
@@ -436,6 +481,12 @@ function postExpiratorMenuGeneral() {
436
$expirationdateDefaultTimeFormat = $expirationdateDefaultTimeFormat;
437
}
438
439
$expireddisplayfooter = get_option('expirationdateDisplayFooter');
440
if (empty($expireddisplayfooter))
441
$expireddisplayfooter = 0;
@@ -447,6 +498,11 @@ function postExpiratorMenuGeneral() {
447
else if ($expireddisplayfooter == 1)
448
$expireddisplayfooterenabled = 'checked="checked"';
449
450
$expirationdateFooterContents = get_option('expirationdateFooterContents');
451
if (empty($expirationdateFooterContents)) {
452
global $expirationdateDefaultFooterContents;
@@ -513,6 +569,34 @@ function postExpiratorMenuGeneral() {
513
</td>
514
</tr>
515
</table>
516
<h3><?php _e('Post Footer Display','post-expirator');?></h3>
517
<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>
518
<table class="form-table">
@@ -708,3 +792,54 @@ function postexpirator_add_footer($text) {
708
return $text.$add_to_footer;
709
}
710
add_action('the_content','postexpirator_add_footer',0);
2
/*
3
Plugin Name: Post Expirator
4
Plugin URI: http://wordpress.org/extend/plugins/post-expirator/
5
+ Description: Allows you to add an expiration date (minute) to posts which you can configure to either delete the post, change it to a draft, or update the post categories at expiration time.
6
Author: Aaron Axelsen
7
+ Version: 1.5
8
Author URI: http://postexpirator.tuxdocs.net/
9
Translation: Thierry (http://palijn.info)
10
Text Domain: post-expirator
62
add_action('admin_notices','postExpirationAdminNotice');
63
64
/**
65
+ * Function that does the actual deleting - called by wp_cron
66
*/
67
function expirationdate_delete_expired_posts() {
68
global $wpdb;
70
$time_delete = time();
71
$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 . '"');
72
if (!empty($result)) foreach ($result as $a) {
73
+ // Check to see if already proccessed
74
+ $processed = $wpdb->get_var('select meta_value from ' . $wpdb->postmeta . ' as postmeta, '.$wpdb->posts.' as posts where postmeta.post_id = posts.ID AND posts.ID = '.$a->post_id.' postmeta.meta_key = "_expiration-date-processed"');
75
+ if (!empty($processed) && $processed == 1) continue;
76
+
77
$post_result = $wpdb->get_var('select post_type from ' . $wpdb->posts .' where ID = '. $a->post_id);
78
if ($post_result == 'post') {
79
$expiredStatus = strtolower(get_option('expirationdateExpiredPostStatus'));
83
$expiredStatus = 'draft';
84
}
85
86
+ // Check to see if expiration category is enabled and set - otherwise, proceed as normal
87
+ $catEnabled = get_option('expirationdateCategory');
88
+ $cat = get_post_meta($a->post_id,'_expiration-date-category');
89
+ if (($catEnabled === false || $catEnabled == 1) && (isset($cat) && !empty($cat[0]))) {
90
+ wp_update_post(array('ID' => $a->post_id, 'post_category' => $cat[0]));
91
+ } else {
92
+ if ($expiredStatus == 'delete')
93
+ wp_delete_post($a->post_id);
94
+ else {
95
+ wp_update_post(array('ID' => $a->post_id, 'post_status' => 'draft'));
96
+ delete_post_meta($a->post_id, 'expiration-date');
97
+ update_post_meta($a->post_id, 'expiration-date', $a->meta_value, true);
98
+ }
99
}
100
+
101
+ // Mark as Processed
102
+ update_post_meta($a->post_id, '_expiration-date-processed', 1);
103
}
104
}
105
if (postExpirator_is_wpmu())
119
update_option('expirationdateFooterContents',$expirationdateDefaultFooterContents);
120
update_option('expirationdateFooterStyle',$expirationdateDefaultFooterStyle);
121
update_option('expirationdateDisplayFooter',0);
122
+ update_option('expirationdateCategory',1);
123
postExpiratorTimezoneSetup();
124
125
if (postExpirator_is_wpmu())
141
delete_option('expirationdateDisplayFooter');
142
delete_option('expirationdateFooterContents');
143
delete_option('expirationdateFooterStyle');
144
+ delete_option('expirationdateCategory');
145
if (postExpirator_is_wpmu())
146
wp_clear_scheduled_hook('expirationdate_delete_'.$current_blog->blog_id);
147
else
176
add_action ('manage_pages_custom_column', 'expirationdate_show_value');
177
178
/**
179
+ * Adds hooks to get the meta box added to pages and custom post types
180
*/
181
function expirationdate_meta_custom() {
182
+ $custom_post_types = get_post_types();
183
+ foreach ($custom_post_types as $t) {
184
+ add_meta_box('expirationdatediv', __('Post Expirator','post-expirator'), 'expirationdate_meta_box', 'post', 'side', 'core');
185
+ }
186
+ add_meta_box('expirationdatediv', __('Post Expirator','post-expirator'), 'expirationdate_meta_box', 'page', 'side', 'core');
187
}
188
+ add_action ('add_meta_boxes','expirationdate_meta_custom');
189
190
/**
191
* Actually adds the meta box
201
$defaultyear = date('Y');
202
$defaultminute = date('i');
203
$disabled = 'disabled="disabled"';
204
+ $categories = get_option('expirationdateCategoryDefaults');
205
} else {
206
$defaultmonth = date('F',$expirationdatets);
207
$defaultday = date('d',$expirationdatets);
208
$defaultyear = date('Y',$expirationdatets);
209
$defaulthour = date('H',$expirationdatets);
210
$defaultminute = date('i',$expirationdatets);
211
+ $categories = get_post_meta($post->ID,'_expiration-date-category',true);
212
$enabled = ' checked="checked"';
213
$disabled = '';
214
}
222
$rv[] = '<th style="text-align: left;">'.__('Day','post-expirator').'</th>';
223
$rv[] = '</tr><tr>';
224
$rv[] = '<td>';
225
+ $rv[] = '<select name="expirationdate_year" id="expirationdate_year"'.$disabled.'>';
226
$currentyear = date('Y');
227
if ($defaultyear < $currentyear)
228
$currentyear = $defaultyear;
235
}
236
$rv[] = '</select>';
237
$rv[] = '</td><td>';
238
+ $rv[] = '<select name="expirationdate_month" id="expirationdate_month"'.$disabled.'>';
239
for($i = 1; $i <= 12; $i++) {
240
if ($defaultmonth == date('F',mktime(0, 0, 0, $i, 1, date("Y"))))
241
$selected = ' selected="selected"';
242
else
243
$selected = '';
244
+ $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"))),'post-expirator').'</option>';
245
}
246
$rv[] = '</select>';
247
$rv[] = '</td><td>';
248
+ $rv[] = '<input type="text" id="expirationdate_day" name="expirationdate_day" value="'.$defaultday.'" size="2"'.$disabled.' />,';
249
$rv[] = '</td></tr><tr>';
250
$rv[] = '<th style="text-align: left;"></th>';
251
$rv[] = '<th style="text-align: left;">'.__('Hour','post-expirator').'('.date('T',mktime(0, 0, 0, $i, 1, date("Y"))).')</th>';
252
$rv[] = '<th style="text-align: left;">'.__('Minute','post-expirator').'</th>';
253
$rv[] = '</tr><tr>';
254
$rv[] = '<td>@</td><td>';
255
+ /* $rv[] = '<input type="text" id="expirationdate_hour" name="expirationdate_hour" value="'.$defaulthour.'" size="2"'.$disabled.' />'; */
256
+ $rv[] = '<select name="expirationdate_hour" id="expirationdate_hour"'.$disabled.'>';
257
for($i = 1; $i <= 24; $i++) {
258
if ($defaulthour == date('H',mktime($i, 0, 0, date("n"), date("j"), date("Y"))))
259
$selected = ' selected="selected"';
262
$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>';
263
}
264
$rv[] = '</td><td>';
265
+ $rv[] = '<input type="text" id="expirationdate_minute" name="expirationdate_minute" value="'.$defaultminute.'" size="2"'.$disabled.' />';
266
$rv[] = '<input type="hidden" name="expirationdate_formcheck" value="true" />';
267
$rv[] = '</td></tr></table>';
268
+ echo implode("\n",$rv);
269
270
+ $catEnabled = get_option('expirationdateCategory');
271
+ if (($post->post_type != 'page') && ($catEnabled === false || $catEnabled == 1)) {
272
+ $args = array('hide_empty' => 0,'orderby' => 'name','hierarchical' => 0);
273
+ echo '<br/>'.__('Expiration Categories','post-expirator').':<br/>';
274
275
+ echo '<div class="wp-tab-panel" id="post-expirator-cat-list">';
276
+ echo '<ul id="categorychecklist" class="list:category categorychecklist form-no-clear">';
277
+ $walker = new Walker_PostExpirator_Category_Checklist();
278
+ if (!empty($disabled)) $walker->setDisabled();
279
+ wp_terms_checklist(0, array( 'taxonomy' => 'category', 'walker' => $walker, 'selected_cats' => $categories, 'checked_ontop' => false ) );
280
+ echo '</ul>';
281
+ echo '</div>';
282
+
283
+ echo '<p class="howto">'.__('Setting an expiration category will change the category at expiration time, and override the default post action','post-expirator').'.</p>';
284
+ }
285
+ echo '<div id="expirationdate_ajax_result"></div>';
286
}
287
288
/**
320
document.getElementById('expirationdate_year').disabled = false;
321
document.getElementById('expirationdate_hour').disabled = false;
322
document.getElementById('expirationdate_minute').disabled = false;
323
+ var cats = document.getElementsByName('expirationdate_category[]');
324
+ var max = cats.length;
325
+ for (var i=0; i<max; i++) {
326
+ cats[i].disabled = '';
327
+ }
328
} else {
329
document.getElementById('expirationdate_month').disabled = true;
330
document.getElementById('expirationdate_day').disabled = true;
331
document.getElementById('expirationdate_year').disabled = true;
332
document.getElementById('expirationdate_hour').disabled = true;
333
document.getElementById('expirationdate_minute').disabled = true;
334
+ var cats = document.getElementsByName('expirationdate_category[]');
335
+ var max = cats.length;
336
+ for (var i=0; i<max; i++) {
337
+ cats[i].disabled = 'disable';
338
+ }
339
var enable = 'false';
340
}
341
380
$year = $_POST['expirationdate_year'];
381
$hour = $_POST['expirationdate_hour'];
382
$minute = $_POST['expirationdate_minute'];
383
+ $category = $_POST['expirationdate_category'];
384
if (isset($_POST['enable-expirationdate'])) {
385
postExpiratorTimezoneSetup();
386
// Format Date
387
$ts = mktime($hour,$minute,0,$month,$day,$year);
388
389
// Update Post Meta
390
+ delete_post_meta($id, '_expiration-date-category');
391
delete_post_meta($id, 'expiration-date');
392
update_post_meta($id, 'expiration-date', $ts, true);
393
+
394
+ $catEnabled = get_option('expirationdateCategory');
395
+ if ((isset($category) && !empty($category)) && ($catEnabled === false || $catEnabled == 1)) {
396
+ if (!empty($category)) update_post_meta($id, '_expiration-date-category', $category);
397
+ }
398
+ update_post_meta($id, '_expiration-date-processed', 0, true);
399
} else {
400
delete_post_meta($id, 'expiration-date');
401
+ delete_post_meta($id, '_expiration-date-category');
402
+ delete_post_meta($id, '_expiration-date-processed');
403
}
404
}
405
add_action('save_post','expirationdate_update_post_meta');
453
update_option('expirationdateDisplayFooter',$_POST['expired-display-footer']);
454
update_option('expirationdateFooterContents',$_POST['expired-footer-contents']);
455
update_option('expirationdateFooterStyle',$_POST['expired-footer-style']);
456
+ update_option('expirationdateCategory',$_POST['expired-category']);
457
+ update_option('expirationdateCategoryDefaults',$_POST['expirationdate_category']);
458
echo "<div id='message' class='updated fade'><p>";
459
_e('Saved Options!','post-expirator');
460
echo "</p></div>";
481
$expirationdateDefaultTimeFormat = $expirationdateDefaultTimeFormat;
482
}
483
484
+ $categories = get_option('expirationdateCategoryDefaults');
485
+
486
+ $expiredcategory = get_option('expirationdateCategory');
487
+ if (!isset($expiredcategory))
488
+ $expiredcategory = 1;
489
+
490
$expireddisplayfooter = get_option('expirationdateDisplayFooter');
491
if (empty($expireddisplayfooter))
492
$expireddisplayfooter = 0;
498
else if ($expireddisplayfooter == 1)
499
$expireddisplayfooterenabled = 'checked="checked"';
500
501
+ if ($expiredcategory == 0)
502
+ $expiredcategorydisabled = 'checked="checked"';
503
+ else if ($expiredcategory == 1)
504
+ $expiredcategoryenabled = 'checked="checked"';
505
+
506
$expirationdateFooterContents = get_option('expirationdateFooterContents');
507
if (empty($expirationdateFooterContents)) {
508
global $expirationdateDefaultFooterContents;
569
</td>
570
</tr>
571
</table>
572
+ <h3><?php _e('Category Expiration','post-expirator');?></h3>
573
+ <table class="form-table">
574
+ <tr valign-"top">
575
+ <th scope="row"><?php _e('Enable Post Expiration to Category?','post-expirator');?></th>
576
+ <td>
577
+ <input type="radio" name="expired-category" id="expired-category-true" value="1" <?php echo $expiredcategoryenabled ?>/> <label for="expired-category-true"><?php _e('Enabled','post-expirator');?></label>
578
+ <input type="radio" name="expired-category" id="expired-category-false" value="0" <?php echo $expiredcategorydisabled ?>/> <label for="expired-category-false"><?php _e('Disabled','post-expirator');?></label>
579
+ <br/>
580
+ <?php _e('This will enable or disable the ability to expire a post to a category.','post-expirator');?>
581
+ </td>
582
+ </tr>
583
+ <tr valign-"top">
584
+ <th scope="row"><?php _e('Default Expiration Category','post-expirator');?>:</th>
585
+ <td>
586
+ <?php
587
+ echo '<div class="wp-tab-panel" id="post-expirator-cat-list">';
588
+ echo '<ul id="categorychecklist" class="list:category categorychecklist form-no-clear">';
589
+ $walker = new Walker_PostExpirator_Category_Checklist();
590
+ wp_terms_checklist(0, array( 'taxonomy' => 'category', 'walker' => $walker, 'selected_cats' => $categories, 'checked_ontop' => false ) );
591
+ echo '</ul>';
592
+ echo '</div>';
593
+ ?>
594
+ <br/>
595
+ <?php _e("Set's the default expiration category for the post.",'post-expirator');?>
596
+ </td>
597
+ </tr>
598
+ </table>
599
+
600
<h3><?php _e('Post Footer Display','post-expirator');?></h3>
601
<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>
602
<table class="form-table">
792
return $text.$add_to_footer;
793
}
794
add_action('the_content','postexpirator_add_footer',0);
795
+
796
+ /**
797
+ * Add Stylesheet
798
+ */
799
+ function postexpirator_css() {
800
+ $myStyleUrl = plugins_url('style.css', __FILE__); // Respects SSL, Style.css is relative to the current file
801
+ $myStyleFile = WP_PLUGIN_DIR . '/post-expirator/style.css';
802
+ if ( file_exists($myStyleFile) ) {
803
+ wp_register_style('postexpirator-css', $myStyleUrl);
804
+ wp_enqueue_style('postexpirator-css');
805
+ }
806
+
807
+ }
808
+ add_action('admin_init','postexpirator_css');
809
+
810
+ class Walker_PostExpirator_Category_Checklist extends Walker {
811
+ var $tree_type = 'category';
812
+ var $db_fields = array ('parent' => 'parent', 'id' => 'term_id'); //TODO: decouple this
813
+
814
+ var $disabled = '';
815
+
816
+ function setDisabled() {
817
+ $this->disabled = 'disabled="disabled"';
818
+ }
819
+
820
+ function start_lvl(&$output, $depth, $args) {
821
+ $indent = str_repeat("\t", $depth);
822
+ $output .= "$indent<ul class='children'>\n";
823
+ }
824
+
825
+ function end_lvl(&$output, $depth, $args) {
826
+ $indent = str_repeat("\t", $depth);
827
+ $output .= "$indent</ul>\n";
828
+ }
829
+
830
+ function start_el(&$output, $category, $depth, $args) {
831
+ extract($args);
832
+ if ( empty($taxonomy) )
833
+ $taxonomy = 'category';
834
+
835
+ $name = 'expirationdate_category';
836
+
837
+ $class = in_array( $category->term_id, $popular_cats ) ? ' class="popular-category"' : '';
838
+ $output .= "\n<li id='{$taxonomy}-{$category->term_id}'$class>" . '<label class="selectit"><input value="' . $category->term_id . '" type="checkbox" name="'.$name.'[]" id="in-'.$taxonomy.'-' . $category->term_id . '"' . checked( in_array( $category->term_id, $selected_cats ), true, false ) . disabled( empty( $args['disabled'] ), false, false ) . ' '.$this->disabled.'/> ' . esc_html( apply_filters('the_category', $category->name )) . '</label>';
839
+ }
840
+
841
+ function end_el(&$output, $category, $depth, $args) {
842
+ $output .= "</li>\n";
843
+ }
844
+ }
845
+
readme.txt CHANGED
@@ -1,18 +1,21 @@
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.3
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
10
== Description ==
11
12
The Post Expirator plugin allows the user to set expiration dates for both posts and pages. There is a configuration option page in the plugins
13
- area that will allow you to seperataly control whether or not posts/pages are wither deleted or changed to draft status.
14
15
- The plugin hooks into the wp cron processes and runs every hour.
16
17
The expiration date can be displayed within the actual post by using the [postexpirator] tag. The format attribute will override the plugin
18
default display format. See the [PHP Date Function](http://us2.php.net/manual/en/function.date.php) for valid date/time format options.
@@ -25,24 +28,22 @@ Plugin homepage [WordPress Post Expirator](http://postexpirator.tuxdocs.net).
25
* dateformat - format set here will override the value set on the settings page
26
* timeformat - format set here will override the value set on the settings page
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
31
- functions.
32
-
33
- == Credits ==
34
-
35
- Plugin is based on the orginial [Expiration Date](http://www.hostscope.com/wordpress-plugins/the-expirationdate-wordpress-plugin/) plugin by jrrl.
36
37
== Installation ==
38
39
This section describes how to install the plugin and get it working.
40
41
- 1. Upload `plugin-name.php` to the `/wp-content/plugins/` directory
42
2. Activate the plugin through the 'Plugins' menu in WordPress
43
44
== Changelog ==
45
46
**Version 1.4.3**
47
48
* Fixed issue with 3.0 multisite detection
1
=== Post Expirator ===
2
Contributors: axelseaa
3
Tags: expire, posts, pages, schedule
4
+ Requires at least: 3.0
5
+ Tested up to: 3.3.1
6
+ Stable tag: 1.5
7
8
+ Allows you to add an expiration date to posts which you can configure to either delete the post, change it to a draft, or update the
9
+ post categories.
10
11
== Description ==
12
13
The Post Expirator plugin allows the user to set expiration dates for both posts and pages. There is a configuration option page in the plugins
14
+ area that will allow you to seperataly control whether or not posts/pages are either deleted or changed to draft status. Additionally you can
15
+ also choose to have the post categories change at expiration time. If you choose to change the post category, the default action of changing
16
+ the status will be ignored.
17
18
+ The plugin hooks into the wp cron processes and runs every minute.
19
20
The expiration date can be displayed within the actual post by using the [postexpirator] tag. The format attribute will override the plugin
21
default display format. See the [PHP Date Function](http://us2.php.net/manual/en/function.date.php) for valid date/time format options.
28
* dateformat - format set here will override the value set on the settings page
29
* timeformat - format set here will override the value set on the settings page
30
31
+ This plugin is fully compatible with WordPress Multisite Mode.
32
33
== Installation ==
34
35
This section describes how to install the plugin and get it working.
36
37
+ 1. Unzip the plugin contents to the `/wp-content/plugins/post-expirator/` directory
38
2. Activate the plugin through the 'Plugins' menu in WordPress
39
40
== Changelog ==
41
42
+ **Version 1.5**
43
+
44
+ * Moved Expirator Box to Sidebar and cleaned up meta code
45
+ * Added ability to expire post to category
46
+
47
**Version 1.4.3**
48
49
* Fixed issue with 3.0 multisite detection
style.css ADDED
@@ -0,0 +1,9 @@
1
+ #post-expirator-cat-list {
2
+ max-width: 250px;
3
+ }
4
+ #post-expirator-cat-list ul {
5
+ margin: 0;
6
+ }
7
+ #post-expirator-cat-list ul ul {
8
+ margin-left: 18px;
9
+ }