Version Description
This is a major update of the core functions of this plugin. All current plugins and settings should be upgraded to the new formats and work as expected. Any posts currently schedule to be expirated in the future will be automatically upgraded to the new format.
Download this release
Release Info
Developer | axelseaa |
Plugin | Post Expirator |
Version | 2.0.0 |
Comparing to | |
See all releases |
Code changes from version 1.6.2 to 2.0.0
- languages/post-expirator.pot +133 -195
- post-expirator-debug.php +4 -5
- post-expirator.php +480 -377
- readme.txt +24 -2
- screenshot-1.png +0 -0
- screenshot-2.png +0 -0
- screenshot-3.png +0 -0
languages/post-expirator.pot
CHANGED
@@ -1,195 +1,149 @@
|
|
1 |
-
# Copyright (C)
|
2 |
# This file is distributed under the same license as the Post Expirator package.
|
3 |
msgid ""
|
4 |
msgstr ""
|
5 |
-
"Project-Id-Version: Post Expirator
|
6 |
"Report-Msgid-Bugs-To: http://wordpress.org/tag/post-expirator\n"
|
7 |
-
"POT-Creation-Date:
|
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:
|
12 |
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
13 |
"Language-Team: LANGUAGE <LL@li.org>\n"
|
14 |
|
15 |
-
#: post-expirator-debug.php:
|
16 |
msgid "Debugging table is currently empty."
|
17 |
msgstr ""
|
18 |
|
19 |
-
#: post-expirator-debug.php:
|
20 |
msgid "Timestamp"
|
21 |
msgstr ""
|
22 |
|
23 |
-
#: post-expirator-debug.php:
|
24 |
msgid "Message"
|
25 |
msgstr ""
|
26 |
|
27 |
-
#: post-expirator.php:
|
28 |
msgid "l F jS, Y"
|
29 |
msgstr ""
|
30 |
|
31 |
-
#: post-expirator.php:
|
32 |
msgid "g:ia"
|
33 |
msgstr ""
|
34 |
|
35 |
-
#: post-expirator.php:
|
36 |
msgid "Post expires at EXPIRATIONTIME on EXPIRATIONDATE"
|
37 |
msgstr ""
|
38 |
|
39 |
-
#: post-expirator.php:
|
40 |
-
msgid "Once a Minute"
|
41 |
-
msgstr ""
|
42 |
-
|
43 |
-
#: post-expirator.php:62
|
44 |
msgid "Settings"
|
45 |
msgstr ""
|
46 |
|
47 |
-
#: post-expirator.php:
|
48 |
-
msgid "Cron Events Reset!"
|
49 |
-
msgstr ""
|
50 |
-
|
51 |
-
#: post-expirator.php:79
|
52 |
-
msgid "Post Expirator cron events need to be reset. "
|
53 |
-
msgstr ""
|
54 |
-
|
55 |
-
#: post-expirator.php:81
|
56 |
-
msgid "Click here to reset"
|
57 |
-
msgstr ""
|
58 |
-
|
59 |
-
#: post-expirator.php:159
|
60 |
msgid "Expires"
|
61 |
msgstr ""
|
62 |
|
63 |
-
#: post-expirator.php:
|
64 |
msgid "Never"
|
65 |
msgstr ""
|
66 |
|
67 |
-
#. #-#-#-#-# plugin.pot (Post Expirator
|
68 |
#. Plugin Name of the plugin/theme
|
69 |
-
#: post-expirator.php:
|
70 |
msgid "Post Expirator"
|
71 |
msgstr ""
|
72 |
|
73 |
-
#: post-expirator.php:
|
74 |
msgid "Enable Post Expiration"
|
75 |
msgstr ""
|
76 |
|
77 |
-
#: post-expirator.php:
|
78 |
msgid "The published date/time will be used as the expiration value"
|
79 |
msgstr ""
|
80 |
|
81 |
-
#: post-expirator.php:
|
82 |
msgid "Year"
|
83 |
msgstr ""
|
84 |
|
85 |
-
#: post-expirator.php:
|
86 |
msgid "Month"
|
87 |
msgstr ""
|
88 |
|
89 |
-
#: post-expirator.php:
|
90 |
msgid "Day"
|
91 |
msgstr ""
|
92 |
|
93 |
-
#: post-expirator.php:
|
94 |
msgid "Hour"
|
95 |
msgstr ""
|
96 |
|
97 |
-
#: post-expirator.php:
|
98 |
msgid "Minute"
|
99 |
msgstr ""
|
100 |
|
101 |
-
#: post-expirator.php:
|
102 |
-
msgid "
|
103 |
msgstr ""
|
104 |
|
105 |
-
#: post-expirator.php:
|
106 |
-
msgid ""
|
107 |
-
"Setting an expiration category will change the category at expiration time, "
|
108 |
-
"and override the default post action"
|
109 |
msgstr ""
|
110 |
|
111 |
-
#: post-expirator.php:
|
112 |
msgid "General Settings"
|
113 |
msgstr ""
|
114 |
|
115 |
-
#: post-expirator.php:
|
|
|
|
|
|
|
|
|
116 |
msgid "Diagnostics"
|
117 |
msgstr ""
|
118 |
|
119 |
-
#: post-expirator.php:
|
120 |
msgid "View Debug Logs"
|
121 |
msgstr ""
|
122 |
|
123 |
-
#: post-expirator.php:
|
124 |
msgid "Post Expirator Options"
|
125 |
msgstr ""
|
126 |
|
127 |
-
#: post-expirator.php:
|
128 |
msgid "Saved Options!"
|
129 |
msgstr ""
|
130 |
|
131 |
-
#: post-expirator.php:
|
132 |
msgid ""
|
133 |
"The post expirator plugin sets a custom meta value, and then optionally "
|
134 |
"allows you to select if you want the post changed to a draft status or "
|
135 |
"deleted when it expires."
|
136 |
msgstr ""
|
137 |
|
138 |
-
#: post-expirator.php:
|
139 |
msgid "Valid [postexpirator] attributes:"
|
140 |
msgstr ""
|
141 |
|
142 |
-
#: post-expirator.php:
|
143 |
msgid "type - defaults to full - valid options are full,date,time"
|
144 |
msgstr ""
|
145 |
|
146 |
-
#: post-expirator.php:
|
147 |
msgid ""
|
148 |
"dateformat - format set here will override the value set on the settings page"
|
149 |
msgstr ""
|
150 |
|
151 |
-
#: post-expirator.php:
|
152 |
msgid ""
|
153 |
"timeformat - format set here will override the value set on the settings page"
|
154 |
msgstr ""
|
155 |
|
156 |
-
#: post-expirator.php:
|
157 |
-
msgid "Defaults"
|
158 |
-
msgstr ""
|
159 |
-
|
160 |
-
#: post-expirator.php:540
|
161 |
-
msgid "Set Post To:"
|
162 |
-
msgstr ""
|
163 |
-
|
164 |
-
#: post-expirator.php:543 post-expirator.php:554
|
165 |
-
msgid "Draft"
|
166 |
-
msgstr ""
|
167 |
-
|
168 |
-
#: post-expirator.php:544 post-expirator.php:555
|
169 |
-
msgid "Delete"
|
170 |
-
msgstr ""
|
171 |
-
|
172 |
-
#: post-expirator.php:547
|
173 |
-
msgid ""
|
174 |
-
"Select whether the post should be deleted or changed to a draft at "
|
175 |
-
"expiration time."
|
176 |
-
msgstr ""
|
177 |
-
|
178 |
-
#: post-expirator.php:551
|
179 |
-
msgid "Set Page To:"
|
180 |
-
msgstr ""
|
181 |
-
|
182 |
-
#: post-expirator.php:558
|
183 |
-
msgid ""
|
184 |
-
"Select whether the page should be deleted or changed to a draft at "
|
185 |
-
"expiration time."
|
186 |
-
msgstr ""
|
187 |
-
|
188 |
-
#: post-expirator.php:562
|
189 |
msgid "Date Format:"
|
190 |
msgstr ""
|
191 |
|
192 |
-
#: post-expirator.php:
|
193 |
msgid ""
|
194 |
"The default format to use when displaying the expiration date within a post "
|
195 |
"using the [postexpirator] shortcode or within the footer. For information "
|
@@ -197,11 +151,11 @@ msgid ""
|
|
197 |
"function.date.php\" target=\"_blank\">PHP Date Function</a>."
|
198 |
msgstr ""
|
199 |
|
200 |
-
#: post-expirator.php:
|
201 |
msgid "Time Format:"
|
202 |
msgstr ""
|
203 |
|
204 |
-
#: post-expirator.php:
|
205 |
msgid ""
|
206 |
"The default format to use when displaying the expiration time within a post "
|
207 |
"using the [postexpirator] shortcode or within the footer. For information "
|
@@ -209,245 +163,229 @@ msgid ""
|
|
209 |
"function.date.php\" target=\"_blank\">PHP Date Function</a>."
|
210 |
msgstr ""
|
211 |
|
212 |
-
#: post-expirator.php:
|
213 |
-
msgid "Cron Schedule:"
|
214 |
-
msgstr ""
|
215 |
-
|
216 |
-
#: post-expirator.php:588
|
217 |
-
msgid "By default set to \"postexpiratorminute\" which fires every minute."
|
218 |
-
msgstr ""
|
219 |
-
|
220 |
-
#: post-expirator.php:592
|
221 |
msgid "Default Date/Time Duration:"
|
222 |
msgstr ""
|
223 |
|
224 |
-
#: post-expirator.php:
|
225 |
msgid "None"
|
226 |
msgstr ""
|
227 |
|
228 |
-
#: post-expirator.php:
|
229 |
msgid "Custom"
|
230 |
msgstr ""
|
231 |
|
232 |
-
#: post-expirator.php:
|
233 |
msgid "Post/Page Publish Time"
|
234 |
msgstr ""
|
235 |
|
236 |
-
#: post-expirator.php:
|
237 |
msgid ""
|
238 |
"Set the default expiration date to be used when creating new posts and "
|
239 |
"pages. Defaults to none."
|
240 |
msgstr ""
|
241 |
|
242 |
-
#: post-expirator.php:
|
243 |
msgid ""
|
244 |
"Set the custom value to use for the default expiration date. For "
|
245 |
"information on formatting, see <a href=\"http://php.net/manual/en/function."
|
246 |
"strtotime.php\">PHP strtotime function</a>."
|
247 |
msgstr ""
|
248 |
|
249 |
-
#: post-expirator.php:
|
250 |
msgid "Category Expiration"
|
251 |
msgstr ""
|
252 |
|
253 |
-
#: post-expirator.php:
|
254 |
-
msgid "Enable Post Expiration to Category?"
|
255 |
-
msgstr ""
|
256 |
-
|
257 |
-
#: post-expirator.php:615 post-expirator.php:644
|
258 |
-
msgid "Enabled"
|
259 |
-
msgstr ""
|
260 |
-
|
261 |
-
#: post-expirator.php:616 post-expirator.php:645
|
262 |
-
msgid "Disabled"
|
263 |
-
msgstr ""
|
264 |
-
|
265 |
-
#: post-expirator.php:618
|
266 |
-
msgid "This will enable or disable the ability to expire a post to a category."
|
267 |
-
msgstr ""
|
268 |
-
|
269 |
-
#: post-expirator.php:622
|
270 |
msgid "Default Expiration Category"
|
271 |
msgstr ""
|
272 |
|
273 |
-
#: post-expirator.php:
|
274 |
msgid "Set's the default expiration category for the post."
|
275 |
msgstr ""
|
276 |
|
277 |
-
#: post-expirator.php:
|
278 |
msgid "Post Footer Display"
|
279 |
msgstr ""
|
280 |
|
281 |
-
#: post-expirator.php:
|
282 |
msgid ""
|
283 |
"Enabling this below will display the expiration date automatically at the "
|
284 |
"end of any post which is set to expire."
|
285 |
msgstr ""
|
286 |
|
287 |
-
#: post-expirator.php:
|
288 |
msgid "Show in post footer?"
|
289 |
msgstr ""
|
290 |
|
291 |
-
#: post-expirator.php:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
292 |
msgid ""
|
293 |
"This will enable or disable displaying the post expiration date in the post "
|
294 |
"footer."
|
295 |
msgstr ""
|
296 |
|
297 |
-
#: post-expirator.php:
|
298 |
msgid "Footer Contents:"
|
299 |
msgstr ""
|
300 |
|
301 |
-
#: post-expirator.php:
|
302 |
msgid ""
|
303 |
"Enter the text you would like to appear at the bottom of every post that "
|
304 |
"will expire. The following placeholders will be replaced with the post "
|
305 |
"expiration date in the following format:"
|
306 |
msgstr ""
|
307 |
|
308 |
-
#: post-expirator.php:
|
309 |
msgid "Footer Style:"
|
310 |
msgstr ""
|
311 |
|
312 |
-
#: post-expirator.php:
|
313 |
msgid "This post will expire on"
|
314 |
msgstr ""
|
315 |
|
316 |
-
#: post-expirator.php:
|
317 |
msgid "The inline css which will be used to style the footer text."
|
318 |
msgstr ""
|
319 |
|
320 |
-
#: post-expirator.php:
|
321 |
msgid "Save Changes"
|
322 |
msgstr ""
|
323 |
|
324 |
-
#: post-expirator.php:
|
325 |
-
msgid "
|
326 |
-
msgstr ""
|
327 |
-
|
328 |
-
#: post-expirator.php:727
|
329 |
-
msgid "Debugging Enabled"
|
330 |
msgstr ""
|
331 |
|
332 |
-
#: post-expirator.php:
|
333 |
-
msgid "
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
msgid "OK"
|
338 |
-
msgstr ""
|
339 |
-
|
340 |
-
#: post-expirator.php:737
|
341 |
-
msgid "RESET NEEDED"
|
342 |
-
msgstr ""
|
343 |
-
|
344 |
-
#: post-expirator.php:741
|
345 |
-
msgid "ERROR WITH FILTER"
|
346 |
msgstr ""
|
347 |
|
348 |
-
#: post-expirator.php:
|
349 |
-
msgid "
|
350 |
msgstr ""
|
351 |
|
352 |
-
#: post-expirator.php:
|
353 |
-
msgid "
|
354 |
msgstr ""
|
355 |
|
356 |
-
#: post-expirator.php:
|
357 |
-
msgid "
|
358 |
msgstr ""
|
359 |
|
360 |
-
#: post-expirator.php:
|
361 |
-
msgid "
|
362 |
msgstr ""
|
363 |
|
364 |
-
#: post-expirator.php:
|
365 |
-
msgid "
|
366 |
msgstr ""
|
367 |
|
368 |
-
#: post-expirator.php:
|
369 |
-
msgid "
|
370 |
msgstr ""
|
371 |
|
372 |
-
#: post-expirator.php:
|
373 |
-
msgid "
|
374 |
msgstr ""
|
375 |
|
376 |
-
#: post-expirator.php:
|
377 |
msgid "Advanced Diagnostics"
|
378 |
msgstr ""
|
379 |
|
380 |
-
#: post-expirator.php:
|
381 |
msgid "Post Expirator Debug Logging:"
|
382 |
msgstr ""
|
383 |
|
384 |
-
#: post-expirator.php:
|
385 |
msgid "Status: Enabled"
|
386 |
msgstr ""
|
387 |
|
388 |
-
#: post-expirator.php:
|
389 |
msgid "Disable Debugging"
|
390 |
msgstr ""
|
391 |
|
392 |
-
#: post-expirator.php:
|
393 |
msgid "Status: Disabled"
|
394 |
msgstr ""
|
395 |
|
396 |
-
#: post-expirator.php:
|
397 |
msgid "Enable Debugging"
|
398 |
msgstr ""
|
399 |
|
400 |
-
#: post-expirator.php:
|
401 |
msgid "Purge Debug Log:"
|
402 |
msgstr ""
|
403 |
|
404 |
-
#: post-expirator.php:
|
405 |
msgid "Purge Debug Log"
|
406 |
msgstr ""
|
407 |
|
408 |
-
#: post-expirator.php:
|
409 |
msgid "Current Cron Schedule:"
|
410 |
msgstr ""
|
411 |
|
412 |
-
#: post-expirator.php:
|
413 |
msgid ""
|
414 |
"The below table will show all currently scheduled cron events with the next "
|
415 |
"run time."
|
416 |
msgstr ""
|
417 |
|
418 |
-
#: post-expirator.php:
|
419 |
-
msgid ""
|
420 |
-
"There should be an event named expirationdate_delete_blogid (where the "
|
421 |
-
"blogid is replaced with the numeric id of the blog) with a schedule of %s."
|
422 |
-
msgstr ""
|
423 |
-
|
424 |
-
#: post-expirator.php:800
|
425 |
-
msgid ""
|
426 |
-
"There should be an event named expirationdate_delete with a schedule of %s."
|
427 |
-
msgstr ""
|
428 |
-
|
429 |
-
#: post-expirator.php:805
|
430 |
msgid "Date"
|
431 |
msgstr ""
|
432 |
|
433 |
-
#: post-expirator.php:
|
434 |
msgid "Event"
|
435 |
msgstr ""
|
436 |
|
437 |
-
#: post-expirator.php:
|
438 |
-
msgid "Schedule"
|
439 |
msgstr ""
|
440 |
|
441 |
-
#: post-expirator.php:
|
442 |
-
msgid "
|
443 |
msgstr ""
|
444 |
|
445 |
-
#: post-expirator.php:
|
446 |
msgid ""
|
447 |
"Below is a dump of the debugging table, this should be useful for "
|
448 |
"troubleshooting."
|
449 |
msgstr ""
|
450 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
451 |
#. Plugin URI of the plugin/theme
|
452 |
msgid "http://wordpress.org/extend/plugins/post-expirator/"
|
453 |
msgstr ""
|
1 |
+
# Copyright (C) 2013 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 2.0.0\n"
|
6 |
"Report-Msgid-Bugs-To: http://wordpress.org/tag/post-expirator\n"
|
7 |
+
"POT-Creation-Date: 2013-03-09 22:46:54+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: 2013-MO-DA HO:MI+ZONE\n"
|
12 |
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
13 |
"Language-Team: LANGUAGE <LL@li.org>\n"
|
14 |
|
15 |
+
#: post-expirator-debug.php:47
|
16 |
msgid "Debugging table is currently empty."
|
17 |
msgstr ""
|
18 |
|
19 |
+
#: post-expirator-debug.php:51
|
20 |
msgid "Timestamp"
|
21 |
msgstr ""
|
22 |
|
23 |
+
#: post-expirator-debug.php:52
|
24 |
msgid "Message"
|
25 |
msgstr ""
|
26 |
|
27 |
+
#: post-expirator.php:22
|
28 |
msgid "l F jS, Y"
|
29 |
msgstr ""
|
30 |
|
31 |
+
#: post-expirator.php:23
|
32 |
msgid "g:ia"
|
33 |
msgstr ""
|
34 |
|
35 |
+
#: post-expirator.php:24
|
36 |
msgid "Post expires at EXPIRATIONTIME on EXPIRATIONDATE"
|
37 |
msgstr ""
|
38 |
|
39 |
+
#: post-expirator.php:33
|
|
|
|
|
|
|
|
|
40 |
msgid "Settings"
|
41 |
msgstr ""
|
42 |
|
43 |
+
#: post-expirator.php:51
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
44 |
msgid "Expires"
|
45 |
msgstr ""
|
46 |
|
47 |
+
#: post-expirator.php:65
|
48 |
msgid "Never"
|
49 |
msgstr ""
|
50 |
|
51 |
+
#. #-#-#-#-# plugin.pot (Post Expirator 2.0.0) #-#-#-#-#
|
52 |
#. Plugin Name of the plugin/theme
|
53 |
+
#: post-expirator.php:77 post-expirator.php:79 post-expirator.php:562
|
54 |
msgid "Post Expirator"
|
55 |
msgstr ""
|
56 |
|
57 |
+
#: post-expirator.php:150
|
58 |
msgid "Enable Post Expiration"
|
59 |
msgstr ""
|
60 |
|
61 |
+
#: post-expirator.php:153
|
62 |
msgid "The published date/time will be used as the expiration value"
|
63 |
msgstr ""
|
64 |
|
65 |
+
#: post-expirator.php:156
|
66 |
msgid "Year"
|
67 |
msgstr ""
|
68 |
|
69 |
+
#: post-expirator.php:157
|
70 |
msgid "Month"
|
71 |
msgstr ""
|
72 |
|
73 |
+
#: post-expirator.php:158
|
74 |
msgid "Day"
|
75 |
msgstr ""
|
76 |
|
77 |
+
#: post-expirator.php:190
|
78 |
msgid "Hour"
|
79 |
msgstr ""
|
80 |
|
81 |
+
#: post-expirator.php:191
|
82 |
msgid "Minute"
|
83 |
msgstr ""
|
84 |
|
85 |
+
#: post-expirator.php:211
|
86 |
+
msgid "How to expire"
|
87 |
msgstr ""
|
88 |
|
89 |
+
#: post-expirator.php:222
|
90 |
+
msgid "Expiration Categories"
|
|
|
|
|
91 |
msgstr ""
|
92 |
|
93 |
+
#: post-expirator.php:529
|
94 |
msgid "General Settings"
|
95 |
msgstr ""
|
96 |
|
97 |
+
#: post-expirator.php:530 post-expirator.php:623
|
98 |
+
msgid "Defaults"
|
99 |
+
msgstr ""
|
100 |
+
|
101 |
+
#: post-expirator.php:531
|
102 |
msgid "Diagnostics"
|
103 |
msgstr ""
|
104 |
|
105 |
+
#: post-expirator.php:532
|
106 |
msgid "View Debug Logs"
|
107 |
msgstr ""
|
108 |
|
109 |
+
#: post-expirator.php:543 post-expirator.php:562
|
110 |
msgid "Post Expirator Options"
|
111 |
msgstr ""
|
112 |
|
113 |
+
#: post-expirator.php:581
|
114 |
msgid "Saved Options!"
|
115 |
msgstr ""
|
116 |
|
117 |
+
#: post-expirator.php:612
|
118 |
msgid ""
|
119 |
"The post expirator plugin sets a custom meta value, and then optionally "
|
120 |
"allows you to select if you want the post changed to a draft status or "
|
121 |
"deleted when it expires."
|
122 |
msgstr ""
|
123 |
|
124 |
+
#: post-expirator.php:615
|
125 |
msgid "Valid [postexpirator] attributes:"
|
126 |
msgstr ""
|
127 |
|
128 |
+
#: post-expirator.php:617
|
129 |
msgid "type - defaults to full - valid options are full,date,time"
|
130 |
msgstr ""
|
131 |
|
132 |
+
#: post-expirator.php:618
|
133 |
msgid ""
|
134 |
"dateformat - format set here will override the value set on the settings page"
|
135 |
msgstr ""
|
136 |
|
137 |
+
#: post-expirator.php:619
|
138 |
msgid ""
|
139 |
"timeformat - format set here will override the value set on the settings page"
|
140 |
msgstr ""
|
141 |
|
142 |
+
#: post-expirator.php:626
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
143 |
msgid "Date Format:"
|
144 |
msgstr ""
|
145 |
|
146 |
+
#: post-expirator.php:630
|
147 |
msgid ""
|
148 |
"The default format to use when displaying the expiration date within a post "
|
149 |
"using the [postexpirator] shortcode or within the footer. For information "
|
151 |
"function.date.php\" target=\"_blank\">PHP Date Function</a>."
|
152 |
msgstr ""
|
153 |
|
154 |
+
#: post-expirator.php:634
|
155 |
msgid "Time Format:"
|
156 |
msgstr ""
|
157 |
|
158 |
+
#: post-expirator.php:638
|
159 |
msgid ""
|
160 |
"The default format to use when displaying the expiration time within a post "
|
161 |
"using the [postexpirator] shortcode or within the footer. For information "
|
163 |
"function.date.php\" target=\"_blank\">PHP Date Function</a>."
|
164 |
msgstr ""
|
165 |
|
166 |
+
#: post-expirator.php:642
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
167 |
msgid "Default Date/Time Duration:"
|
168 |
msgstr ""
|
169 |
|
170 |
+
#: post-expirator.php:645
|
171 |
msgid "None"
|
172 |
msgstr ""
|
173 |
|
174 |
+
#: post-expirator.php:646
|
175 |
msgid "Custom"
|
176 |
msgstr ""
|
177 |
|
178 |
+
#: post-expirator.php:647
|
179 |
msgid "Post/Page Publish Time"
|
180 |
msgstr ""
|
181 |
|
182 |
+
#: post-expirator.php:650
|
183 |
msgid ""
|
184 |
"Set the default expiration date to be used when creating new posts and "
|
185 |
"pages. Defaults to none."
|
186 |
msgstr ""
|
187 |
|
188 |
+
#: post-expirator.php:655
|
189 |
msgid ""
|
190 |
"Set the custom value to use for the default expiration date. For "
|
191 |
"information on formatting, see <a href=\"http://php.net/manual/en/function."
|
192 |
"strtotime.php\">PHP strtotime function</a>."
|
193 |
msgstr ""
|
194 |
|
195 |
+
#: post-expirator.php:660
|
196 |
msgid "Category Expiration"
|
197 |
msgstr ""
|
198 |
|
199 |
+
#: post-expirator.php:663
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
200 |
msgid "Default Expiration Category"
|
201 |
msgstr ""
|
202 |
|
203 |
+
#: post-expirator.php:674
|
204 |
msgid "Set's the default expiration category for the post."
|
205 |
msgstr ""
|
206 |
|
207 |
+
#: post-expirator.php:679
|
208 |
msgid "Post Footer Display"
|
209 |
msgstr ""
|
210 |
|
211 |
+
#: post-expirator.php:680
|
212 |
msgid ""
|
213 |
"Enabling this below will display the expiration date automatically at the "
|
214 |
"end of any post which is set to expire."
|
215 |
msgstr ""
|
216 |
|
217 |
+
#: post-expirator.php:683
|
218 |
msgid "Show in post footer?"
|
219 |
msgstr ""
|
220 |
|
221 |
+
#: post-expirator.php:685 post-expirator.php:772
|
222 |
+
msgid "Enabled"
|
223 |
+
msgstr ""
|
224 |
+
|
225 |
+
#: post-expirator.php:686 post-expirator.php:773
|
226 |
+
msgid "Disabled"
|
227 |
+
msgstr ""
|
228 |
+
|
229 |
+
#: post-expirator.php:688
|
230 |
msgid ""
|
231 |
"This will enable or disable displaying the post expiration date in the post "
|
232 |
"footer."
|
233 |
msgstr ""
|
234 |
|
235 |
+
#: post-expirator.php:692
|
236 |
msgid "Footer Contents:"
|
237 |
msgstr ""
|
238 |
|
239 |
+
#: post-expirator.php:696
|
240 |
msgid ""
|
241 |
"Enter the text you would like to appear at the bottom of every post that "
|
242 |
"will expire. The following placeholders will be replaced with the post "
|
243 |
"expiration date in the following format:"
|
244 |
msgstr ""
|
245 |
|
246 |
+
#: post-expirator.php:705
|
247 |
msgid "Footer Style:"
|
248 |
msgstr ""
|
249 |
|
250 |
+
#: post-expirator.php:708
|
251 |
msgid "This post will expire on"
|
252 |
msgstr ""
|
253 |
|
254 |
+
#: post-expirator.php:710
|
255 |
msgid "The inline css which will be used to style the footer text."
|
256 |
msgstr ""
|
257 |
|
258 |
+
#: post-expirator.php:715 post-expirator.php:783
|
259 |
msgid "Save Changes"
|
260 |
msgstr ""
|
261 |
|
262 |
+
#: post-expirator.php:743
|
263 |
+
msgid "Default Expiration Values"
|
|
|
|
|
|
|
|
|
264 |
msgstr ""
|
265 |
|
266 |
+
#: post-expirator.php:745
|
267 |
+
msgid ""
|
268 |
+
"Use the values below to set the default actions/values to be used for each "
|
269 |
+
"for the corresponding post types. These values can all be overwridden when "
|
270 |
+
"creating/editing the post/page."
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
271 |
msgstr ""
|
272 |
|
273 |
+
#: post-expirator.php:761
|
274 |
+
msgid "How to expire:"
|
275 |
msgstr ""
|
276 |
|
277 |
+
#: post-expirator.php:766
|
278 |
+
msgid "Select the default expire action for the post type."
|
279 |
msgstr ""
|
280 |
|
281 |
+
#: post-expirator.php:770
|
282 |
+
msgid "Auto-Enable?"
|
283 |
msgstr ""
|
284 |
|
285 |
+
#: post-expirator.php:775
|
286 |
+
msgid "Select whether the post expirator is enabled for all new posts."
|
287 |
msgstr ""
|
288 |
|
289 |
+
#: post-expirator.php:792
|
290 |
+
msgid "Debugging Disabled"
|
291 |
msgstr ""
|
292 |
|
293 |
+
#: post-expirator.php:795
|
294 |
+
msgid "Debugging Enabled"
|
295 |
msgstr ""
|
296 |
|
297 |
+
#: post-expirator.php:800
|
298 |
+
msgid "Debugging Table Emptied"
|
299 |
msgstr ""
|
300 |
|
301 |
+
#: post-expirator.php:806
|
302 |
msgid "Advanced Diagnostics"
|
303 |
msgstr ""
|
304 |
|
305 |
+
#: post-expirator.php:809
|
306 |
msgid "Post Expirator Debug Logging:"
|
307 |
msgstr ""
|
308 |
|
309 |
+
#: post-expirator.php:813
|
310 |
msgid "Status: Enabled"
|
311 |
msgstr ""
|
312 |
|
313 |
+
#: post-expirator.php:814
|
314 |
msgid "Disable Debugging"
|
315 |
msgstr ""
|
316 |
|
317 |
+
#: post-expirator.php:816
|
318 |
msgid "Status: Disabled"
|
319 |
msgstr ""
|
320 |
|
321 |
+
#: post-expirator.php:817
|
322 |
msgid "Enable Debugging"
|
323 |
msgstr ""
|
324 |
|
325 |
+
#: post-expirator.php:825
|
326 |
msgid "Purge Debug Log:"
|
327 |
msgstr ""
|
328 |
|
329 |
+
#: post-expirator.php:827
|
330 |
msgid "Purge Debug Log"
|
331 |
msgstr ""
|
332 |
|
333 |
+
#: post-expirator.php:831
|
334 |
msgid "Current Cron Schedule:"
|
335 |
msgstr ""
|
336 |
|
337 |
+
#: post-expirator.php:833
|
338 |
msgid ""
|
339 |
"The below table will show all currently scheduled cron events with the next "
|
340 |
"run time."
|
341 |
msgstr ""
|
342 |
|
343 |
+
#: post-expirator.php:837
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
344 |
msgid "Date"
|
345 |
msgstr ""
|
346 |
|
347 |
+
#: post-expirator.php:838
|
348 |
msgid "Event"
|
349 |
msgstr ""
|
350 |
|
351 |
+
#: post-expirator.php:839
|
352 |
+
msgid "Arguments / Schedule"
|
353 |
msgstr ""
|
354 |
|
355 |
+
#: post-expirator.php:864
|
356 |
+
msgid "Single Event"
|
357 |
msgstr ""
|
358 |
|
359 |
+
#: post-expirator.php:885
|
360 |
msgid ""
|
361 |
"Below is a dump of the debugging table, this should be useful for "
|
362 |
"troubleshooting."
|
363 |
msgstr ""
|
364 |
|
365 |
+
#: post-expirator.php:1146
|
366 |
+
msgid "Draft"
|
367 |
+
msgstr ""
|
368 |
+
|
369 |
+
#: post-expirator.php:1147
|
370 |
+
msgid "Delete"
|
371 |
+
msgstr ""
|
372 |
+
|
373 |
+
#: post-expirator.php:1148
|
374 |
+
msgid "Private"
|
375 |
+
msgstr ""
|
376 |
+
|
377 |
+
#: post-expirator.php:1149
|
378 |
+
msgid "Category: Replace"
|
379 |
+
msgstr ""
|
380 |
+
|
381 |
+
#: post-expirator.php:1150
|
382 |
+
msgid "Category: Add"
|
383 |
+
msgstr ""
|
384 |
+
|
385 |
+
#: post-expirator.php:1151
|
386 |
+
msgid "Category: Remove"
|
387 |
+
msgstr ""
|
388 |
+
|
389 |
#. Plugin URI of the plugin/theme
|
390 |
msgid "http://wordpress.org/extend/plugins/post-expirator/"
|
391 |
msgstr ""
|
post-expirator-debug.php
CHANGED
@@ -28,7 +28,7 @@ class postExpiratorDebug {
|
|
28 |
|
29 |
public function removeDBTable() {
|
30 |
global $wpdb;
|
31 |
-
$wpdb->query(
|
32 |
}
|
33 |
|
34 |
public function save($data) {
|
@@ -37,13 +37,12 @@ class postExpiratorDebug {
|
|
37 |
global $current_blog;
|
38 |
$blog = $current_blog->blog_id;
|
39 |
} else $blog = 0;
|
40 |
-
$
|
41 |
-
$wpdb->query($wpdb->prepare($sql));
|
42 |
}
|
43 |
|
44 |
public function getTable() {
|
45 |
global $wpdb;
|
46 |
-
$results = $wpdb->get_results(
|
47 |
if (empty($results)) {
|
48 |
print '<p>'.__('Debugging table is currently empty.','post-expirator').'</p>';
|
49 |
return;
|
@@ -60,6 +59,6 @@ class postExpiratorDebug {
|
|
60 |
|
61 |
public function purge() {
|
62 |
global $wpdb;
|
63 |
-
$wpdb->query(
|
64 |
}
|
65 |
}
|
28 |
|
29 |
public function removeDBTable() {
|
30 |
global $wpdb;
|
31 |
+
$wpdb->query('DROP TABLE IF EXISTS '.$this->debug_table);
|
32 |
}
|
33 |
|
34 |
public function save($data) {
|
37 |
global $current_blog;
|
38 |
$blog = $current_blog->blog_id;
|
39 |
} else $blog = 0;
|
40 |
+
$wpdb->query($wpdb->prepare('INSERT INTO '.$this->debug_table.' (`timestamp`,`message`,`blog`) VALUES (FROM_UNIXTIME(%d),%s,%s)',time(),$data['message'],$blog));
|
|
|
41 |
}
|
42 |
|
43 |
public function getTable() {
|
44 |
global $wpdb;
|
45 |
+
$results = $wpdb->get_results("SELECT * FROM {$this->debug_table} ORDER BY `id` DESC");
|
46 |
if (empty($results)) {
|
47 |
print '<p>'.__('Debugging table is currently empty.','post-expirator').'</p>';
|
48 |
return;
|
59 |
|
60 |
public function purge() {
|
61 |
global $wpdb;
|
62 |
+
$wpdb->query("TRUNCATE TABLE {$this->debug_table}");
|
63 |
}
|
64 |
}
|
post-expirator.php
CHANGED
@@ -4,7 +4,7 @@ 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:
|
8 |
Author URI: http://postexpirator.tuxdocs.net/
|
9 |
Translation: Thierry (http://palijn.info)
|
10 |
Text Domain: post-expirator
|
@@ -17,46 +17,16 @@ function postExpirator_init() {
|
|
17 |
}
|
18 |
add_action('plugins_loaded', 'postExpirator_init');
|
19 |
|
20 |
-
|
21 |
// Default Values
|
22 |
-
define('POSTEXPIRATOR_VERSION','
|
23 |
define('POSTEXPIRATOR_DATEFORMAT',__('l F jS, Y','post-expirator'));
|
24 |
define('POSTEXPIRATOR_TIMEFORMAT',__('g:ia','post-expirator'));
|
25 |
define('POSTEXPIRATOR_FOOTERCONTENTS',__('Post expires at EXPIRATIONTIME on EXPIRATIONDATE','post-expirator'));
|
26 |
define('POSTEXPIRATOR_FOOTERSTYLE','font-style: italic;');
|
27 |
-
define('POSTEXPIRATOR_POSTSTATUS','Draft');
|
28 |
-
define('POSTEXPIRATOR_PAGESTATUS','Draft');
|
29 |
define('POSTEXPIRATOR_FOOTERDISPLAY','0');
|
30 |
-
define('
|
31 |
-
define('POSTEXPIRATOR_AUTOENABLE','0');
|
32 |
-
define('POSTEXPIRATOR_DEBUG','0');
|
33 |
-
define('POSTEXPIRATOR_CRONSCHEDULE','postexpiratorminute');
|
34 |
define('POSTEXPIRATOR_EXPIREDEFAULT','null');
|
35 |
|
36 |
-
// Detect WPMU/MultiSite
|
37 |
-
function postExpirator_is_wpmu() {
|
38 |
-
return is_multisite();
|
39 |
-
}
|
40 |
-
|
41 |
-
// Timezone Setup
|
42 |
-
function postExpiratorTimezoneSetup() {
|
43 |
-
if ( !$timezone_string = get_option( 'timezone_string' ) ) {
|
44 |
-
return false;
|
45 |
-
}
|
46 |
-
|
47 |
-
@date_default_timezone_set($timezone_string);
|
48 |
-
}
|
49 |
-
|
50 |
-
// Add cron interval of 60 seconds
|
51 |
-
function postExpiratorAddCronMinutes($array) {
|
52 |
-
$array['postexpiratorminute'] = array(
|
53 |
-
'interval' => 60,
|
54 |
-
'display' => __('Once a Minute','post-expirator')
|
55 |
-
);
|
56 |
-
return $array;
|
57 |
-
}
|
58 |
-
add_filter('cron_schedules','postExpiratorAddCronMinutes');
|
59 |
-
|
60 |
function postExpirator_plugin_action_links($links, $file) {
|
61 |
$this_plugin = basename(plugin_dir_url(__FILE__)) . '/post-expirator.php';
|
62 |
if($file == $this_plugin) {
|
@@ -66,99 +36,19 @@ function postExpirator_plugin_action_links($links, $file) {
|
|
66 |
}
|
67 |
add_filter('plugin_action_links', 'postExpirator_plugin_action_links', 10, 2);
|
68 |
|
69 |
-
|
70 |
/**
|
71 |
* Add admin notice hook if cron schedule needs to be reset
|
72 |
*/
|
73 |
function postExpirationAdminNotice() {
|
74 |
-
|
75 |
-
postExpiratorResetCronEvent();
|
76 |
-
echo "<div id='message' class='updated fade'><p>"; _e('Cron Events Reset!','post-expirator'); echo "</p></div>";
|
77 |
-
}
|
78 |
-
if (postExpiratorCronEventStatus() === false) {
|
79 |
-
echo '<div class="error fade post-expirator-adminnotice"><p><strong>';
|
80 |
-
_e('Post Expirator cron events need to be reset. ','post-expirator');
|
81 |
-
echo('<a href="'.admin_url('options-general.php?page=post-expirator.php&tab=diagnostics&reset=cron').'" style="color: blue;">');
|
82 |
-
_e('Click here to reset','post-expirator');
|
83 |
-
echo('</a></strong></p></div>');
|
84 |
-
}
|
85 |
}
|
86 |
add_action('admin_notices','postExpirationAdminNotice');
|
87 |
|
88 |
-
/**
|
89 |
-
* Function that does the actual deleting - called by wp_cron
|
90 |
-
*/
|
91 |
-
function expirationdate_delete_expired_posts() {
|
92 |
-
global $wpdb;
|
93 |
-
postExpiratorTimezoneSetup();
|
94 |
-
$time_delete = time();
|
95 |
-
$sql = '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 . '"';
|
96 |
-
$result = $wpdb->get_results($sql);
|
97 |
-
|
98 |
-
$debugEnabled = postExpiratorDebugEnabled();
|
99 |
-
if ($debugEnabled) {
|
100 |
-
// Load Debug Class
|
101 |
-
require_once(plugin_dir_path(__FILE__).'post-expirator-debug.php');
|
102 |
-
|
103 |
-
$debug = new postExpiratorDebug();
|
104 |
-
$startts = time();
|
105 |
-
$debug->save(array('timestamp' => $startts,'message' => 'START'));
|
106 |
-
$debug->save(array('timestamp' => $startts,'message' => 'SQL EXPIRE: '.$sql));
|
107 |
-
}
|
108 |
-
|
109 |
-
$processsql = 'select post_id from '.$wpdb->postmeta.' where meta_key = "_expiration-date-processed" AND meta_value = "1"';
|
110 |
-
if ($debugEnabled) $debug->save(array('timestamp' => time(),'message' => 'SQL PROCESSED: '.$processsql));
|
111 |
-
$processresult = $wpdb->get_col($processsql);
|
112 |
-
if ($debugEnabled) $debug->save(array('timestamp' => time(),'message' => 'PROCESSED POST IDS: '.print_r($processresult,true)));
|
113 |
-
|
114 |
-
if (!empty($result)) foreach ($result as $a) {
|
115 |
-
// Check to see if already proccessed
|
116 |
-
if (in_array($a->post_id,$processresult)) continue;
|
117 |
-
|
118 |
-
$post_result = $wpdb->get_var('select post_type from ' . $wpdb->posts .' where ID = '. $a->post_id);
|
119 |
-
if ($post_result == 'post') {
|
120 |
-
$expiredStatus = strtolower(get_option('expirationdateExpiredPostStatus',POSTEXPIRATOR_POSTSTATUS));
|
121 |
-
} else if ($post_result == 'page') {
|
122 |
-
$expiredStatus = strtolower(get_option('expirationdateExpiredPageStatus',POSTEXPIRATOR_PAGESTATUS));
|
123 |
-
} else {
|
124 |
-
$expiredStatus = 'draft';
|
125 |
-
}
|
126 |
-
|
127 |
-
// Check to see if expiration category is enabled and set - otherwise, proceed as normal
|
128 |
-
$catEnabled = get_option('expirationdateCategory');
|
129 |
-
$cat = get_post_meta($a->post_id,'_expiration-date-category');
|
130 |
-
if (($catEnabled === false || $catEnabled == 1) && (isset($cat) && !empty($cat[0]))) {
|
131 |
-
wp_update_post(array('ID' => $a->post_id, 'post_category' => $cat[0]));
|
132 |
-
if ($debugEnabled) $debug->save(array('timestamp' => time(),'message' => 'EXPIRE: ID:'.$a->post_id.' CATEGORY:'.print_r($cat[0],true)));
|
133 |
-
} else {
|
134 |
-
if ($expiredStatus == 'delete') {
|
135 |
-
wp_delete_post($a->post_id);
|
136 |
-
if ($debugEnabled) $debug->save(array('timestamp' => time(),'message' => 'EXPIRE: ID:'.$a->post_id.' DELETE'));
|
137 |
-
} else {
|
138 |
-
wp_update_post(array('ID' => $a->post_id, 'post_status' => 'draft'));
|
139 |
-
delete_post_meta($a->post_id, 'expiration-date');
|
140 |
-
update_post_meta($a->post_id, 'expiration-date', $a->meta_value);
|
141 |
-
if ($debugEnabled) $debug->save(array('timestamp' => time(),'message' => 'EXPIRE: ID:'.$a->post_id.' DRAFT'));
|
142 |
-
}
|
143 |
-
}
|
144 |
-
|
145 |
-
// Mark as Processed
|
146 |
-
update_post_meta($a->post_id, '_expiration-date-processed', 1);
|
147 |
-
if ($debugEnabled) $debug->save(array('timestamp' => time(),'message' => 'PROCESSED: ID:'.$a->post_id));
|
148 |
-
}
|
149 |
-
if ($debugEnabled) $debug->save(array('timestamp' => time(),'message' => 'END - DURATION: '.(time() - $startts)));
|
150 |
-
}
|
151 |
-
if (postExpirator_is_wpmu()) {
|
152 |
-
global $current_blog;
|
153 |
-
add_action ('expirationdate_delete_'.$current_blog->blog_id, 'expirationdate_delete_expired_posts');
|
154 |
-
} else
|
155 |
-
add_action ('expirationdate_delete', 'expirationdate_delete_expired_posts');
|
156 |
-
|
157 |
/**
|
158 |
* adds an 'Expires' column to the post display table.
|
159 |
*/
|
160 |
function expirationdate_add_column ($columns) {
|
161 |
-
$columns['expirationdate'] = __('Expires','post-expirator')
|
162 |
return $columns;
|
163 |
}
|
164 |
add_filter ('manage_posts_columns', 'expirationdate_add_column');
|
@@ -168,13 +58,11 @@ add_filter ('manage_pages_columns', 'expirationdate_add_column');
|
|
168 |
* fills the 'Expires' column of the post display table.
|
169 |
*/
|
170 |
function expirationdate_show_value ($column_name) {
|
171 |
-
global $
|
172 |
$id = $post->ID;
|
173 |
if ($column_name === 'expirationdate') {
|
174 |
-
|
175 |
-
$
|
176 |
-
$ed = $wpdb->get_var($query);
|
177 |
-
echo ($ed ? date('Y/m/d H:i',$ed) : __("Never",'post-expirator'));
|
178 |
}
|
179 |
}
|
180 |
add_action ('manage_posts_custom_column', 'expirationdate_show_value');
|
@@ -197,48 +85,64 @@ add_action ('add_meta_boxes','expirationdate_meta_custom');
|
|
197 |
*/
|
198 |
function expirationdate_meta_box($post) {
|
199 |
// Get default month
|
200 |
-
|
201 |
-
$
|
202 |
$default = '';
|
|
|
203 |
if (empty($expirationdatets)) {
|
|
|
|
|
204 |
$default = get_option('expirationdateDefaultDate',POSTEXPIRATOR_EXPIREDEFAULT);
|
205 |
if ($default == 'null') {
|
206 |
-
$defaultmonth
|
207 |
-
$defaultday
|
208 |
-
$defaulthour
|
209 |
-
$defaultyear
|
210 |
-
$defaultminute
|
211 |
|
212 |
} elseif ($default == 'custom') {
|
213 |
$custom = get_option('expirationdateDefaultDateCustom');
|
214 |
if ($custom === false) $ts = time();
|
215 |
-
else
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
222 |
}
|
223 |
|
224 |
$enabled = '';
|
225 |
$disabled = ' disabled="disabled"';
|
226 |
$categories = get_option('expirationdateCategoryDefaults');
|
227 |
|
228 |
-
|
229 |
-
|
|
|
|
|
|
|
230 |
$enabled = ' checked="checked"';
|
231 |
$disabled='';
|
232 |
}
|
233 |
} else {
|
234 |
-
$defaultmonth
|
235 |
-
$defaultday
|
236 |
-
$defaultyear
|
237 |
-
$defaulthour
|
238 |
-
$defaultminute
|
239 |
-
$enabled
|
240 |
-
$disabled
|
241 |
-
$
|
|
|
|
|
|
|
|
|
242 |
}
|
243 |
|
244 |
$rv = array();
|
@@ -271,11 +175,11 @@ function expirationdate_meta_box($post) {
|
|
271 |
$rv[] = '<select name="expirationdate_month" id="expirationdate_month"'.$disabled.'>';
|
272 |
|
273 |
for($i = 1; $i <= 12; $i++) {
|
274 |
-
if ($defaultmonth ==
|
275 |
$selected = ' selected="selected"';
|
276 |
else
|
277 |
$selected = '';
|
278 |
-
$rv[] = '<option value="'.
|
279 |
}
|
280 |
|
281 |
$rv[] = '</select>';
|
@@ -283,18 +187,18 @@ function expirationdate_meta_box($post) {
|
|
283 |
$rv[] = '<input type="text" id="expirationdate_day" name="expirationdate_day" value="'.$defaultday.'" size="2"'.$disabled.' />,';
|
284 |
$rv[] = '</td></tr><tr>';
|
285 |
$rv[] = '<th style="text-align: left;"></th>';
|
286 |
-
$rv[] = '<th style="text-align: left;">'.__('Hour','post-expirator').'('.
|
287 |
$rv[] = '<th style="text-align: left;">'.__('Minute','post-expirator').'</th>';
|
288 |
$rv[] = '</tr><tr>';
|
289 |
$rv[] = '<td>@</td><td>';
|
290 |
$rv[] = '<select name="expirationdate_hour" id="expirationdate_hour"'.$disabled.'>';
|
291 |
|
292 |
for($i = 1; $i <= 24; $i++) {
|
293 |
-
if ($defaulthour ==
|
294 |
$selected = ' selected="selected"';
|
295 |
else
|
296 |
$selected = '';
|
297 |
-
$rv[] = '<option value="'.
|
298 |
}
|
299 |
|
300 |
$rv[] = '</select></td><td>';
|
@@ -304,9 +208,17 @@ function expirationdate_meta_box($post) {
|
|
304 |
$rv[] = '<input type="hidden" name="expirationdate_formcheck" value="true" />';
|
305 |
echo implode("\n",$rv);
|
306 |
|
307 |
-
|
308 |
-
|
309 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
310 |
echo '<br/>'.__('Expiration Categories','post-expirator').':<br/>';
|
311 |
|
312 |
echo '<div class="wp-tab-panel" id="post-expirator-cat-list">';
|
@@ -316,8 +228,7 @@ function expirationdate_meta_box($post) {
|
|
316 |
wp_terms_checklist(0, array( 'taxonomy' => 'category', 'walker' => $walker, 'selected_cats' => $categories, 'checked_ontop' => false ) );
|
317 |
echo '</ul>';
|
318 |
echo '</div>';
|
319 |
-
|
320 |
-
echo '<p class="howto">'.__('Setting an expiration category will change the category at expiration time, and override the default post action','post-expirator').'.</p>';
|
321 |
}
|
322 |
echo '<div id="expirationdate_ajax_result"></div>';
|
323 |
}
|
@@ -336,12 +247,13 @@ function expirationdate_ajax_add_meta(expireenable) {
|
|
336 |
if (expire.checked == true) {
|
337 |
var enable = 'true';
|
338 |
if (document.getElementById('expirationdate_month')) {
|
339 |
-
|
340 |
document.getElementById('expirationdate_day').disabled = false;
|
341 |
document.getElementById('expirationdate_year').disabled = false;
|
342 |
document.getElementById('expirationdate_hour').disabled = false;
|
343 |
document.getElementById('expirationdate_minute').disabled = false;
|
344 |
}
|
|
|
345 |
var cats = document.getElementsByName('expirationdate_category[]');
|
346 |
var max = cats.length;
|
347 |
for (var i=0; i<max; i++) {
|
@@ -355,6 +267,7 @@ function expirationdate_ajax_add_meta(expireenable) {
|
|
355 |
document.getElementById('expirationdate_hour').disabled = true;
|
356 |
document.getElementById('expirationdate_minute').disabled = true;
|
357 |
}
|
|
|
358 |
var cats = document.getElementsByName('expirationdate_category[]');
|
359 |
var max = cats.length;
|
360 |
for (var i=0; i<max; i++) {
|
@@ -365,6 +278,17 @@ function expirationdate_ajax_add_meta(expireenable) {
|
|
365 |
|
366 |
return true;
|
367 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
368 |
function expirationdate_toggle_defaultdate(id) {
|
369 |
if (id.options[id.selectedIndex].value == 'custom') {
|
370 |
jQuery('#expired-custom-container').show();
|
@@ -383,7 +307,7 @@ add_action('admin_head', 'expirationdate_js_admin_header' );
|
|
383 |
* Get correct URL (HTTP or HTTPS)
|
384 |
*/
|
385 |
function expirationdate_get_blog_url() {
|
386 |
-
if (
|
387 |
echo network_home_url('/');
|
388 |
else
|
389 |
echo home_url('/');
|
@@ -393,47 +317,209 @@ function expirationdate_get_blog_url() {
|
|
393 |
* Called when post is saved - stores expiration-date meta value
|
394 |
*/
|
395 |
function expirationdate_update_post_meta($id) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
396 |
if (!isset($_POST['expirationdate_formcheck']))
|
397 |
-
return
|
398 |
|
399 |
-
$default = get_option('expirationdateDefaultDate',POSTEXPIRATOR_EXPIREDEFAULT);
|
400 |
-
if ($default == 'publish') {
|
401 |
-
$month = $_POST['mm'];
|
402 |
-
$day = $_POST['jj'];
|
403 |
-
$year = $_POST['aa'];
|
404 |
-
$hour = $_POST['hh'];
|
405 |
-
$minute = $_POST['mn'];
|
406 |
-
} else {
|
407 |
-
$month = $_POST['expirationdate_month'];
|
408 |
-
$day = $_POST['expirationdate_day'];
|
409 |
-
$year = $_POST['expirationdate_year'];
|
410 |
-
$hour = $_POST['expirationdate_hour'];
|
411 |
-
$minute = $_POST['expirationdate_minute'];
|
412 |
-
}
|
413 |
-
$category = isset($_POST['expirationdate_category']) ? $_POST['expirationdate_category'] : 0;
|
414 |
if (isset($_POST['enable-expirationdate'])) {
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
|
|
427 |
}
|
428 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
429 |
} else {
|
430 |
-
|
431 |
-
delete_post_meta($id, '_expiration-date-category');
|
432 |
-
delete_post_meta($id, '_expiration-date-processed');
|
433 |
}
|
434 |
}
|
435 |
add_action('save_post','expirationdate_update_post_meta');
|
436 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
437 |
/**
|
438 |
* Build the menu for the options page
|
439 |
*/
|
@@ -441,6 +527,7 @@ function postExpiratorMenuTabs($tab) {
|
|
441 |
echo '<p>';
|
442 |
if (empty($tab)) $tab = 'general';
|
443 |
echo '<a href="'.admin_url('options-general.php?page=post-expirator.php&tab=general').'"'.($tab == 'general' ? ' style="font-weight: bold; text-decoration:none;"' : '').'>'.__('General Settings','post-expirator').'</a> | ';
|
|
|
444 |
echo '<a href="'.admin_url('options-general.php?page=post-expirator.php&tab=diagnostics').'"'.($tab == 'diagnostics' ? ' style="font-weight: bold; text-decoration:none;"' : '').'>'.__('Diagnostics','post-expirator').'</a>';
|
445 |
echo ' | <a href="'.admin_url('options-general.php?page=post-expirator.php&tab=viewdebug').'"'.($tab == 'viewdebug' ? ' style="font-weight: bold; text-decoration:none;"' : '').'>'.__('View Debug Logs','post-expirator').'</a>';
|
446 |
echo '</p><hr/>';
|
@@ -458,6 +545,8 @@ function postExpiratorMenu() {
|
|
458 |
postExpiratorMenuTabs($tab);
|
459 |
if (empty($tab) || $tab == 'general') {
|
460 |
postExpiratorMenuGeneral();
|
|
|
|
|
461 |
} elseif ($tab == 'diagnostics') {
|
462 |
postExpiratorMenuDiagnostics();
|
463 |
} elseif ($tab == 'viewdebug') {
|
@@ -470,7 +559,7 @@ function postExpiratorMenu() {
|
|
470 |
* Hook's to add plugin page menu
|
471 |
*/
|
472 |
function postExpiratorPluginMenu() {
|
473 |
-
add_submenu_page('options-general.php',__('Post Expirator Options','post-expirator'),__('Post Expirator','post-expirator'),'
|
474 |
}
|
475 |
add_action('admin_menu', 'postExpiratorPluginMenu');
|
476 |
|
@@ -480,37 +569,25 @@ add_action('admin_menu', 'postExpiratorPluginMenu');
|
|
480 |
function postExpiratorMenuGeneral() {
|
481 |
|
482 |
if (isset($_POST['expirationdateSave']) && $_POST['expirationdateSave']) {
|
483 |
-
update_option('expirationdateExpiredPostStatus',$_POST['expired-post-status']);
|
484 |
-
update_option('expirationdateExpiredPageStatus',$_POST['expired-page-status']);
|
485 |
update_option('expirationdateDefaultDateFormat',$_POST['expired-default-date-format']);
|
486 |
update_option('expirationdateDefaultTimeFormat',$_POST['expired-default-time-format']);
|
487 |
update_option('expirationdateDisplayFooter',$_POST['expired-display-footer']);
|
488 |
update_option('expirationdateFooterContents',$_POST['expired-footer-contents']);
|
489 |
update_option('expirationdateFooterStyle',$_POST['expired-footer-style']);
|
490 |
-
update_option('
|
491 |
-
update_option('expirationdateCategoryDefaults',$_POST['expirationdate_category']);
|
492 |
-
update_option('expirationdateCronSchedule',$_POST['expired-default-cron-schedule']);
|
493 |
update_option('expirationdateDefaultDate',$_POST['expired-default-expiration-date']);
|
494 |
-
update_option('expirationdateAutoEnabled',$_POST['expired-auto-enable']);
|
495 |
if ($_POST['expired-custom-expiration-date']) update_option('expirationdateDefaultDateCustom',$_POST['expired-custom-expiration-date']);
|
496 |
-
postExpiratorResetCronEvent();
|
497 |
echo "<div id='message' class='updated fade'><p>";
|
498 |
_e('Saved Options!','post-expirator');
|
499 |
echo "</p></div>";
|
500 |
}
|
501 |
-
postExpiratorTimezoneSetup();
|
502 |
|
503 |
// Get Option
|
504 |
-
$expirationdateExpiredPostStatus = get_option('expirationdateExpiredPostStatus',POSTEXPIRATOR_POSTSTATUS);
|
505 |
-
$expirationdateExpiredPageStatus = get_option('expirationdateExpiredPageStatus',POSTEXPIRATOR_PAGESTATUS);
|
506 |
$expirationdateDefaultDateFormat = get_option('expirationdateDefaultDateFormat',POSTEXPIRATOR_DATEFORMAT);
|
507 |
$expirationdateDefaultTimeFormat = get_option('expirationdateDefaultTimeFormat',POSTEXPIRATOR_TIMEFORMAT);
|
508 |
-
$expiredcategory = get_option('expirationdateCategory',POSTEXPIRATOR_CATEGORY);
|
509 |
-
$expiredauto = get_option('expirationdateAutoEnabled',POSTEXPIRATOR_AUTOENABLE);
|
510 |
$expireddisplayfooter = get_option('expirationdateDisplayFooter',POSTEXPIRATOR_FOOTERDISPLAY);
|
511 |
$expirationdateFooterContents = get_option('expirationdateFooterContents',POSTEXPIRATOR_FOOTERCONTENTS);
|
512 |
$expirationdateFooterStyle = get_option('expirationdateFooterStyle',POSTEXPIRATOR_FOOTERSTYLE);
|
513 |
-
$expirationdateCronSchedule = get_option('expirationdateCronSchedule',POSTEXPIRATOR_CRONSCHEDULE);
|
514 |
$expirationdateDefaultDate = get_option('expirationdateDefaultDate',POSTEXPIRATOR_EXPIREDEFAULT);
|
515 |
$expirationdateDefaultDateCustom = get_option('expirationdateDefaultDateCustom');
|
516 |
|
@@ -530,13 +607,6 @@ function postExpiratorMenuGeneral() {
|
|
530 |
else if ($expiredcategory == 1)
|
531 |
$expiredcategoryenabled = 'checked="checked"';
|
532 |
|
533 |
-
$expiredautoenabled = '';
|
534 |
-
$expiredautodisabled = '';
|
535 |
-
if ($expiredauto == 0)
|
536 |
-
$expiredautodisabled = 'checked="checked"';
|
537 |
-
else if ($expiredauto == 1)
|
538 |
-
$expiredautoenabled= 'checked="checked"';
|
539 |
-
|
540 |
?>
|
541 |
<p>
|
542 |
<?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'); ?>
|
@@ -552,37 +622,6 @@ function postExpiratorMenuGeneral() {
|
|
552 |
<form method="post" id="expirationdate_save_options">
|
553 |
<h3><?php _e('Defaults','post-expirator'); ?></h3>
|
554 |
<table class="form-table">
|
555 |
-
<tr valign-"top">
|
556 |
-
<th scope="row"><label for="expired-post-status"><?php _e('Set Post To:','post-expirator'); ?></label></th>
|
557 |
-
<td>
|
558 |
-
<select name="expired-post-status" id="expired-post-status">
|
559 |
-
<option <?php if ($expirationdateExpiredPostStatus == 'Draft'){ echo 'selected="selected"';} ?> value="Draft"><?php _e('Draft','post-expirator');?></option>
|
560 |
-
<option <?php if ($expirationdateExpiredPostStatus == 'Delete'){ echo 'selected="selected"';} ?> value="Delete"><?php _e('Delete','post-expirator');?></option>
|
561 |
-
</select>
|
562 |
-
<br/>
|
563 |
-
<?php _e('Select whether the post should be deleted or changed to a draft at expiration time.','post-expirator');?>
|
564 |
-
</td>
|
565 |
-
</tr>
|
566 |
-
<tr valign-"top">
|
567 |
-
<th scope="row"><label for="expired-page-status"><?php _e('Set Page To:','post-expirator');?></label></th>
|
568 |
-
<td>
|
569 |
-
<select name="expired-page-status" id="expired-page-status">
|
570 |
-
<option<?php if ($expirationdateExpiredPageStatus == 'Draft'){ echo ' selected="selected"';}?> value="Draft"><?php _e('Draft','post-expirator');?></option>
|
571 |
-
<option<?php if ($expirationdateExpiredPageStatus == 'Delete'){ echo ' selected="selected"';}?> value="Delete"><?php _e('Delete','post-expirator');?></option>
|
572 |
-
</select>
|
573 |
-
<br/>
|
574 |
-
<?php _e('Select whether the page should be deleted or changed to a draft at expiration time.','post-expirator');?>
|
575 |
-
</td>
|
576 |
-
</tr>
|
577 |
-
<tr valign-"top">
|
578 |
-
<th scope="row"><label for="expired-auto-enable"><?php _e('Auto-Enable Post Expirator:','post-expirator');?></label></th>
|
579 |
-
<td>
|
580 |
-
<input type="radio" name="expired-auto-enable" id="expired-auto-enable-true" value="1" <?php echo $expiredautoenabled ?>/> <label for="expired-auto-enable-true"><?php _e('Enabled','post-expirator');?></label>
|
581 |
-
<input type="radio" name="expired-auto-enable" id="expired-auto-enable-false" value="0" <?php echo $expiredautodisabled ?>/> <label for="expired-auto-enable-false"><?php _e('Disabled','post-expirator');?></label>
|
582 |
-
<br/>
|
583 |
-
<?php _e('Select whether the post expirator is enabled for all new posts.','post-expirator');?>
|
584 |
-
</td>
|
585 |
-
</tr>
|
586 |
<tr valign-"top">
|
587 |
<th scope="row"><label for="expired-default-date-format"><?php _e('Date Format:','post-expirator');?></label></th>
|
588 |
<td>
|
@@ -599,20 +638,6 @@ function postExpiratorMenuGeneral() {
|
|
599 |
<?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'); ?>
|
600 |
</td>
|
601 |
</tr>
|
602 |
-
<tr valign-"top">
|
603 |
-
<th scope="row"><label for="expired-default-cron-schedule"><?php _e('Cron Schedule:','post-expirator');?></label></th>
|
604 |
-
<td>
|
605 |
-
<select name="expired-default-cron-schedule" id="expired-default-cron-schedule">
|
606 |
-
<?php $schedules = wp_get_schedules();
|
607 |
-
foreach ($schedules as $key=>$value) {
|
608 |
-
$selected = ($key == $expirationdateCronSchedule) ? ' selected="selected"' : '';
|
609 |
-
echo '<option value="'.$key.'"'.$selected.'>'.$value['display'].' ('.$key.') </option>';
|
610 |
-
} ?>
|
611 |
-
</select>
|
612 |
-
<br/>
|
613 |
-
<?php _e('By default set to "postexpiratorminute" which fires every minute.','post-expirator'); ?>
|
614 |
-
</td>
|
615 |
-
</tr>
|
616 |
<tr valign-"top">
|
617 |
<th scope="row"><label for="expired-default-expiration-date"><?php _e('Default Date/Time Duration:','post-expirator');?></label></th>
|
618 |
<td>
|
@@ -634,15 +659,6 @@ function postExpiratorMenuGeneral() {
|
|
634 |
</table>
|
635 |
<h3><?php _e('Category Expiration','post-expirator');?></h3>
|
636 |
<table class="form-table">
|
637 |
-
<tr valign-"top">
|
638 |
-
<th scope="row"><?php _e('Enable Post Expiration to Category?','post-expirator');?></th>
|
639 |
-
<td>
|
640 |
-
<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>
|
641 |
-
<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>
|
642 |
-
<br/>
|
643 |
-
<?php _e('This will enable or disable the ability to expire a post to a category.','post-expirator');?>
|
644 |
-
</td>
|
645 |
-
</tr>
|
646 |
<tr valign-"top">
|
647 |
<th scope="row"><?php _e('Default Expiration Category','post-expirator');?>:</th>
|
648 |
<td>
|
@@ -702,45 +718,72 @@ function postExpiratorMenuGeneral() {
|
|
702 |
<?php
|
703 |
}
|
704 |
|
705 |
-
function
|
706 |
-
$
|
707 |
-
|
708 |
-
|
709 |
-
global $current_blog;
|
710 |
-
$name = 'expirationdate_delete_'.$current_blog->blog_id;
|
711 |
-
} else {
|
712 |
-
$name = 'expirationdate_delete';
|
713 |
-
}
|
714 |
-
|
715 |
-
$expirationdateCronSchedule = get_option('expirationdateCronSchedule',POSTEXPIRATOR_CRONSCHEDULE);
|
716 |
-
if (wp_get_schedule($name) != $expirationdateCronSchedule) return false;
|
717 |
|
718 |
-
|
719 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
720 |
|
721 |
-
|
722 |
-
|
723 |
-
|
724 |
-
if ($schedules['postexpiratorminute']['interval'] == '60')
|
725 |
-
return true;
|
726 |
}
|
727 |
-
return false;
|
728 |
-
}
|
729 |
-
|
730 |
-
/**
|
731 |
-
* Reset all cron events for Post Expirator Plugin
|
732 |
-
*/
|
733 |
-
function postExpiratorResetCronEvent() {
|
734 |
-
wp_clear_scheduled_hook('expirationdate_delete');
|
735 |
-
wp_clear_scheduled_hook('expirationdate_delete_');
|
736 |
|
737 |
-
|
738 |
-
|
739 |
-
|
740 |
-
|
741 |
-
|
742 |
-
|
743 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
744 |
}
|
745 |
|
746 |
function postExpiratorMenuDiagnostics() {
|
@@ -757,46 +800,16 @@ function postExpiratorMenuDiagnostics() {
|
|
757 |
echo "<div id='message' class='updated fade'><p>"; _e('Debugging Table Emptied','post-expirator'); echo "</p></div>";
|
758 |
}
|
759 |
|
760 |
-
$
|
761 |
-
if ($status) $cronstatus = '<span style="color:green">'.__('OK','post-expirator').'</span>';
|
762 |
-
else $cronstatus = '<span style="color:red">'.__('RESET NEEDED','post-expirator').'</span>';
|
763 |
-
|
764 |
-
$schedule = postExpiratorCronScheduleStatus();
|
765 |
-
if ($schedule) $cronschedulestatus = '<span style="color:green">'.__('OK','post-expirator').'</span>';
|
766 |
-
else $cronschedulestatus = '<span style="color:red">'.__('ERROR WITH FILTER','post-expirator').'</span>';
|
767 |
-
|
768 |
-
$debug = postExpiratorDebugEnabled();
|
769 |
-
|
770 |
?>
|
771 |
<form method="post" id="postExpiratorMenuUpgrade">
|
772 |
-
<h3><?php _e('Cron Settings','post-expirator');?></h3>
|
773 |
-
<table class="form-table">
|
774 |
-
<tr valign-"top">
|
775 |
-
<th scope="row"><label for="reset-cron-event"><?php _e('Reset Cron Event:','post-expirator');?></label></th>
|
776 |
-
<td>
|
777 |
-
<input type="submit" class="button" name="reset-cron-event" id="reset-cron-event" value="<?php _e('Reset','post-expirator');?>" />
|
778 |
-
<?php _e('Status:','post-expirator');?> <?php echo $cronstatus; ?>
|
779 |
-
<br/>
|
780 |
-
<?php _e('Resets the cron event and removes any old or stray entries.','post-expirator');?>
|
781 |
-
</td>
|
782 |
-
</tr>
|
783 |
-
<tr valign-"top">
|
784 |
-
<th scope="row"><label for="reset-cron-schedule"><?php _e('Reset Cron Schedule:','post-expirator');?></label></th>
|
785 |
-
<td>
|
786 |
-
<?php _e('Status:','post-expirator');?> <?php echo $cronschedulestatus; ?>
|
787 |
-
<br/>
|
788 |
-
<?php _e('Displays the cron minute schedule status for post expirator.','post-expirator');?>
|
789 |
-
</td>
|
790 |
-
</tr>
|
791 |
-
</table>
|
792 |
-
|
793 |
<h3><?php _e('Advanced Diagnostics','post-expirator');?></h3>
|
794 |
<table class="form-table">
|
795 |
<tr valign-"top">
|
796 |
<th scope="row"><label for="postexpirator-log"><?php _e('Post Expirator Debug Logging:','post-expirator');?></label></th>
|
797 |
<td>
|
798 |
<?php
|
799 |
-
if (
|
800 |
echo __('Status: Enabled','post-expirator').'<br/>';
|
801 |
echo '<input type="submit" class="button" name="debugging-disable" id="debugging-disable" value="'.__('Disable Debugging','post-expirator').'" />';
|
802 |
} else {
|
@@ -818,19 +831,12 @@ function postExpiratorMenuDiagnostics() {
|
|
818 |
<th scope="row"><label for="cron-schedule"><?php _e('Current Cron Schedule:','post-expirator');?></label></th>
|
819 |
<td>
|
820 |
<?php _e('The below table will show all currently scheduled cron events with the next run time.','post-expirator');?><br/>
|
821 |
-
<?php
|
822 |
-
if (postExpirator_is_wpmu())
|
823 |
-
printf(__('There should be an event named expirationdate_delete_blogid (where the blogid is replaced with the numeric id of the blog) with a schedule of %s.','post-expirator'),'<em>'.get_option('expirationdateCronSchedule',POSTEXPIRATOR_CRONSCHEDULE).'</em>');
|
824 |
-
else
|
825 |
-
printf(__('There should be an event named expirationdate_delete with a schedule of %s.','post-expirator'),'<em>'.get_option('expirationdateCronSchedule',POSTEXPIRATOR_CRONSCHEDULE.'</em>'));
|
826 |
-
?><br/>
|
827 |
|
828 |
<table>
|
829 |
<tr>
|
830 |
-
<th><?php _e('Date','post-expirator');?></th>
|
831 |
-
<th><?php _e('Event','post-expirator');?></th>
|
832 |
-
<th><?php _e('Schedule','post-expirator');?></th>
|
833 |
-
<th><?php _e('Interval (seconds)','post-expirator');?></th>
|
834 |
</tr>
|
835 |
<?php
|
836 |
$cron = _get_cron_array();
|
@@ -840,8 +846,28 @@ function postExpiratorMenuDiagnostics() {
|
|
840 |
print '<td>'.date_i18n('r',$key).'</td>';
|
841 |
print '<td>'.$eventkey.'</td>';
|
842 |
$arrkey = array_keys($eventvalue);
|
843 |
-
print '<td>'
|
844 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
845 |
print '</tr>';
|
846 |
}
|
847 |
}
|
@@ -865,14 +891,14 @@ function postExpiratorMenuViewdebug() {
|
|
865 |
function postexpirator_shortcode($atts) {
|
866 |
global $post;
|
867 |
|
868 |
-
$expirationdatets = get_post_meta($post->ID,'
|
869 |
if (empty($expirationdatets))
|
870 |
return false;
|
871 |
|
872 |
extract(shortcode_atts(array(
|
873 |
'dateformat' => get_option('expirationdateDefaultDateFormat',POSTEXPIRATOR_DATEFORMAT),
|
874 |
'timeformat' => get_option('expirationdateDefaultTimeFormat',POSTEXPIRATOR_TIMEFORMAT),
|
875 |
-
'type' => full,
|
876 |
'tz' => date('T')
|
877 |
), $atts));
|
878 |
|
@@ -893,8 +919,7 @@ function postexpirator_shortcode($atts) {
|
|
893 |
else if ($type == 'time')
|
894 |
$format = $timeformat;
|
895 |
|
896 |
-
|
897 |
-
return date("$format",$expirationdatets);
|
898 |
}
|
899 |
add_shortcode('postexpirator', 'postexpirator_shortcode');
|
900 |
|
@@ -906,7 +931,7 @@ function postexpirator_add_footer($text) {
|
|
906 |
if ($displayFooter === false || $displayFooter == 0)
|
907 |
return $text;
|
908 |
|
909 |
-
$expirationdatets = get_post_meta($post->ID,'
|
910 |
if (!is_numeric($expirationdatets))
|
911 |
return $text;
|
912 |
|
@@ -915,16 +940,15 @@ function postexpirator_add_footer($text) {
|
|
915 |
$expirationdateFooterContents = get_option('expirationdateFooterContents',POSTEXPIRATOR_FOOTERCONTENTS);
|
916 |
$expirationdateFooterStyle = get_option('expirationdateFooterStyle',POSTEXPIRATOR_FOOTERSTYLE);
|
917 |
|
918 |
-
postExpiratorTimezoneSetup();
|
919 |
$search = array(
|
920 |
'EXPIRATIONFULL',
|
921 |
'EXPIRATIONDATE',
|
922 |
'EXPIRATIONTIME'
|
923 |
);
|
924 |
$replace = array(
|
925 |
-
date_i18n("$dateformat $timeformat"
|
926 |
-
date_i18n(
|
927 |
-
date_i18n(
|
928 |
);
|
929 |
|
930 |
$add_to_footer = '<p style="'.$expirationdateFooterStyle.'">'.str_replace($search,$replace,$expirationdateFooterContents).'</p>';
|
@@ -935,12 +959,19 @@ add_action('the_content','postexpirator_add_footer',0);
|
|
935 |
/**
|
936 |
* Check for Debug
|
937 |
*/
|
938 |
-
function
|
939 |
$debug = get_option('expirationdateDebug');
|
940 |
-
if ($debug == 1)
|
941 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
942 |
}
|
943 |
|
|
|
944 |
/**
|
945 |
* Add Stylesheet
|
946 |
*/
|
@@ -959,21 +990,60 @@ add_action('admin_init','postexpirator_css');
|
|
959 |
* Post Expirator Activation/Upgrade
|
960 |
*/
|
961 |
function postexpirator_upgrade() {
|
|
|
962 |
// Check for current version, if not exists, run activation
|
963 |
$version = get_option('postexpiratorVersion');
|
964 |
if ($version === false) { //not installed, run default activation
|
965 |
postexpirator_activate();
|
966 |
update_option('postexpiratorVersion',POSTEXPIRATOR_VERSION);
|
967 |
-
}
|
968 |
-
|
969 |
-
|
970 |
-
|
971 |
-
|
972 |
-
|
973 |
-
|
974 |
-
|
975 |
-
|
976 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
977 |
}
|
978 |
}
|
979 |
}
|
@@ -983,22 +1053,13 @@ add_action('admin_init','postexpirator_upgrade');
|
|
983 |
* Called at plugin activation
|
984 |
*/
|
985 |
function postexpirator_activate () {
|
986 |
-
if (get_option('expirationdateExpiredPostStatus') === false) update_option('expirationdateExpiredPostStatus',POSTEXPIRATOR_POSTSTATUS);
|
987 |
-
if (get_option('expirationdateExpiredPageStatus') === false) update_option('expirationdateExpiredPageStatus',POSTEXPIRATOR_PAGESTATUS);
|
988 |
if (get_option('expirationdateDefaultDateFormat') === false) update_option('expirationdateDefaultDateFormat',POSTEXPIRATOR_DATEFORMAT);
|
989 |
if (get_option('expirationdateDefaultTimeFormat') === false) update_option('expirationdateDefaultTimeFormat',POSTEXPIRATOR_TIMEFORMAT);
|
990 |
if (get_option('expirationdateFooterContents') === false) update_option('expirationdateFooterContents',POSTEXPIRATOR_FOOTERCONTENTS);
|
991 |
if (get_option('expirationdateFooterStyle') === false) update_option('expirationdateFooterStyle',POSTEXPIRATOR_FOOTERSTYLE);
|
992 |
if (get_option('expirationdateDisplayFooter') === false) update_option('expirationdateDisplayFooter',POSTEXPIRATOR_FOOTERDISPLAY);
|
993 |
-
if (get_option('
|
994 |
-
if (get_option('expirationdateDebug') === false) update_option('expirationdateDebug',POSTEXPIRATOR_DEBUG);
|
995 |
if (get_option('expirationdateDefaultDate') === false) update_option('expirationdateDefaultDate',POSTEXPIRATOR_EXPIREDEFAULT);
|
996 |
-
|
997 |
-
if (postExpirator_is_wpmu()) {
|
998 |
-
global $current_blog;
|
999 |
-
wp_schedule_event(current_time('timestamp'), get_option('expirationdateCronSchedule',POSTEXPIRATOR_CRONSCHEDULE), 'expirationdate_delete_'.$current_blog->blog_id);
|
1000 |
-
} else
|
1001 |
-
wp_schedule_event(current_time('timestamp'), get_option('expirationdateCronSchedule',POSTEXPIRATOR_CRONSCHEDULE), 'expirationdate_delete');
|
1002 |
}
|
1003 |
|
1004 |
/**
|
@@ -1021,7 +1082,10 @@ function expirationdate_deactivate () {
|
|
1021 |
delete_option('expirationdateDefaultDate');
|
1022 |
delete_option('expirationdateDefaultDateCustom');
|
1023 |
delete_option('expirationdateAutoEnabled');
|
1024 |
-
|
|
|
|
|
|
|
1025 |
wp_clear_scheduled_hook('expirationdate_delete_'.$current_blog->blog_id);
|
1026 |
else
|
1027 |
wp_clear_scheduled_hook('expirationdate_delete');
|
@@ -1058,11 +1122,50 @@ class Walker_PostExpirator_Category_Checklist extends Walker {
|
|
1058 |
|
1059 |
$name = 'expirationdate_category';
|
1060 |
|
1061 |
-
$class = in_array( $category->term_id, $popular_cats ) ? ' class="
|
1062 |
-
$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>';
|
1063 |
}
|
1064 |
|
1065 |
function end_el(&$output, $category, $depth, $args) {
|
1066 |
$output .= "</li>\n";
|
1067 |
}
|
1068 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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: 2.0.0
|
8 |
Author URI: http://postexpirator.tuxdocs.net/
|
9 |
Translation: Thierry (http://palijn.info)
|
10 |
Text Domain: post-expirator
|
17 |
}
|
18 |
add_action('plugins_loaded', 'postExpirator_init');
|
19 |
|
|
|
20 |
// Default Values
|
21 |
+
define('POSTEXPIRATOR_VERSION','2.0.0-rc1');
|
22 |
define('POSTEXPIRATOR_DATEFORMAT',__('l F jS, Y','post-expirator'));
|
23 |
define('POSTEXPIRATOR_TIMEFORMAT',__('g:ia','post-expirator'));
|
24 |
define('POSTEXPIRATOR_FOOTERCONTENTS',__('Post expires at EXPIRATIONTIME on EXPIRATIONDATE','post-expirator'));
|
25 |
define('POSTEXPIRATOR_FOOTERSTYLE','font-style: italic;');
|
|
|
|
|
26 |
define('POSTEXPIRATOR_FOOTERDISPLAY','0');
|
27 |
+
define('POSTEXPIRATOR_DEBUGDEFAULT','0');
|
|
|
|
|
|
|
28 |
define('POSTEXPIRATOR_EXPIREDEFAULT','null');
|
29 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
function postExpirator_plugin_action_links($links, $file) {
|
31 |
$this_plugin = basename(plugin_dir_url(__FILE__)) . '/post-expirator.php';
|
32 |
if($file == $this_plugin) {
|
36 |
}
|
37 |
add_filter('plugin_action_links', 'postExpirator_plugin_action_links', 10, 2);
|
38 |
|
|
|
39 |
/**
|
40 |
* Add admin notice hook if cron schedule needs to be reset
|
41 |
*/
|
42 |
function postExpirationAdminNotice() {
|
43 |
+
// Currently not used
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
44 |
}
|
45 |
add_action('admin_notices','postExpirationAdminNotice');
|
46 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
/**
|
48 |
* adds an 'Expires' column to the post display table.
|
49 |
*/
|
50 |
function expirationdate_add_column ($columns) {
|
51 |
+
$columns['expirationdate'] = __('Expires','post-expirator');
|
52 |
return $columns;
|
53 |
}
|
54 |
add_filter ('manage_posts_columns', 'expirationdate_add_column');
|
58 |
* fills the 'Expires' column of the post display table.
|
59 |
*/
|
60 |
function expirationdate_show_value ($column_name) {
|
61 |
+
global $post;
|
62 |
$id = $post->ID;
|
63 |
if ($column_name === 'expirationdate') {
|
64 |
+
$ed = get_post_meta($id,'_expiration-date',true);
|
65 |
+
echo ($ed ? postexpirator_get_date_from_gmt(date('Y-m-d H:i:s',$ed),get_option('date_format').' '.get_option('time_format')) : __("Never",'post-expirator'));
|
|
|
|
|
66 |
}
|
67 |
}
|
68 |
add_action ('manage_posts_custom_column', 'expirationdate_show_value');
|
85 |
*/
|
86 |
function expirationdate_meta_box($post) {
|
87 |
// Get default month
|
88 |
+
$expirationdatets = get_post_meta($post->ID,'_expiration-date',true);
|
89 |
+
$firstsave = get_post_meta($post->ID,'_expiration-date-status',true);
|
90 |
$default = '';
|
91 |
+
$expireType = '';
|
92 |
if (empty($expirationdatets)) {
|
93 |
+
$defaults = get_option('expirationdateDefaults'.ucfirst($post->post_type));
|
94 |
+
|
95 |
$default = get_option('expirationdateDefaultDate',POSTEXPIRATOR_EXPIREDEFAULT);
|
96 |
if ($default == 'null') {
|
97 |
+
$defaultmonth = date_i18n('m');
|
98 |
+
$defaultday = date_i18n('d');
|
99 |
+
$defaulthour = date_i18n('H');
|
100 |
+
$defaultyear = date_i18n('Y');
|
101 |
+
$defaultminute = date_i18n('i');
|
102 |
|
103 |
} elseif ($default == 'custom') {
|
104 |
$custom = get_option('expirationdateDefaultDateCustom');
|
105 |
if ($custom === false) $ts = time();
|
106 |
+
else {
|
107 |
+
$tz = get_option('timezone_string');
|
108 |
+
if ( $tz ) date_default_timezone_set( $tz );
|
109 |
+
|
110 |
+
$ts = gmmktime() + (strtotime($custom) - time());
|
111 |
+
|
112 |
+
if ( $tz ) date_default_timezone_set('UTC');
|
113 |
+
}
|
114 |
+
$defaultmonth = postexpirator_get_date_from_gmt(date_i18n('Y-m-d H:i:s',$ts),'m');
|
115 |
+
$defaultday = postexpirator_get_date_from_gmt(date_i18n('Y-m-d H:i:s',$ts),'d');
|
116 |
+
$defaultyear = postexpirator_get_date_from_gmt(date_i18n('Y-m-d H:i:s',$ts),'Y');;
|
117 |
+
$defaulthour = postexpirator_get_date_from_gmt(date_i18n('Y-m-d H:i:s',$ts),'H');
|
118 |
+
$defaultminute = postexpirator_get_date_from_gmt(date_i18n('Y-m-d H:i:s',$ts),'i');
|
119 |
}
|
120 |
|
121 |
$enabled = '';
|
122 |
$disabled = ' disabled="disabled"';
|
123 |
$categories = get_option('expirationdateCategoryDefaults');
|
124 |
|
125 |
+
if (isset($defaults['expireType'])) {
|
126 |
+
$expireType = $defaults['expireType'];
|
127 |
+
}
|
128 |
+
|
129 |
+
if (isset($defaults['autoEnable']) && ($firstsave !== 'saved') && ($defaults['autoEnable'] === true || $defaults['autoEnable'] == 1)) {
|
130 |
$enabled = ' checked="checked"';
|
131 |
$disabled='';
|
132 |
}
|
133 |
} else {
|
134 |
+
$defaultmonth = postexpirator_get_date_from_gmt(date_i18n('Y-m-d H:i:s',$expirationdatets),'m');
|
135 |
+
$defaultday = postexpirator_get_date_from_gmt(date_i18n('Y-m-d H:i:s',$expirationdatets),'d');
|
136 |
+
$defaultyear = postexpirator_get_date_from_gmt(date_i18n('Y-m-d H:i:s',$expirationdatets),'Y');
|
137 |
+
$defaulthour = postexpirator_get_date_from_gmt(date_i18n('Y-m-d H:i:s',$expirationdatets),'H');
|
138 |
+
$defaultminute = postexpirator_get_date_from_gmt(date_i18n('Y-m-d H:i:s',$expirationdatets),'i');
|
139 |
+
$enabled = ' checked="checked"';
|
140 |
+
$disabled = '';
|
141 |
+
$opts = get_post_meta($post->ID,'_expiration-date-options',true);
|
142 |
+
if (isset($opts['expireType'])) {
|
143 |
+
$expireType = $opts['expireType'];
|
144 |
+
}
|
145 |
+
$categories = isset($opts['category']) ? $opts['category'] : false;
|
146 |
}
|
147 |
|
148 |
$rv = array();
|
175 |
$rv[] = '<select name="expirationdate_month" id="expirationdate_month"'.$disabled.'>';
|
176 |
|
177 |
for($i = 1; $i <= 12; $i++) {
|
178 |
+
if ($defaultmonth == date_i18n('m',mktime(0, 0, 0, $i, 1, date_i18n('Y'))))
|
179 |
$selected = ' selected="selected"';
|
180 |
else
|
181 |
$selected = '';
|
182 |
+
$rv[] = '<option value="'.date_i18n('m',mktime(0, 0, 0, $i, 1, date_i18n('Y'))).'"'.$selected.'>'.date_i18n('F',mktime(0, 0, 0, $i, 1, date_i18n('Y'))).'</option>';
|
183 |
}
|
184 |
|
185 |
$rv[] = '</select>';
|
187 |
$rv[] = '<input type="text" id="expirationdate_day" name="expirationdate_day" value="'.$defaultday.'" size="2"'.$disabled.' />,';
|
188 |
$rv[] = '</td></tr><tr>';
|
189 |
$rv[] = '<th style="text-align: left;"></th>';
|
190 |
+
$rv[] = '<th style="text-align: left;">'.__('Hour','post-expirator').'('.date_i18n('T',mktime(0, 0, 0, $i, 1, date_i18n('Y'))).')</th>';
|
191 |
$rv[] = '<th style="text-align: left;">'.__('Minute','post-expirator').'</th>';
|
192 |
$rv[] = '</tr><tr>';
|
193 |
$rv[] = '<td>@</td><td>';
|
194 |
$rv[] = '<select name="expirationdate_hour" id="expirationdate_hour"'.$disabled.'>';
|
195 |
|
196 |
for($i = 1; $i <= 24; $i++) {
|
197 |
+
if ($defaulthour == date_i18n('H',mktime($i, 0, 0, date_i18n('n'), date_i18n('j'), date_i18n('Y'))))
|
198 |
$selected = ' selected="selected"';
|
199 |
else
|
200 |
$selected = '';
|
201 |
+
$rv[] = '<option value="'.date_i18n('H',mktime($i, 0, 0, date_i18n('n'), date_i18n('j'), date_i18n('Y'))).'"'.$selected.'>'.date_i18n('H',mktime($i, 0, 0, date_i18n('n'), date_i18n('j'), date_i18n('Y'))).'</option>';
|
202 |
}
|
203 |
|
204 |
$rv[] = '</select></td><td>';
|
208 |
$rv[] = '<input type="hidden" name="expirationdate_formcheck" value="true" />';
|
209 |
echo implode("\n",$rv);
|
210 |
|
211 |
+
echo '<br/>'.__('How to expire','post-expirator').': ';
|
212 |
+
echo _postExpiratorExpireType(array('name'=>'expirationdate_expiretype','selected'=>$expireType,'disabled'=>$disabled,'onchange' => 'expirationdate_toggle_category(this)'));
|
213 |
+
echo '<br/>';
|
214 |
+
|
215 |
+
if ($post->post_type != 'page') {
|
216 |
+
if (isset($expireType) && ($expireType == 'category' || $expireType == 'category-add' || $expireType == 'category-remove')) {
|
217 |
+
$catdisplay = 'block';
|
218 |
+
} else {
|
219 |
+
$catdisplay = 'none';
|
220 |
+
}
|
221 |
+
echo '<div id="expired-category-selection" style="display: '.$catdisplay.'">';
|
222 |
echo '<br/>'.__('Expiration Categories','post-expirator').':<br/>';
|
223 |
|
224 |
echo '<div class="wp-tab-panel" id="post-expirator-cat-list">';
|
228 |
wp_terms_checklist(0, array( 'taxonomy' => 'category', 'walker' => $walker, 'selected_cats' => $categories, 'checked_ontop' => false ) );
|
229 |
echo '</ul>';
|
230 |
echo '</div>';
|
231 |
+
echo '</div>';
|
|
|
232 |
}
|
233 |
echo '<div id="expirationdate_ajax_result"></div>';
|
234 |
}
|
247 |
if (expire.checked == true) {
|
248 |
var enable = 'true';
|
249 |
if (document.getElementById('expirationdate_month')) {
|
250 |
+
document.getElementById('expirationdate_month').disabled = false;
|
251 |
document.getElementById('expirationdate_day').disabled = false;
|
252 |
document.getElementById('expirationdate_year').disabled = false;
|
253 |
document.getElementById('expirationdate_hour').disabled = false;
|
254 |
document.getElementById('expirationdate_minute').disabled = false;
|
255 |
}
|
256 |
+
document.getElementById('expirationdate_expiretype').disabled = false;
|
257 |
var cats = document.getElementsByName('expirationdate_category[]');
|
258 |
var max = cats.length;
|
259 |
for (var i=0; i<max; i++) {
|
267 |
document.getElementById('expirationdate_hour').disabled = true;
|
268 |
document.getElementById('expirationdate_minute').disabled = true;
|
269 |
}
|
270 |
+
document.getElementById('expirationdate_expiretype').disabled = true;
|
271 |
var cats = document.getElementsByName('expirationdate_category[]');
|
272 |
var max = cats.length;
|
273 |
for (var i=0; i<max; i++) {
|
278 |
|
279 |
return true;
|
280 |
}
|
281 |
+
function expirationdate_toggle_category(id) {
|
282 |
+
if (id.options[id.selectedIndex].value == 'category') {
|
283 |
+
jQuery('#expired-category-selection').show();
|
284 |
+
} else if (id.options[id.selectedIndex].value == 'category-add') {
|
285 |
+
jQuery('#expired-category-selection').show(); //TEMP
|
286 |
+
} else if (id.options[id.selectedIndex].value == 'category-remove') {
|
287 |
+
jQuery('#expired-category-selection').show(); //TEMP
|
288 |
+
} else {
|
289 |
+
jQuery('#expired-category-selection').hide();
|
290 |
+
}
|
291 |
+
}
|
292 |
function expirationdate_toggle_defaultdate(id) {
|
293 |
if (id.options[id.selectedIndex].value == 'custom') {
|
294 |
jQuery('#expired-custom-container').show();
|
307 |
* Get correct URL (HTTP or HTTPS)
|
308 |
*/
|
309 |
function expirationdate_get_blog_url() {
|
310 |
+
if (is_multisite())
|
311 |
echo network_home_url('/');
|
312 |
else
|
313 |
echo home_url('/');
|
317 |
* Called when post is saved - stores expiration-date meta value
|
318 |
*/
|
319 |
function expirationdate_update_post_meta($id) {
|
320 |
+
// don't run the echo if this is an auto save
|
321 |
+
if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE )
|
322 |
+
return;
|
323 |
+
|
324 |
+
// don't run the echo if the function is called for saving revision.
|
325 |
+
$posttype = get_post_type($id);
|
326 |
+
if ( $posttype == 'revision' )
|
327 |
+
return;
|
328 |
+
|
329 |
if (!isset($_POST['expirationdate_formcheck']))
|
330 |
+
return;
|
331 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
332 |
if (isset($_POST['enable-expirationdate'])) {
|
333 |
+
$default = get_option('expirationdateDefaultDate',POSTEXPIRATOR_EXPIREDEFAULT);
|
334 |
+
if ($default == 'publish') {
|
335 |
+
$month = intval($_POST['mm']);
|
336 |
+
$day = intval($_POST['jj']);
|
337 |
+
$year = intval($_POST['aa']);
|
338 |
+
$hour = intval($_POST['hh']);
|
339 |
+
$minute = intval($_POST['mn']);
|
340 |
+
} else {
|
341 |
+
$month = intval($_POST['expirationdate_month']);
|
342 |
+
$day = intval($_POST['expirationdate_day']);
|
343 |
+
$year = intval($_POST['expirationdate_year']);
|
344 |
+
$hour = intval($_POST['expirationdate_hour']);
|
345 |
+
$minute = intval($_POST['expirationdate_minute']);
|
346 |
}
|
347 |
+
$category = isset($_POST['expirationdate_category']) ? $_POST['expirationdate_category'] : 0;
|
348 |
+
|
349 |
+
$opts = array();
|
350 |
+
$ts = get_gmt_from_date("$year-$month-$day $hour:$minute:0",'U');
|
351 |
+
|
352 |
+
// Schedule/Update Expiration
|
353 |
+
$opts['expireType'] = $_POST['expirationdate_expiretype'];
|
354 |
+
$opts['id'] = $id;
|
355 |
+
|
356 |
+
if ($opts['expireType'] == 'category' || $opts['expireType'] == 'category-add' || $opts['expireType'] == 'category-remove') {
|
357 |
+
if (isset($category) && !empty($category)) {
|
358 |
+
if (!empty($category)) {
|
359 |
+
$opts['category'] = $category;
|
360 |
+
}
|
361 |
+
}
|
362 |
+
}
|
363 |
+
|
364 |
+
_scheduleExpiratorEvent($id,$ts,$opts);
|
365 |
} else {
|
366 |
+
_unscheduleExpiratorEvent($id);
|
|
|
|
|
367 |
}
|
368 |
}
|
369 |
add_action('save_post','expirationdate_update_post_meta');
|
370 |
|
371 |
+
function _scheduleExpiratorEvent($id,$ts,$opts) {
|
372 |
+
$debug = postExpiratorDebug(); //check for/load debug
|
373 |
+
|
374 |
+
if (wp_next_scheduled('postExpiratorExpire',array($id)) !== false) {
|
375 |
+
wp_clear_scheduled_hook('postExpiratorExpire',array($id)); //Remove any existing hooks
|
376 |
+
if (POSTEXPIRATOR_DEBUG) $debug->save(array('message' => $id.' -> UNSCHEDULED'));
|
377 |
+
}
|
378 |
+
|
379 |
+
wp_schedule_single_event($ts,'postExpiratorExpire',array($id));
|
380 |
+
if (POSTEXPIRATOR_DEBUG) $debug->save(array('message' => $id.' -> SCHEDULED at '.date_i18n('r',$ts).' '.'('.$ts.') with options '.print_r($opts,true)));
|
381 |
+
|
382 |
+
// Update Post Meta
|
383 |
+
update_post_meta($id, '_expiration-date', $ts);
|
384 |
+
update_post_meta($id, '_expiration-date-options', $opts);
|
385 |
+
update_post_meta($id, '_expiration-date-status','saved');
|
386 |
+
}
|
387 |
+
|
388 |
+
function _unscheduleExpiratorEvent($id) {
|
389 |
+
$debug = postExpiratorDebug(); // check for/load debug
|
390 |
+
delete_post_meta($id, '_expiration-date');
|
391 |
+
delete_post_meta($id, '_expiration-date-options');
|
392 |
+
|
393 |
+
// Delete Scheduled Expiration
|
394 |
+
if (wp_next_scheduled('postExpiratorExpire',array($id)) !== false) {
|
395 |
+
wp_clear_scheduled_hook('postExpiratorExpire',array($id)); //Remove any existing hooks
|
396 |
+
if (POSTEXPIRATOR_DEBUG) $debug->save(array('message' => $id.' -> UNSCHEDULED'));
|
397 |
+
}
|
398 |
+
update_post_meta($id, '_expiration-date-status','saved');
|
399 |
+
}
|
400 |
+
|
401 |
+
/**
|
402 |
+
* The new expiration function, to work with single scheduled events.
|
403 |
+
*
|
404 |
+
* This was designed to hopefully be more flexible for future tweaks/modifications to the architecture.
|
405 |
+
*
|
406 |
+
* @param array $opts - options to pass into the expiration process, in key/value format
|
407 |
+
*/
|
408 |
+
function postExpiratorExpire($id) {
|
409 |
+
$debug = postExpiratorDebug(); //check for/load debug
|
410 |
+
|
411 |
+
if (empty($id)) {
|
412 |
+
if (POSTEXPIRATOR_DEBUG) $debug->save(array('message' => 'No Post ID found - exiting'));
|
413 |
+
return false;
|
414 |
+
}
|
415 |
+
|
416 |
+
if (is_null(get_post($id))) {
|
417 |
+
if (POSTEXPIRATOR_DEBUG) $debug->save(array('message' => $id.' -> Post does not exist - exiting'));
|
418 |
+
return false;
|
419 |
+
}
|
420 |
+
|
421 |
+
$postoptions = get_post_meta($id,'_expiration-date-options',true);
|
422 |
+
extract($postoptions);
|
423 |
+
|
424 |
+
// Check for default expire only if not passed in
|
425 |
+
if (empty($expireType)) {
|
426 |
+
$posttype = get_post_type($id);
|
427 |
+
if ($posttype == 'page') {
|
428 |
+
$expireType = strtolower(get_option('expirationdateExpiredPageStatus',POSTEXPIRATOR_PAGESTATUS));
|
429 |
+
} elseif ($posttype == 'post') {
|
430 |
+
$expireType = strtolower(get_option('expirationdateExpiredPostStatus','Draft'));
|
431 |
+
} else {
|
432 |
+
$expireType = apply_filters('postexpirator_custom_posttype_expire', $expireType, $posttype); //hook to set defaults for custom post types
|
433 |
+
}
|
434 |
+
}
|
435 |
+
|
436 |
+
// Remove KSES - wp_cron runs as an unauthenticated user, which will by default trigger kses filtering,
|
437 |
+
// even if the post was published by a admin user. It is fairly safe here to remove the filter call since
|
438 |
+
// we are only changing the post status/meta information and not touching the content.
|
439 |
+
kses_remove_filters();
|
440 |
+
|
441 |
+
// Do Work
|
442 |
+
if ($expireType == 'draft') {
|
443 |
+
if (wp_update_post(array('ID' => $id, 'post_status' => 'draft')) == 0) {
|
444 |
+
if (POSTEXPIRATOR_DEBUG) $debug->save(array('message' => $id.' -> FAILED '.$expireType.' '.print_r($postoptions,true)));
|
445 |
+
} else {
|
446 |
+
if (POSTEXPIRATOR_DEBUG) $debug->save(array('message' => $id.' -> PROCESSED '.$expireType.' '.print_r($postoptions,true)));
|
447 |
+
}
|
448 |
+
} elseif ($expireType == 'private') {
|
449 |
+
if (wp_update_post(array('ID' => $id, 'post_status' => 'private')) == 0) {
|
450 |
+
if (POSTEXPIRATOR_DEBUG) $debug->save(array('message' => $id.' -> FAILED '.$expireType.' '.print_r($postoptions,true)));
|
451 |
+
} else {
|
452 |
+
if (POSTEXPIRATOR_DEBUG) $debug->save(array('message' => $id.' -> PROCESSED '.$expireType.' '.print_r($postoptions,true)));
|
453 |
+
}
|
454 |
+
} elseif ($expireType == 'delete') {
|
455 |
+
if (wp_delete_post($id) === false) {
|
456 |
+
if (POSTEXPIRATOR_DEBUG) $debug->save(array('message' => $id.' -> FAILED '.$expireType.' '.print_r($postoptions,true)));
|
457 |
+
} else {
|
458 |
+
if (POSTEXPIRATOR_DEBUG) $debug->save(array('message' => $id.' -> PROCESSED '.$expireType.' '.print_r($postoptions,true)));
|
459 |
+
}
|
460 |
+
} elseif ($expireType == 'category') {
|
461 |
+
if (!empty($category)) {
|
462 |
+
if (wp_update_post(array('ID' => $id, 'post_category' => $category)) == 0) {
|
463 |
+
if (POSTEXPIRATOR_DEBUG) $debug->save(array('message' => $id.' -> FAILED '.$expireType.' '.print_r($postoptions,true)));
|
464 |
+
} else {
|
465 |
+
if (POSTEXPIRATOR_DEBUG) {
|
466 |
+
$debug->save(array('message' => $id.' -> PROCESSED '.$expireType.' '.print_r($postoptions,true)));
|
467 |
+
$debug->save(array('message' => $id.' -> CATEGORIES REPLACED '.print_r(_postExpiratorGetCatNames($category),true)));
|
468 |
+
$debug->save(array('message' => $id.' -> CATEGORIES COMPLETE '.print_r(_postExpiratorGetCatNames($category),true)));
|
469 |
+
}
|
470 |
+
}
|
471 |
+
} else {
|
472 |
+
if (POSTEXPIRATOR_DEBUG) $debug->save(array('message' => $id.' -> CATEGORIES MISSING '.$expireType.' '.print_r($postoptions,true)));
|
473 |
+
}
|
474 |
+
} elseif ($expireType == 'category-add') {
|
475 |
+
if (!empty($category)) {
|
476 |
+
$cats = wp_get_post_categories($id);
|
477 |
+
$merged = array_merge($cats,$category);
|
478 |
+
if (wp_update_post(array('ID' => $id, 'post_category' => $merged)) == 0) {
|
479 |
+
if (POSTEXPIRATOR_DEBUG) $debug->save(array('message' => $id.' -> FAILED '.$expireType.' '.print_r($postoptions,true)));
|
480 |
+
} else {
|
481 |
+
if (POSTEXPIRATOR_DEBUG) {
|
482 |
+
$debug->save(array('message' => $id.' -> PROCESSED '.$expireType.' '.print_r($postoptions,true)));
|
483 |
+
$debug->save(array('message' => $id.' -> CATEGORIES ADDED '.print_r(_postExpiratorGetCatNames($category),true)));
|
484 |
+
$debug->save(array('message' => $id.' -> CATEGORIES COMPLETE '.print_r(_postExpiratorGetCatNames($merged),true)));
|
485 |
+
}
|
486 |
+
}
|
487 |
+
} else {
|
488 |
+
if (POSTEXPIRATOR_DEBUG) $debug->save(array('message' => $id.' -> CATEGORIES MISSING '.$expireType.' '.print_r($postoptions,true)));
|
489 |
+
}
|
490 |
+
} elseif ($expireType == 'category-remove') {
|
491 |
+
if (!empty($category)) {
|
492 |
+
$cats = wp_get_post_categories($id);
|
493 |
+
$merged = array();
|
494 |
+
foreach ($cats as $cat) {
|
495 |
+
if (!in_array($cat,$category)) {
|
496 |
+
$merged[] = $cat;
|
497 |
+
}
|
498 |
+
}
|
499 |
+
if (wp_update_post(array('ID' => $id, 'post_category' => $merged)) == 0) {
|
500 |
+
if (POSTEXPIRATOR_DEBUG) $debug->save(array('message' => $id.' -> FAILED '.$expireType.' '.print_r($postoptions,true)));
|
501 |
+
} else {
|
502 |
+
if (POSTEXPIRATOR_DEBUG) {
|
503 |
+
$debug->save(array('message' => $id.' -> PROCESSED '.$expireType.' '.print_r($postoptions,true)));
|
504 |
+
$debug->save(array('message' => $id.' -> CATEGORIES REPLACED '.print_r(_postExpiratorGetCatNames($category),true)));
|
505 |
+
$debug->save(array('message' => $id.' -> CATEGORIES COMPLETE '.print_r(_postExpiratorGetCatNames($merged),true)));
|
506 |
+
}
|
507 |
+
}
|
508 |
+
} else {
|
509 |
+
if (POSTEXPIRATOR_DEBUG) $debug->save(array('message' => $id.' -> CATEGORIES MISSING '.$expireType.' '.print_r($postoptions,true)));
|
510 |
+
}
|
511 |
+
}
|
512 |
+
}
|
513 |
+
add_action('postExpiratorExpire','postExpiratorExpire');
|
514 |
+
|
515 |
+
function _postExpiratorGetCatNames($cats) {
|
516 |
+
$out = array();
|
517 |
+
foreach ($cats as $cat) {
|
518 |
+
$out[$cat] = get_the_category_by_id($cat);
|
519 |
+
}
|
520 |
+
return $out;
|
521 |
+
}
|
522 |
+
|
523 |
/**
|
524 |
* Build the menu for the options page
|
525 |
*/
|
527 |
echo '<p>';
|
528 |
if (empty($tab)) $tab = 'general';
|
529 |
echo '<a href="'.admin_url('options-general.php?page=post-expirator.php&tab=general').'"'.($tab == 'general' ? ' style="font-weight: bold; text-decoration:none;"' : '').'>'.__('General Settings','post-expirator').'</a> | ';
|
530 |
+
echo '<a href="'.admin_url('options-general.php?page=post-expirator.php&tab=defaults').'"'.($tab == 'defaults' ? ' style="font-weight: bold; text-decoration:none;"' : '').'>'.__('Defaults','post-expirator').'</a> | ';
|
531 |
echo '<a href="'.admin_url('options-general.php?page=post-expirator.php&tab=diagnostics').'"'.($tab == 'diagnostics' ? ' style="font-weight: bold; text-decoration:none;"' : '').'>'.__('Diagnostics','post-expirator').'</a>';
|
532 |
echo ' | <a href="'.admin_url('options-general.php?page=post-expirator.php&tab=viewdebug').'"'.($tab == 'viewdebug' ? ' style="font-weight: bold; text-decoration:none;"' : '').'>'.__('View Debug Logs','post-expirator').'</a>';
|
533 |
echo '</p><hr/>';
|
545 |
postExpiratorMenuTabs($tab);
|
546 |
if (empty($tab) || $tab == 'general') {
|
547 |
postExpiratorMenuGeneral();
|
548 |
+
} elseif ($tab == 'defaults') {
|
549 |
+
postExpiratorMenuDefaults();
|
550 |
} elseif ($tab == 'diagnostics') {
|
551 |
postExpiratorMenuDiagnostics();
|
552 |
} elseif ($tab == 'viewdebug') {
|
559 |
* Hook's to add plugin page menu
|
560 |
*/
|
561 |
function postExpiratorPluginMenu() {
|
562 |
+
add_submenu_page('options-general.php',__('Post Expirator Options','post-expirator'),__('Post Expirator','post-expirator'),'manage_options',basename(__FILE__),'postExpiratorMenu');
|
563 |
}
|
564 |
add_action('admin_menu', 'postExpiratorPluginMenu');
|
565 |
|
569 |
function postExpiratorMenuGeneral() {
|
570 |
|
571 |
if (isset($_POST['expirationdateSave']) && $_POST['expirationdateSave']) {
|
|
|
|
|
572 |
update_option('expirationdateDefaultDateFormat',$_POST['expired-default-date-format']);
|
573 |
update_option('expirationdateDefaultTimeFormat',$_POST['expired-default-time-format']);
|
574 |
update_option('expirationdateDisplayFooter',$_POST['expired-display-footer']);
|
575 |
update_option('expirationdateFooterContents',$_POST['expired-footer-contents']);
|
576 |
update_option('expirationdateFooterStyle',$_POST['expired-footer-style']);
|
577 |
+
if (isset($_POST['expirationdate_category'])) update_option('expirationdateCategoryDefaults',$_POST['expirationdate_category']);
|
|
|
|
|
578 |
update_option('expirationdateDefaultDate',$_POST['expired-default-expiration-date']);
|
|
|
579 |
if ($_POST['expired-custom-expiration-date']) update_option('expirationdateDefaultDateCustom',$_POST['expired-custom-expiration-date']);
|
|
|
580 |
echo "<div id='message' class='updated fade'><p>";
|
581 |
_e('Saved Options!','post-expirator');
|
582 |
echo "</p></div>";
|
583 |
}
|
|
|
584 |
|
585 |
// Get Option
|
|
|
|
|
586 |
$expirationdateDefaultDateFormat = get_option('expirationdateDefaultDateFormat',POSTEXPIRATOR_DATEFORMAT);
|
587 |
$expirationdateDefaultTimeFormat = get_option('expirationdateDefaultTimeFormat',POSTEXPIRATOR_TIMEFORMAT);
|
|
|
|
|
588 |
$expireddisplayfooter = get_option('expirationdateDisplayFooter',POSTEXPIRATOR_FOOTERDISPLAY);
|
589 |
$expirationdateFooterContents = get_option('expirationdateFooterContents',POSTEXPIRATOR_FOOTERCONTENTS);
|
590 |
$expirationdateFooterStyle = get_option('expirationdateFooterStyle',POSTEXPIRATOR_FOOTERSTYLE);
|
|
|
591 |
$expirationdateDefaultDate = get_option('expirationdateDefaultDate',POSTEXPIRATOR_EXPIREDEFAULT);
|
592 |
$expirationdateDefaultDateCustom = get_option('expirationdateDefaultDateCustom');
|
593 |
|
607 |
else if ($expiredcategory == 1)
|
608 |
$expiredcategoryenabled = 'checked="checked"';
|
609 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
610 |
?>
|
611 |
<p>
|
612 |
<?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'); ?>
|
622 |
<form method="post" id="expirationdate_save_options">
|
623 |
<h3><?php _e('Defaults','post-expirator'); ?></h3>
|
624 |
<table class="form-table">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
625 |
<tr valign-"top">
|
626 |
<th scope="row"><label for="expired-default-date-format"><?php _e('Date Format:','post-expirator');?></label></th>
|
627 |
<td>
|
638 |
<?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'); ?>
|
639 |
</td>
|
640 |
</tr>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
641 |
<tr valign-"top">
|
642 |
<th scope="row"><label for="expired-default-expiration-date"><?php _e('Default Date/Time Duration:','post-expirator');?></label></th>
|
643 |
<td>
|
659 |
</table>
|
660 |
<h3><?php _e('Category Expiration','post-expirator');?></h3>
|
661 |
<table class="form-table">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
662 |
<tr valign-"top">
|
663 |
<th scope="row"><?php _e('Default Expiration Category','post-expirator');?>:</th>
|
664 |
<td>
|
718 |
<?php
|
719 |
}
|
720 |
|
721 |
+
function postExpiratorMenuDefaults() {
|
722 |
+
$debug = postExpiratorDebug();
|
723 |
+
$types = get_post_types(array('_builtin' => false));
|
724 |
+
array_unshift($types,'post','page');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
725 |
|
726 |
+
if (isset($_POST['expirationdateSaveDefaults'])) {
|
727 |
+
$defaults = array();
|
728 |
+
foreach ($types as $type) {
|
729 |
+
if (isset($_POST['expirationdate_expiretype-'.$type])) {
|
730 |
+
$defaults[$type]['expireType'] = $_POST['expirationdate_expiretype-'.$type];
|
731 |
+
}
|
732 |
+
if (isset($_POST['expirationdate_autoenable-'.$type])) {
|
733 |
+
$defaults[$type]['autoEnable'] = intval($_POST['expirationdate_autoenable-'.$type]);
|
734 |
+
}
|
735 |
|
736 |
+
//Save Settings
|
737 |
+
update_option('expirationdateDefaults'.ucfirst($type),$defaults[$type]);
|
738 |
+
}
|
|
|
|
|
739 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
740 |
|
741 |
+
?>
|
742 |
+
<form method="post">
|
743 |
+
<h3><?php _e('Default Expiration Values','post-expirator');?></h3>
|
744 |
+
<p>
|
745 |
+
<?php _e('Use the values below to set the default actions/values to be used for each for the corresponding post types. These values can all be overwridden when creating/editing the post/page.','post-expirator'); ?>
|
746 |
+
</p>
|
747 |
+
<?php
|
748 |
+
foreach ($types as $type) {
|
749 |
+
$defaults = get_option('expirationdateDefaults'.ucfirst($type));
|
750 |
+
if (isset($defaults['autoEnable']) && $defaults['autoEnable'] == 1) {
|
751 |
+
$expiredautoenabled = 'checked = "checked"';
|
752 |
+
$expiredautodisabled = '';
|
753 |
+
} else {
|
754 |
+
$expiredautoenabled = '';
|
755 |
+
$expiredautodisabled = 'checked = "checked"';
|
756 |
+
}
|
757 |
+
print '<h4>Expiration values for: '.$type.'</h4>';
|
758 |
+
?>
|
759 |
+
<table class="form-table">
|
760 |
+
<tr valign-"top">
|
761 |
+
<th scope="row"><label for="expirationdate_expiretype-<?php echo $type ?>"><?php _e('How to expire:','post-expirator'); ?></label></th>
|
762 |
+
<td>
|
763 |
+
<?php echo _postExpiratorExpireType(array('name'=>'expirationdate_expiretype-'.$type,'selected' => $defaults['expireType'])); ?>
|
764 |
+
</select>
|
765 |
+
<br/>
|
766 |
+
<?php _e('Select the default expire action for the post type.','post-expirator');?>
|
767 |
+
</td>
|
768 |
+
</tr>
|
769 |
+
<tr valign-"top">
|
770 |
+
<th scope="row"><label for="expirationdate_autoenable-<?php echo $type ?>"><?php _e('Auto-Enable?','post-expirator');?></label></th>
|
771 |
+
<td>
|
772 |
+
<input type="radio" name="expirationdate_autoenable-<?php echo $type ?>" id="expirationdate_autoenable-true-<?php echo $type ?>" value="1" <?php echo $expiredautoenabled ?>/> <label for="expired-auto-enable-true"><?php _e('Enabled','post-expirator');?></label>
|
773 |
+
<input type="radio" name="expirationdate_autoenable-<?php echo $type ?>" id="expirationdate_autoenable-false-<?php echo $type ?>" value="0" <?php echo $expiredautodisabled ?>/> <label for="expired-auto-enable-false"><?php _e('Disabled','post-expirator');?></label>
|
774 |
+
<br/>
|
775 |
+
<?php _e('Select whether the post expirator is enabled for all new posts.','post-expirator');?>
|
776 |
+
</td>
|
777 |
+
</tr>
|
778 |
+
</table>
|
779 |
+
<?php
|
780 |
+
}
|
781 |
+
?>
|
782 |
+
<p class="submit">
|
783 |
+
<input type="submit" name="expirationdateSaveDefaults" class="button-primary" value="<?php _e('Save Changes','post-expirator');?>" />
|
784 |
+
</p>
|
785 |
+
</form>
|
786 |
+
<?php
|
787 |
}
|
788 |
|
789 |
function postExpiratorMenuDiagnostics() {
|
800 |
echo "<div id='message' class='updated fade'><p>"; _e('Debugging Table Emptied','post-expirator'); echo "</p></div>";
|
801 |
}
|
802 |
|
803 |
+
$debug = postExpiratorDebug();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
804 |
?>
|
805 |
<form method="post" id="postExpiratorMenuUpgrade">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
806 |
<h3><?php _e('Advanced Diagnostics','post-expirator');?></h3>
|
807 |
<table class="form-table">
|
808 |
<tr valign-"top">
|
809 |
<th scope="row"><label for="postexpirator-log"><?php _e('Post Expirator Debug Logging:','post-expirator');?></label></th>
|
810 |
<td>
|
811 |
<?php
|
812 |
+
if (POSTEXPIRATOR_DEBUG) {
|
813 |
echo __('Status: Enabled','post-expirator').'<br/>';
|
814 |
echo '<input type="submit" class="button" name="debugging-disable" id="debugging-disable" value="'.__('Disable Debugging','post-expirator').'" />';
|
815 |
} else {
|
831 |
<th scope="row"><label for="cron-schedule"><?php _e('Current Cron Schedule:','post-expirator');?></label></th>
|
832 |
<td>
|
833 |
<?php _e('The below table will show all currently scheduled cron events with the next run time.','post-expirator');?><br/>
|
|
|
|
|
|
|
|
|
|
|
|
|
834 |
|
835 |
<table>
|
836 |
<tr>
|
837 |
+
<th style="width: 200px;"><?php _e('Date','post-expirator');?></th>
|
838 |
+
<th style="width: 200px;"><?php _e('Event','post-expirator');?></th>
|
839 |
+
<th style="width: 500px;"><?php _e('Arguments / Schedule','post-expirator');?></th>
|
|
|
840 |
</tr>
|
841 |
<?php
|
842 |
$cron = _get_cron_array();
|
846 |
print '<td>'.date_i18n('r',$key).'</td>';
|
847 |
print '<td>'.$eventkey.'</td>';
|
848 |
$arrkey = array_keys($eventvalue);
|
849 |
+
print '<td>';
|
850 |
+
foreach ($arrkey as $eventguid) {
|
851 |
+
print '<table><tr>';
|
852 |
+
if (empty($eventvalue[$eventguid]['args'])) {
|
853 |
+
print '<td>No Arguments</td>';
|
854 |
+
} else {
|
855 |
+
print '<td>';
|
856 |
+
$args = array();
|
857 |
+
foreach ($eventvalue[$eventguid]['args'] as $key=>$value) {
|
858 |
+
$args[] = "$key => $value";
|
859 |
+
}
|
860 |
+
print implode("<br/>\n",$args);
|
861 |
+
print '</td>';
|
862 |
+
}
|
863 |
+
if (empty($eventvalue[$eventguid]['schedule'])) {
|
864 |
+
print '<td>'.__('Single Event','post-expirator').'</td>';
|
865 |
+
} else {
|
866 |
+
print '<td>'.$eventvalue[$eventguid]['schedule'].' ('.$eventvalue[$eventguid]['interval'].')</td>';
|
867 |
+
}
|
868 |
+
print '</tr></table>';
|
869 |
+
}
|
870 |
+
print '</td>';
|
871 |
print '</tr>';
|
872 |
}
|
873 |
}
|
891 |
function postexpirator_shortcode($atts) {
|
892 |
global $post;
|
893 |
|
894 |
+
$expirationdatets = get_post_meta($post->ID,'_expiration-date',true);
|
895 |
if (empty($expirationdatets))
|
896 |
return false;
|
897 |
|
898 |
extract(shortcode_atts(array(
|
899 |
'dateformat' => get_option('expirationdateDefaultDateFormat',POSTEXPIRATOR_DATEFORMAT),
|
900 |
'timeformat' => get_option('expirationdateDefaultTimeFormat',POSTEXPIRATOR_TIMEFORMAT),
|
901 |
+
'type' => 'full',
|
902 |
'tz' => date('T')
|
903 |
), $atts));
|
904 |
|
919 |
else if ($type == 'time')
|
920 |
$format = $timeformat;
|
921 |
|
922 |
+
return postexpirator_get_date_from_gmt(date_i18n('Y-m-d H:i:s',$expirationdatets),$format);
|
|
|
923 |
}
|
924 |
add_shortcode('postexpirator', 'postexpirator_shortcode');
|
925 |
|
931 |
if ($displayFooter === false || $displayFooter == 0)
|
932 |
return $text;
|
933 |
|
934 |
+
$expirationdatets = get_post_meta($post->ID,'_expiration-date',true);
|
935 |
if (!is_numeric($expirationdatets))
|
936 |
return $text;
|
937 |
|
940 |
$expirationdateFooterContents = get_option('expirationdateFooterContents',POSTEXPIRATOR_FOOTERCONTENTS);
|
941 |
$expirationdateFooterStyle = get_option('expirationdateFooterStyle',POSTEXPIRATOR_FOOTERSTYLE);
|
942 |
|
|
|
943 |
$search = array(
|
944 |
'EXPIRATIONFULL',
|
945 |
'EXPIRATIONDATE',
|
946 |
'EXPIRATIONTIME'
|
947 |
);
|
948 |
$replace = array(
|
949 |
+
postexpirator_get_date_from_gmt(date_i18n('Y-m-d H:i:s',$expirationdatets),"$dateformat $timeformat"),
|
950 |
+
postexpirator_get_date_from_gmt(date_i18n('Y-m-d H:i:s',$expirationdatets),$dateformat),
|
951 |
+
postexpirator_get_date_from_gmt(date_i18n('Y-m-d H:i:s',$expirationdatets),$timeformat)
|
952 |
);
|
953 |
|
954 |
$add_to_footer = '<p style="'.$expirationdateFooterStyle.'">'.str_replace($search,$replace,$expirationdateFooterContents).'</p>';
|
959 |
/**
|
960 |
* Check for Debug
|
961 |
*/
|
962 |
+
function postExpiratorDebug() {
|
963 |
$debug = get_option('expirationdateDebug');
|
964 |
+
if ($debug == 1) {
|
965 |
+
define('POSTEXPIRATOR_DEBUG',1);
|
966 |
+
require_once(plugin_dir_path(__FILE__).'post-expirator-debug.php'); // Load Class
|
967 |
+
return new postExpiratorDebug();
|
968 |
+
} else {
|
969 |
+
define('POSTEXPIRATOR_DEBUG',0);
|
970 |
+
return false;
|
971 |
+
}
|
972 |
}
|
973 |
|
974 |
+
|
975 |
/**
|
976 |
* Add Stylesheet
|
977 |
*/
|
990 |
* Post Expirator Activation/Upgrade
|
991 |
*/
|
992 |
function postexpirator_upgrade() {
|
993 |
+
|
994 |
// Check for current version, if not exists, run activation
|
995 |
$version = get_option('postexpiratorVersion');
|
996 |
if ($version === false) { //not installed, run default activation
|
997 |
postexpirator_activate();
|
998 |
update_option('postexpiratorVersion',POSTEXPIRATOR_VERSION);
|
999 |
+
} else {
|
1000 |
+
if (version_compare($version,'1.6.1') == -1) {
|
1001 |
+
update_option('postexpiratorVersion',POSTEXPIRATOR_VERSION);
|
1002 |
+
update_option('expirationdateDefaultDate',POSTEXPIRATOR_EXPIREDEFAULT);
|
1003 |
+
}
|
1004 |
+
|
1005 |
+
if (version_compare($version,'1.6.2') == -1) {
|
1006 |
+
update_option('postexpiratorVersion',POSTEXPIRATOR_VERSION);
|
1007 |
+
}
|
1008 |
+
|
1009 |
+
if (version_compare($version,'2.0.0-rc1') == -1) {
|
1010 |
+
global $wpdb;
|
1011 |
+
|
1012 |
+
// Schedule Events/Migrate Config
|
1013 |
+
$results = $wpdb->get_results($wpdb->prepare('select post_id, meta_value from ' . $wpdb->postmeta . ' as postmeta, '.$wpdb->posts.' as posts where postmeta.post_id = posts.ID AND postmeta.meta_key = %s AND postmeta.meta_value >= %d','expiration-date',time()));
|
1014 |
+
foreach ($results as $result) {
|
1015 |
+
wp_schedule_single_event($result->meta_value,'postExpiratorExpire',array($result->post_id));
|
1016 |
+
$opts = array();
|
1017 |
+
$opts['id'] = $result->post_id;
|
1018 |
+
$posttype = get_post_type($result->post_id);
|
1019 |
+
if ($posttype == 'page') {
|
1020 |
+
$opts['expireType'] = strtolower(get_option('expirationdateExpiredPageStatus','Draft'));
|
1021 |
+
} else {
|
1022 |
+
$opts['expireType'] = strtolower(get_option('expirationdateExpiredPostStatus','Draft'));
|
1023 |
+
}
|
1024 |
+
|
1025 |
+
$cat = get_post_meta($result->post_id,'_expiration-date-category',true);
|
1026 |
+
if ((isset($cat) && !empty($cat))) {
|
1027 |
+
$opts['category'] = $cat;
|
1028 |
+
$opts['expireType'] = 'category';
|
1029 |
+
}
|
1030 |
+
update_post_meta($result->post_id,'_expiration-date-options',$opts);
|
1031 |
+
}
|
1032 |
+
|
1033 |
+
// update meta key to new format
|
1034 |
+
$wpdb->query($wpdb->prepare("UPDATE $wpdb->postmeta SET meta_key = %s WHERE meta_key = %s",'_expiration-date','expiration-date'));
|
1035 |
+
|
1036 |
+
// migrate defaults
|
1037 |
+
$pagedefault = get_option('expirationdateExpiredPageStatus');
|
1038 |
+
$postdefault = get_option('expirationdateExpiredPostStatus');
|
1039 |
+
if ($pagedefault) update_option('expirationdateDefaultsPage',array('expireType' => $pagedefault));
|
1040 |
+
if ($postdefault) update_option('expirationdateDefaultsPost',array('expireType' => $postdefault));
|
1041 |
+
|
1042 |
+
delete_option('expirationdateCronSchedule');
|
1043 |
+
delete_option('expirationdateAutoEnabled');
|
1044 |
+
delete_option('expirationdateExpiredPageStatus');
|
1045 |
+
delete_option('expirationdateExpiredPostStatus');
|
1046 |
+
update_option('postexpiratorVersion',POSTEXPIRATOR_VERSION);
|
1047 |
}
|
1048 |
}
|
1049 |
}
|
1053 |
* Called at plugin activation
|
1054 |
*/
|
1055 |
function postexpirator_activate () {
|
|
|
|
|
1056 |
if (get_option('expirationdateDefaultDateFormat') === false) update_option('expirationdateDefaultDateFormat',POSTEXPIRATOR_DATEFORMAT);
|
1057 |
if (get_option('expirationdateDefaultTimeFormat') === false) update_option('expirationdateDefaultTimeFormat',POSTEXPIRATOR_TIMEFORMAT);
|
1058 |
if (get_option('expirationdateFooterContents') === false) update_option('expirationdateFooterContents',POSTEXPIRATOR_FOOTERCONTENTS);
|
1059 |
if (get_option('expirationdateFooterStyle') === false) update_option('expirationdateFooterStyle',POSTEXPIRATOR_FOOTERSTYLE);
|
1060 |
if (get_option('expirationdateDisplayFooter') === false) update_option('expirationdateDisplayFooter',POSTEXPIRATOR_FOOTERDISPLAY);
|
1061 |
+
if (get_option('expirationdateDebug') === false) update_option('expirationdateDebug',POSTEXPIRATOR_DEBUGDEFAULT);
|
|
|
1062 |
if (get_option('expirationdateDefaultDate') === false) update_option('expirationdateDefaultDate',POSTEXPIRATOR_EXPIREDEFAULT);
|
|
|
|
|
|
|
|
|
|
|
|
|
1063 |
}
|
1064 |
|
1065 |
/**
|
1082 |
delete_option('expirationdateDefaultDate');
|
1083 |
delete_option('expirationdateDefaultDateCustom');
|
1084 |
delete_option('expirationdateAutoEnabled');
|
1085 |
+
delete_option('expirationdateDefaultsPage');
|
1086 |
+
delete_option('expirationdateDefaultsPost');
|
1087 |
+
## what about custom post types? - how to cleanup?
|
1088 |
+
if (is_multisite())
|
1089 |
wp_clear_scheduled_hook('expirationdate_delete_'.$current_blog->blog_id);
|
1090 |
else
|
1091 |
wp_clear_scheduled_hook('expirationdate_delete');
|
1122 |
|
1123 |
$name = 'expirationdate_category';
|
1124 |
|
1125 |
+
$class = in_array( $category->term_id, $popular_cats ) ? ' class="expirator-category"' : '';
|
1126 |
+
$output .= "\n<li id='expirator-{$taxonomy}-{$category->term_id}'$class>" . '<label class="selectit"><input value="' . $category->term_id . '" type="checkbox" name="'.$name.'[]" id="expirator-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>';
|
1127 |
}
|
1128 |
|
1129 |
function end_el(&$output, $category, $depth, $args) {
|
1130 |
$output .= "</li>\n";
|
1131 |
}
|
1132 |
}
|
1133 |
+
|
1134 |
+
function _postExpiratorExpireType($opts) {
|
1135 |
+
if (empty($opts)) return false;
|
1136 |
+
|
1137 |
+
extract($opts);
|
1138 |
+
if (!isset($name)) return false;
|
1139 |
+
if (!isset($id)) $id = $name;
|
1140 |
+
if (!isset($disabled)) $disabled = '';
|
1141 |
+
if (!isset($onchange)) $onchange = '';
|
1142 |
+
if (!isset($type)) $type = '';
|
1143 |
+
|
1144 |
+
$rv = array();
|
1145 |
+
$rv[] = '<select name="'.$name.'" id="'.$id.'"'.$disabled.' onchange="'.$onchange.'">';
|
1146 |
+
$rv[] = '<option value="draft" '. ($selected == 'draft' ? 'selected="selected"' : '') . '>'.__('Draft','post-expirator').'</option>';
|
1147 |
+
$rv[] = '<option value="delete" '. ($selected == 'delete' ? 'selected="selected"' : '') . '>'.__('Delete','post-expirator').'</option>';
|
1148 |
+
$rv[] = '<option value="private" '. ($selected == 'private' ? 'selected="selected"' : '') . '>'.__('Private','post-expirator').'</option>';
|
1149 |
+
$rv[] = '<option value="category" '. ($selected == 'category' ? 'selected="selected"' : '') . '>'.__('Category: Replace','post-expirator').'</option>';
|
1150 |
+
$rv[] = '<option value="category-add" '. ($selected == 'category-add' ? 'selected="selected"' : '') . '>'.__('Category: Add','post-expirator').'</option>';
|
1151 |
+
$rv[] = '<option value="category-remove" '. ($selected == 'category-remove' ? 'selected="selected"' : '') . '>'.__('Category: Remove','post-expirator').'</option>';
|
1152 |
+
$rv[] = '</select>';
|
1153 |
+
return implode("<br/>/n",$rv);
|
1154 |
+
}
|
1155 |
+
|
1156 |
+
/**
|
1157 |
+
* TEMPORARY FUNCTION UNTIL TICKET 20328 IS FIXED
|
1158 |
+
*/
|
1159 |
+
function postexpirator_get_date_from_gmt($string,$format = 'Y-m-d H:i:s') {
|
1160 |
+
$tz = get_option('timezone_string');
|
1161 |
+
if ( $tz ) {
|
1162 |
+
$datetime = new DateTime( $string , new DateTimeZone('UTC') );
|
1163 |
+
$datetime->setTimezone( new DateTimeZone($tz) );
|
1164 |
+
$string_localtime = $datetime->format($format);
|
1165 |
+
} else {
|
1166 |
+
preg_match('#([0-9]{1,4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})#', $string, $matches);
|
1167 |
+
$string_time = gmmktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
|
1168 |
+
$string_localtime = gmdate($format, $string_time + get_option('gmt_offset')*3600);
|
1169 |
+
}
|
1170 |
+
return $string_localtime;
|
1171 |
+
}
|
readme.txt
CHANGED
@@ -2,8 +2,8 @@
|
|
2 |
Contributors: axelseaa
|
3 |
Tags: expire, posts, pages, schedule
|
4 |
Requires at least: 3.2
|
5 |
-
Tested up to: 3.
|
6 |
-
Stable tag:
|
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.
|
@@ -47,6 +47,25 @@ This section describes how to install the plugin and get it working.
|
|
47 |
|
48 |
== Changelog ==
|
49 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
**Version 1.6.2**
|
51 |
|
52 |
* Added the ability to configure the post expirator to be enabled by default for all new posts
|
@@ -150,6 +169,9 @@ NOTE: After upgrading, you may need to reset the cron schedules. Following onsc
|
|
150 |
|
151 |
== Upgrade Notice ==
|
152 |
|
|
|
|
|
|
|
153 |
= 1.6.1 =
|
154 |
Tweaked error messages, added option to allow user to select cron schedule and set default exiration duration
|
155 |
|
2 |
Contributors: axelseaa
|
3 |
Tags: expire, posts, pages, schedule
|
4 |
Requires at least: 3.2
|
5 |
+
Tested up to: 3.5.1
|
6 |
+
Stable tag: 2.0.0
|
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.
|
47 |
|
48 |
== Changelog ==
|
49 |
|
50 |
+
**Version 2.0.0**
|
51 |
+
|
52 |
+
This is a major update of the core functions of this plugin. All current plugins and settings should be upgraded to the new formats and work as expected. Any posts currently schedule to be expirated in the future will be automatically upgraded to the new format.
|
53 |
+
|
54 |
+
* New: Improved debug calls and logging
|
55 |
+
* New: Added the ability to expire to a "private" post
|
56 |
+
* New: Added the ability to expire by adding or removing categories. The old way of doing things is now known as replacing categories
|
57 |
+
* New: Revamped the expiration process - the plugin no longer runs on an minute, hourly, or other schedule. Each expiration event schedules a unique event to run, conserving system resources and making things more efficient
|
58 |
+
* New: The type of expiration event can be selected for each post, directly from the post editing screen
|
59 |
+
* New: Ability to set defaults for each post type (including custom posts)
|
60 |
+
* New: Renamed expiration-date meta value to _expiration-date
|
61 |
+
* New: Revamped timezone handling to be more correct with WordPress standards and fix conflicts with other plugins
|
62 |
+
* New: 'Expires' column on post display table now uses the default date/time formats set for the blog
|
63 |
+
* Fix: Removed kses filter calls when then schedule task runs that was causing code entered as unfiltered_html to be removed
|
64 |
+
* Fix: Updated some calls of date to now use date_i18n
|
65 |
+
* Fix: Most (if not all) php error/warnings should be addressed
|
66 |
+
* Fix: Updated wpdb calls in the debug class to use wpdb_prepare correctly
|
67 |
+
* Fix: Changed menu capability option from "edit_plugin" to "manage_options"
|
68 |
+
|
69 |
**Version 1.6.2**
|
70 |
|
71 |
* Added the ability to configure the post expirator to be enabled by default for all new posts
|
169 |
|
170 |
== Upgrade Notice ==
|
171 |
|
172 |
+
= 2.0.0 =
|
173 |
+
This is a major update of the core functions of this plugin. All current plugins and settings should be upgraded to the new formats and work as expected. Any posts currently schedule to be expirated in the future will be automatically upgraded to the new format.
|
174 |
+
|
175 |
= 1.6.1 =
|
176 |
Tweaked error messages, added option to allow user to select cron schedule and set default exiration duration
|
177 |
|
screenshot-1.png
CHANGED
Binary file
|
screenshot-2.png
CHANGED
Binary file
|
screenshot-3.png
CHANGED
Binary file
|