Version Description
Download this release
Release Info
Developer | axelseaa |
Plugin | Post Expirator |
Version | 1.4 |
Comparing to | |
See all releases |
Code changes from version 1.3.1 to 1.4
- post-expirator.php +165 -26
- readme.txt +15 -5
post-expirator.php
CHANGED
@@ -2,9 +2,9 @@
|
|
2 |
/*
|
3 |
Plugin Name: Post Expirator
|
4 |
Plugin URI: http://wordpress.org/extend/plugins/post-expirator/
|
5 |
-
Description: Allows you to add an expiration date
|
6 |
Author: Aaron Axelsen
|
7 |
-
Version: 1.
|
8 |
Author URI: http://www.frozenpc.net
|
9 |
*/
|
10 |
|
@@ -14,22 +14,47 @@ $expirationdateDefaultTimeFormat = 'g:ia';
|
|
14 |
$expirationdateDefaultFooterContents = 'Post expires at EXPIRATIONTIME on EXPIRATIONDATE';
|
15 |
$expirationdateDefaultFooterStyle = 'font-style: italic;';
|
16 |
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
|
28 |
/**
|
29 |
* Function that does the actualy deleting - called by wp_cron
|
30 |
*/
|
31 |
function expirationdate_delete_expired_posts() {
|
32 |
global $wpdb;
|
|
|
33 |
$result = $wpdb->get_results('select post_id, meta_value from ' . $wpdb->postmeta . ' as postmeta, '.$wpdb->posts.' as posts where postmeta.post_id = posts.ID AND posts.post_status = "publish" AND postmeta.meta_key = "expiration-date" AND postmeta.meta_value <= "' . mktime() . '"');
|
34 |
if (!empty($result)) foreach ($result as $a) {
|
35 |
$post_result = $wpdb->get_var('select post_type from ' . $wpdb->posts .' where ID = '. $a->post_id);
|
@@ -50,7 +75,10 @@ function expirationdate_delete_expired_posts() {
|
|
50 |
}
|
51 |
}
|
52 |
}
|
53 |
-
|
|
|
|
|
|
|
54 |
|
55 |
/**
|
56 |
* Called at plugin activation
|
@@ -64,8 +92,12 @@ function expirationdate_activate () {
|
|
64 |
update_option('expirationdateFooterContents',$expirationdateDefaultFooterContents);
|
65 |
update_option('expirationdateFooterStyle',$expirationdateDefaultFooterStyle);
|
66 |
update_option('expirationdateDisplayFooter',0);
|
|
|
67 |
|
68 |
-
|
|
|
|
|
|
|
69 |
}
|
70 |
register_activation_hook (__FILE__, 'expirationdate_activate');
|
71 |
|
@@ -81,7 +113,10 @@ function expirationdate_deactivate () {
|
|
81 |
delete_option('expirationdateDisplayFooter');
|
82 |
delete_option('expirationdateFooterContents');
|
83 |
delete_option('expirationdateFooterStyle');
|
84 |
-
|
|
|
|
|
|
|
85 |
}
|
86 |
register_deactivation_hook (__FILE__, 'expirationdate_deactivate');
|
87 |
|
@@ -89,7 +124,7 @@ register_deactivation_hook (__FILE__, 'expirationdate_deactivate');
|
|
89 |
* adds an 'Expires' column to the post display table.
|
90 |
*/
|
91 |
function expirationdate_add_column ($columns) {
|
92 |
-
$columns['expirationdate'] = 'Expires <br/><span style="font-size: 0.8em; font-weight: normal;">(YYYY/MM/DD HH)</span>';
|
93 |
return $columns;
|
94 |
}
|
95 |
add_filter ('manage_posts_columns', 'expirationdate_add_column');
|
@@ -102,9 +137,10 @@ function expirationdate_show_value ($column_name) {
|
|
102 |
global $wpdb, $post;
|
103 |
$id = $post->ID;
|
104 |
if ($column_name === 'expirationdate') {
|
|
|
105 |
$query = "SELECT meta_value FROM $wpdb->postmeta WHERE meta_key = \"expiration-date\" AND post_id=$id";
|
106 |
$ed = $wpdb->get_var($query);
|
107 |
-
echo ($ed ? date('Y/m/d H',$ed) : "Never");
|
108 |
}
|
109 |
}
|
110 |
add_action ('manage_posts_custom_column', 'expirationdate_show_value');
|
@@ -131,18 +167,21 @@ add_action ('edit_page_form','expirationdate_meta_page');
|
|
131 |
*/
|
132 |
function expirationdate_meta_box($post) {
|
133 |
// Get default month
|
|
|
134 |
$expirationdatets = get_post_meta($post->ID,'expiration-date',true);
|
135 |
if (empty($expirationdatets)) {
|
136 |
$defaultmonth = date('F');
|
137 |
$defaultday = date('d');
|
138 |
$defaulthour = date('H');
|
139 |
$defaultyear = date('Y');
|
|
|
140 |
$disabled = 'disabled="disabled"';
|
141 |
} else {
|
142 |
$defaultmonth = date('F',$expirationdatets);
|
143 |
$defaultday = date('d',$expirationdatets);
|
144 |
$defaultyear = date('Y',$expirationdatets);
|
145 |
$defaulthour = date('H',$expirationdatets);
|
|
|
146 |
|
147 |
$enabled = ' checked="checked"';
|
148 |
$disabled = '';
|
@@ -157,6 +196,7 @@ function expirationdate_meta_box($post) {
|
|
157 |
$rv[] = '<th style="text-align: left;">Year</th>';
|
158 |
$rv[] = '<th style="text-align: left;"></th>';
|
159 |
$rv[] = '<th style="text-align: left;">Hour (24 Hour Format)</th>';
|
|
|
160 |
$rv[] = '</tr><tr>';
|
161 |
$rv[] = '<td>';
|
162 |
$rv[] = '<select name="expirationdate_month" id="expirationdate_month"'.$disabled.'">';
|
@@ -185,6 +225,8 @@ function expirationdate_meta_box($post) {
|
|
185 |
$rv[] = '</select>';
|
186 |
$rv[] = '</td><td>@</td><td>';
|
187 |
$rv[] = '<input type="text" id="expirationdate_hour" name="expirationdate_hour" value="'.$defaulthour.'" size="2"'.$disabled.'" />';
|
|
|
|
|
188 |
$rv[] = '<input type="hidden" name="expirationdate_formcheck" value="true" />';
|
189 |
$rv[] = '</td></tr></table>';
|
190 |
|
@@ -227,11 +269,13 @@ function expirationdate_ajax_add_meta(expireenable) {
|
|
227 |
document.getElementById('expirationdate_day').disabled = false;
|
228 |
document.getElementById('expirationdate_year').disabled = false;
|
229 |
document.getElementById('expirationdate_hour').disabled = false;
|
|
|
230 |
} else {
|
231 |
document.getElementById('expirationdate_month').disabled = true;
|
232 |
document.getElementById('expirationdate_day').disabled = true;
|
233 |
document.getElementById('expirationdate_year').disabled = true;
|
234 |
document.getElementById('expirationdate_hour').disabled = true;
|
|
|
235 |
var enable = 'false';
|
236 |
}
|
237 |
|
@@ -257,7 +301,11 @@ add_action('admin_print_scripts', 'expirationdate_js_admin_header' );
|
|
257 |
function expirationdate_get_blog_url() {
|
258 |
global $current_blog;
|
259 |
$schema = ( isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on' ) ? 'https://' : 'http://';
|
260 |
-
|
|
|
|
|
|
|
|
|
261 |
}
|
262 |
|
263 |
/**
|
@@ -271,10 +319,12 @@ function expirationdate_update_post_meta($id) {
|
|
271 |
$day = $_POST['expirationdate_day'];
|
272 |
$year = $_POST['expirationdate_year'];
|
273 |
$hour = $_POST['expirationdate_hour'];
|
|
|
274 |
|
275 |
if (isset($_POST['enable-expirationdate'])) {
|
|
|
276 |
// Format Date
|
277 |
-
$ts = mktime($hour,0
|
278 |
// Update Post Meta
|
279 |
delete_post_meta($id, 'expiration-date');
|
280 |
update_post_meta($id, 'expiration-date', $ts, true);
|
@@ -284,18 +334,45 @@ function expirationdate_update_post_meta($id) {
|
|
284 |
}
|
285 |
add_action('save_post','expirationdate_update_post_meta');
|
286 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
287 |
/**
|
288 |
* Hook's to add plugin page menu
|
289 |
*/
|
290 |
-
function
|
291 |
-
add_submenu_page('options-general.php','Post Expirator Options','Post Expirator',9,basename(__FILE__),'
|
292 |
}
|
293 |
-
add_action('admin_menu', '
|
294 |
|
295 |
/**
|
296 |
* Show the Expiration Date options page
|
297 |
*/
|
298 |
-
function
|
299 |
|
300 |
if ($_POST['expirationdateSave']) {
|
301 |
update_option('expirationdateExpiredPostStatus',$_POST['expired-post-status']);
|
@@ -353,8 +430,6 @@ function expirationdate_show_options() {
|
|
353 |
}
|
354 |
|
355 |
?>
|
356 |
-
<div class="wrap">
|
357 |
-
<h2><?php _e('Post Expirator Options'); ?></h2>
|
358 |
<p>
|
359 |
The post expirator plugin sets a custom meta value, and then optionally allows you to select if you want the post
|
360 |
changed to a draft status or deleted when it expires.
|
@@ -450,10 +525,74 @@ function expirationdate_show_options() {
|
|
450 |
<input type="submit" name="expirationdateSave" value="Save" />
|
451 |
</p>
|
452 |
</form>
|
453 |
-
</div>
|
454 |
<?php
|
455 |
}
|
456 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
457 |
// [postexpirator format="l F jS, Y g:ia" tz="foo"]
|
458 |
function postexpirator_shortcode($atts) {
|
459 |
global $post;
|
2 |
/*
|
3 |
Plugin Name: Post Expirator
|
4 |
Plugin URI: http://wordpress.org/extend/plugins/post-expirator/
|
5 |
+
Description: Allows you to add an expiration date to posts which you can configure to either delete the post or change it to a draft.
|
6 |
Author: Aaron Axelsen
|
7 |
+
Version: 1.4
|
8 |
Author URI: http://www.frozenpc.net
|
9 |
*/
|
10 |
|
14 |
$expirationdateDefaultFooterContents = 'Post expires at EXPIRATIONTIME on EXPIRATIONDATE';
|
15 |
$expirationdateDefaultFooterStyle = 'font-style: italic;';
|
16 |
|
17 |
+
// Detect WPMU
|
18 |
+
function postExpirator_is_wpmu() {
|
19 |
+
return file_exists(ABSPATH."/wpmu-settings.php");
|
20 |
+
}
|
21 |
+
|
22 |
+
// Timezone Setup
|
23 |
+
function postExpiratorTimezoneSetup() {
|
24 |
+
if ( !$timezone_string = get_option( 'timezone_string' ) ) {
|
25 |
+
return false;
|
26 |
+
}
|
27 |
+
|
28 |
+
@date_default_timezone_set($timezone_string);
|
29 |
+
}
|
30 |
+
|
31 |
+
// Add cron interval of 60 seconds
|
32 |
+
function postExpiratorAddCronMinutes($array) {
|
33 |
+
$array['postexpiratorminute'] = array(
|
34 |
+
'interval' => 60,
|
35 |
+
'display' => __('Once a Minute')
|
36 |
+
);
|
37 |
+
return $array;
|
38 |
+
}
|
39 |
+
add_filter('cron_schedules','postExpiratorAddCronMinutes');
|
40 |
+
|
41 |
+
/**
|
42 |
+
* Add admin notice hook if cron schedule needs to be reset
|
43 |
+
*/
|
44 |
+
function postExpirationAdminNotice() {
|
45 |
+
if (postExpiratorCronStatus() === false) {
|
46 |
+
echo '<div class="error fade" style="background-color:red;"><p><strong>Post Expirator cron schedules need to be reset.
|
47 |
+
<a href="'.admin_url('options-general.php?page=post-expirator.php&tab=upgrade').'" style="color: blue;">Click here to reset</a></strong></p></div>';
|
48 |
+
}
|
49 |
+
}
|
50 |
+
add_action('admin_notices','postExpirationAdminNotice');
|
51 |
|
52 |
/**
|
53 |
* Function that does the actualy deleting - called by wp_cron
|
54 |
*/
|
55 |
function expirationdate_delete_expired_posts() {
|
56 |
global $wpdb;
|
57 |
+
postExpiratorTimezoneSetup();
|
58 |
$result = $wpdb->get_results('select post_id, meta_value from ' . $wpdb->postmeta . ' as postmeta, '.$wpdb->posts.' as posts where postmeta.post_id = posts.ID AND posts.post_status = "publish" AND postmeta.meta_key = "expiration-date" AND postmeta.meta_value <= "' . mktime() . '"');
|
59 |
if (!empty($result)) foreach ($result as $a) {
|
60 |
$post_result = $wpdb->get_var('select post_type from ' . $wpdb->posts .' where ID = '. $a->post_id);
|
75 |
}
|
76 |
}
|
77 |
}
|
78 |
+
if (postExpirator_is_wpmu())
|
79 |
+
add_action ('expirationdate_delete_'.$current_blog->blog_id, 'expirationdate_delete_expired_posts');
|
80 |
+
else
|
81 |
+
add_action ('expirationdate_delete', 'expirationdate_delete_expired_posts');
|
82 |
|
83 |
/**
|
84 |
* Called at plugin activation
|
92 |
update_option('expirationdateFooterContents',$expirationdateDefaultFooterContents);
|
93 |
update_option('expirationdateFooterStyle',$expirationdateDefaultFooterStyle);
|
94 |
update_option('expirationdateDisplayFooter',0);
|
95 |
+
postExpiratorTimezoneSetup();
|
96 |
|
97 |
+
if (postExpirator_is_wpmu())
|
98 |
+
wp_schedule_event(mktime(date('H'),0,0,date('m'),date('d'),date('Y')), 'postexpiratorminute', 'expirationdate_delete_'.$current_blog->blog_id);
|
99 |
+
else
|
100 |
+
wp_schedule_event(mktime(date('H'),0,0,date('m'),date('d'),date('Y')), 'postexpiratorminute', 'expirationdate_delete');
|
101 |
}
|
102 |
register_activation_hook (__FILE__, 'expirationdate_activate');
|
103 |
|
113 |
delete_option('expirationdateDisplayFooter');
|
114 |
delete_option('expirationdateFooterContents');
|
115 |
delete_option('expirationdateFooterStyle');
|
116 |
+
if (postExpirator_is_wpmu())
|
117 |
+
wp_clear_scheduled_hook('expirationdate_delete_'.$current_blog->blog_id);
|
118 |
+
else
|
119 |
+
wp_clear_scheduled_hook('expirationdate_delete');
|
120 |
}
|
121 |
register_deactivation_hook (__FILE__, 'expirationdate_deactivate');
|
122 |
|
124 |
* adds an 'Expires' column to the post display table.
|
125 |
*/
|
126 |
function expirationdate_add_column ($columns) {
|
127 |
+
$columns['expirationdate'] = 'Expires <br/><span style="font-size: 0.8em; font-weight: normal;">(YYYY/MM/DD HH:MM)</span>';
|
128 |
return $columns;
|
129 |
}
|
130 |
add_filter ('manage_posts_columns', 'expirationdate_add_column');
|
137 |
global $wpdb, $post;
|
138 |
$id = $post->ID;
|
139 |
if ($column_name === 'expirationdate') {
|
140 |
+
postExpiratorTimezoneSetup();
|
141 |
$query = "SELECT meta_value FROM $wpdb->postmeta WHERE meta_key = \"expiration-date\" AND post_id=$id";
|
142 |
$ed = $wpdb->get_var($query);
|
143 |
+
echo ($ed ? date('Y/m/d H:i',$ed) : "Never");
|
144 |
}
|
145 |
}
|
146 |
add_action ('manage_posts_custom_column', 'expirationdate_show_value');
|
167 |
*/
|
168 |
function expirationdate_meta_box($post) {
|
169 |
// Get default month
|
170 |
+
postExpiratorTimezoneSetup();
|
171 |
$expirationdatets = get_post_meta($post->ID,'expiration-date',true);
|
172 |
if (empty($expirationdatets)) {
|
173 |
$defaultmonth = date('F');
|
174 |
$defaultday = date('d');
|
175 |
$defaulthour = date('H');
|
176 |
$defaultyear = date('Y');
|
177 |
+
$defaultminute = date('i');
|
178 |
$disabled = 'disabled="disabled"';
|
179 |
} else {
|
180 |
$defaultmonth = date('F',$expirationdatets);
|
181 |
$defaultday = date('d',$expirationdatets);
|
182 |
$defaultyear = date('Y',$expirationdatets);
|
183 |
$defaulthour = date('H',$expirationdatets);
|
184 |
+
$defaultminute = date('i',$expirationdatets);
|
185 |
|
186 |
$enabled = ' checked="checked"';
|
187 |
$disabled = '';
|
196 |
$rv[] = '<th style="text-align: left;">Year</th>';
|
197 |
$rv[] = '<th style="text-align: left;"></th>';
|
198 |
$rv[] = '<th style="text-align: left;">Hour (24 Hour Format)</th>';
|
199 |
+
$rv[] = '<th style="text-align: left;">Minute</th>';
|
200 |
$rv[] = '</tr><tr>';
|
201 |
$rv[] = '<td>';
|
202 |
$rv[] = '<select name="expirationdate_month" id="expirationdate_month"'.$disabled.'">';
|
225 |
$rv[] = '</select>';
|
226 |
$rv[] = '</td><td>@</td><td>';
|
227 |
$rv[] = '<input type="text" id="expirationdate_hour" name="expirationdate_hour" value="'.$defaulthour.'" size="2"'.$disabled.'" />';
|
228 |
+
$rv[] = '</td><td>';
|
229 |
+
$rv[] = '<input type="text" id="expirationdate_minute" name="expirationdate_minute" value="'.$defaultminute.'" size="2"'.$disabled.'" />';
|
230 |
$rv[] = '<input type="hidden" name="expirationdate_formcheck" value="true" />';
|
231 |
$rv[] = '</td></tr></table>';
|
232 |
|
269 |
document.getElementById('expirationdate_day').disabled = false;
|
270 |
document.getElementById('expirationdate_year').disabled = false;
|
271 |
document.getElementById('expirationdate_hour').disabled = false;
|
272 |
+
document.getElementById('expirationdate_minute').disabled = false;
|
273 |
} else {
|
274 |
document.getElementById('expirationdate_month').disabled = true;
|
275 |
document.getElementById('expirationdate_day').disabled = true;
|
276 |
document.getElementById('expirationdate_year').disabled = true;
|
277 |
document.getElementById('expirationdate_hour').disabled = true;
|
278 |
+
document.getElementById('expirationdate_minute').disabled = true;
|
279 |
var enable = 'false';
|
280 |
}
|
281 |
|
301 |
function expirationdate_get_blog_url() {
|
302 |
global $current_blog;
|
303 |
$schema = ( isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on' ) ? 'https://' : 'http://';
|
304 |
+
|
305 |
+
if (postExpirator_is_wpmu())
|
306 |
+
echo $schema.$current_blog->domain.$current_blog->path;
|
307 |
+
else
|
308 |
+
echo get_bloginfo('siteurl').'/';
|
309 |
}
|
310 |
|
311 |
/**
|
319 |
$day = $_POST['expirationdate_day'];
|
320 |
$year = $_POST['expirationdate_year'];
|
321 |
$hour = $_POST['expirationdate_hour'];
|
322 |
+
$minute = $_POST['expirationdate_minute'];
|
323 |
|
324 |
if (isset($_POST['enable-expirationdate'])) {
|
325 |
+
postExpiratorTimezoneSetup();
|
326 |
// Format Date
|
327 |
+
$ts = mktime($hour,$minute,0,$month,$day,$year);
|
328 |
// Update Post Meta
|
329 |
delete_post_meta($id, 'expiration-date');
|
330 |
update_post_meta($id, 'expiration-date', $ts, true);
|
334 |
}
|
335 |
add_action('save_post','expirationdate_update_post_meta');
|
336 |
|
337 |
+
/**
|
338 |
+
* Build the menu for the options page
|
339 |
+
*/
|
340 |
+
function postExpiratorMenuTabs($tab) {
|
341 |
+
echo '<h2>'._('Post Expirator Options').'</h2>';
|
342 |
+
echo '<p>';
|
343 |
+
echo '<a href="'.admin_url('options-general.php?page=post-expirator.php&tab=general').'"'.(empty($tab) || $tab == 'general' ? ' style="font-weight: bold; text-decoration:none;"' : '').'>General Settings</a> | ';
|
344 |
+
echo '<a href="'.admin_url('options-general.php?page=post-expirator.php&tab=upgrade').'"'.($tab == 'upgrade' ? ' style="font-weight: bold; text-decoration:none;"' : '').'>Upgrade</a>';
|
345 |
+
echo '</p><hr/>';
|
346 |
+
}
|
347 |
+
|
348 |
+
/**
|
349 |
+
*
|
350 |
+
*/
|
351 |
+
function postExpiratorMenu() {
|
352 |
+
$tab = $_GET['tab'];
|
353 |
+
|
354 |
+
echo '<div class="wrap">';
|
355 |
+
postExpiratorMenuTabs($tab);
|
356 |
+
if (empty($tab) || $tab == 'general') {
|
357 |
+
postExpiratorMenuGeneral();
|
358 |
+
} elseif ($tab == 'upgrade') {
|
359 |
+
postExpiratorMenuUpgrade();
|
360 |
+
}
|
361 |
+
echo '</div>';
|
362 |
+
}
|
363 |
+
|
364 |
/**
|
365 |
* Hook's to add plugin page menu
|
366 |
*/
|
367 |
+
function postExpiratorPluginMenu() {
|
368 |
+
add_submenu_page('options-general.php','Post Expirator Options','Post Expirator',9,basename(__FILE__),'postExpiratorMenu');
|
369 |
}
|
370 |
+
add_action('admin_menu', 'postExpiratorPluginMenu');
|
371 |
|
372 |
/**
|
373 |
* Show the Expiration Date options page
|
374 |
*/
|
375 |
+
function postExpiratorMenuGeneral() {
|
376 |
|
377 |
if ($_POST['expirationdateSave']) {
|
378 |
update_option('expirationdateExpiredPostStatus',$_POST['expired-post-status']);
|
430 |
}
|
431 |
|
432 |
?>
|
|
|
|
|
433 |
<p>
|
434 |
The post expirator plugin sets a custom meta value, and then optionally allows you to select if you want the post
|
435 |
changed to a draft status or deleted when it expires.
|
525 |
<input type="submit" name="expirationdateSave" value="Save" />
|
526 |
</p>
|
527 |
</form>
|
|
|
528 |
<?php
|
529 |
}
|
530 |
|
531 |
+
function postExpiratorCronStatus() {
|
532 |
+
$names = array('expirationdate_delete','expirationdate_delete_');
|
533 |
+
// WPMU
|
534 |
+
if (postExpirator_is_wpmu()) {
|
535 |
+
global $current_blog;
|
536 |
+
$names[] = 'expirationdate_delete_'.$current_blog->blog_id;
|
537 |
+
}
|
538 |
+
$results = array();
|
539 |
+
foreach ( $names as $name ) {
|
540 |
+
array_push($results,wp_get_schedule($name));
|
541 |
+
}
|
542 |
+
|
543 |
+
foreach ( $results as $result ) {
|
544 |
+
if ($result == 'hourly') return false;
|
545 |
+
}
|
546 |
+
return true;
|
547 |
+
}
|
548 |
+
|
549 |
+
/**
|
550 |
+
* Reset all cron schedules for Post Expirator Plugin
|
551 |
+
*/
|
552 |
+
function postExpiratorResetCron() {
|
553 |
+
postExpiratorTimezoneSetup();
|
554 |
+
if (postExpirator_is_wpmu()) {
|
555 |
+
global $current_blog;
|
556 |
+
wp_clear_scheduled_hook('expirationdate_delete_'.$current_blog->blog_id);
|
557 |
+
wp_schedule_event(mktime(date('H'),0,0,date('m'),date('d'),date('Y')), 'postexpiratorminute', 'expirationdate_delete_'.$current_blog->blog_id);
|
558 |
+
} else {
|
559 |
+
wp_clear_scheduled_hook('expirationdate_delete');
|
560 |
+
wp_clear_scheduled_hook('expirationdate_delete_');
|
561 |
+
wp_schedule_event(mktime(date('H'),0,0,date('m'),date('d'),date('Y')), 'postexpiratorminute', 'expirationdate_delete');
|
562 |
+
}
|
563 |
+
}
|
564 |
+
|
565 |
+
function postExpiratorMenuUpgrade() {
|
566 |
+
if (isset($_POST['reset-cron-schedules'])) {
|
567 |
+
postExpiratorResetCron();
|
568 |
+
echo "<div id='message' class='updated fade'><p>Reset Cron Scheules!</p></div>";
|
569 |
+
}
|
570 |
+
|
571 |
+
$status = postExpiratorCronStatus();
|
572 |
+
if ($status)
|
573 |
+
$cronstatus = '<span style="color:green">OK</span>';
|
574 |
+
else
|
575 |
+
$cronstatus = '<span style="color:red">RESET NEEDED</span>';
|
576 |
+
|
577 |
+
?>
|
578 |
+
<form method="post" id="postExpiratorMenuUpgrade">
|
579 |
+
<h3>Upgrade</h3>
|
580 |
+
<table class="form-table">
|
581 |
+
<tr valign-"top">
|
582 |
+
<th scope="row"><label for="reset-cron-schedules">Reset Cron Schedules:</label></th>
|
583 |
+
<td>
|
584 |
+
<input type="submit" name="reset-cron-schedules" id="reset-cron-schedules" value="Reset" />
|
585 |
+
Status: <?php echo $cronstatus; ?>
|
586 |
+
<br/>
|
587 |
+
Resets the cron scheduler and removes any old or stray entries.
|
588 |
+
</td>
|
589 |
+
</tr>
|
590 |
+
</table>
|
591 |
+
</form>
|
592 |
+
<?php
|
593 |
+
}
|
594 |
+
|
595 |
+
|
596 |
// [postexpirator format="l F jS, Y g:ia" tz="foo"]
|
597 |
function postexpirator_shortcode($atts) {
|
598 |
global $post;
|
readme.txt
CHANGED
@@ -1,11 +1,11 @@
|
|
1 |
=== Post Expirator ===
|
2 |
Contributors: axelseaa
|
3 |
-
Tags: expire, posts, pages
|
4 |
-
Requires at least: 2.
|
5 |
-
Tested up to:
|
6 |
-
Stable tag:
|
7 |
|
8 |
-
Allows you to add an expiration date (
|
9 |
|
10 |
== Description ==
|
11 |
|
@@ -23,6 +23,8 @@ default display format. See the [PHP Date Function](http://us2.php.net/manual/e
|
|
23 |
* dateformat - format set here will override the value set on the settings page
|
24 |
* timeformat - format set here will override the value set on the settings page
|
25 |
|
|
|
|
|
26 |
== Wordpress MU ==
|
27 |
|
28 |
This plugin is compataibile with Wordpress MU 1.5+, however currently it will not work in the mu-plugins folder due to the plugin activation
|
@@ -41,6 +43,14 @@ This section describes how to install the plugin and get it working.
|
|
41 |
|
42 |
== Changelog ==
|
43 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
44 |
**Version 1.3.1**
|
45 |
|
46 |
* Fixed sporadic issue of expired posts not being removed
|
1 |
=== Post Expirator ===
|
2 |
Contributors: axelseaa
|
3 |
+
Tags: expire, posts, pages, schedule
|
4 |
+
Requires at least: 2.8
|
5 |
+
Tested up to: 3.0
|
6 |
+
Stable tag: 1.4
|
7 |
|
8 |
+
Allows you to add an expiration date (minute) to posts which you can configure to either delete the post or change it to a draft.
|
9 |
|
10 |
== Description ==
|
11 |
|
23 |
* dateformat - format set here will override the value set on the settings page
|
24 |
* timeformat - format set here will override the value set on the settings page
|
25 |
|
26 |
+
Note on upgrading to 1.4: After upgrading, you may need to reset the cron schedules. Following onscreen notice if prompted. Previously scheduled posts will not be updated, they will be deleted referncing the old timezone setting. If you wish to update them, you will need to manually update the expiration time.
|
27 |
+
|
28 |
== Wordpress MU ==
|
29 |
|
30 |
This plugin is compataibile with Wordpress MU 1.5+, however currently it will not work in the mu-plugins folder due to the plugin activation
|
43 |
|
44 |
== Changelog ==
|
45 |
|
46 |
+
**Version 1.4**
|
47 |
+
|
48 |
+
NOTE: After upgrading, you may need to reset the cron schedules. Following onscreen notice if prompted. Previously scheduled posts will not be updated, they will be deleted referncing the old timezone setting. If you wish to update them, you will need to manually update the expiration time.
|
49 |
+
|
50 |
+
* Fixed compatability issues with Wordpress - plugin was originally coded for WPMU - should now work on both
|
51 |
+
* Added ability to schedule post expiration by minute
|
52 |
+
* Fixed timezone - now uses the same timezone as configured by the blog
|
53 |
+
|
54 |
**Version 1.3.1**
|
55 |
|
56 |
* Fixed sporadic issue of expired posts not being removed
|