Post Expirator - Version 2.1.1

Version Description

Download this release

Release Info

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

Code changes from version 2.1.0 to 2.1.1

Files changed (2) hide show
  1. post-expirator.php +52 -10
  2. readme.txt +6 -1
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: 2.1.0
8
Author URI: http://postexpirator.tuxdocs.net/
9
Translation: Thierry (http://palijn.info)
10
Text Domain: post-expirator
@@ -18,7 +18,7 @@ function postExpirator_init() {
18
add_action('plugins_loaded', 'postExpirator_init');
19
20
// Default Values
21
- define('POSTEXPIRATOR_VERSION','2.1.0');
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'));
@@ -47,12 +47,26 @@ add_action('admin_notices','postExpirationAdminNotice');
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');
55
- add_filter ('manage_pages_columns', 'expirationdate_add_column');
56
57
/**
58
* fills the 'Expires' column of the post display table.
@@ -73,10 +87,13 @@ add_action ('manage_pages_custom_column', 'expirationdate_show_value');
73
*/
74
function expirationdate_meta_custom() {
75
$custom_post_types = get_post_types();
76
foreach ($custom_post_types as $t) {
77
- add_meta_box('expirationdatediv', __('Post Expirator','post-expirator'), 'expirationdate_meta_box', $t, 'side', 'core');
78
}
79
- add_meta_box('expirationdatediv', __('Post Expirator','post-expirator'), 'expirationdate_meta_box', 'page', 'side', 'core');
80
}
81
add_action ('add_meta_boxes','expirationdate_meta_custom');
82
@@ -106,7 +123,7 @@ function expirationdate_meta_box($post) {
106
$tz = get_option('timezone_string');
107
if ( $tz ) date_default_timezone_set( $tz );
108
109
- $ts = gmmktime() + (strtotime($custom) - time());
110
111
if ( $tz ) date_default_timezone_set('UTC');
112
}
@@ -231,7 +248,8 @@ function expirationdate_meta_box($post) {
231
} elseif (sizeof($taxonomies) > 1 && !isset($defaults['taxonomy'])) {
232
echo '<p>'.__('More than 1 heirachical taxonomy detected. You must assign a default taxonomy on the settings screen.','post-expirator').'</p>';
233
} else {
234
- $taxonomy = isset($defaults['taxonomy']) ? $defaults['taxonomy'] : $taxonomies[0];
235
wp_terms_checklist(0, array( 'taxonomy' => $taxonomy, 'walker' => $walker, 'selected_cats' => $categories, 'checked_ontop' => false ) );
236
echo '<input type="hidden" name="taxonomy-heirarchical" value="'.$taxonomy.'" />';
237
}
@@ -785,6 +803,9 @@ function postExpiratorMenuDefaults() {
785
if (isset($_POST['expirationdate_taxonomy-'.$type])) {
786
$defaults[$type]['taxonomy'] = $_POST['expirationdate_taxonomy-'.$type];
787
}
788
789
//Save Settings
790
update_option('expirationdateDefaults'.ucfirst($type),$defaults[$type]);
@@ -807,9 +828,25 @@ function postExpiratorMenuDefaults() {
807
$expiredautoenabled = '';
808
$expiredautodisabled = 'checked = "checked"';
809
}
810
print '<h4>Expiration values for: '.$type.'</h4>';
811
?>
812
<table class="form-table">
813
<tr valign-"top">
814
<th scope="row"><label for="expirationdate_expiretype-<?php echo $type ?>"><?php _e('How to expire:','post-expirator'); ?></label></th>
815
<td>
@@ -1123,6 +1160,11 @@ function postexpirator_upgrade() {
1123
1124
update_option('postexpiratorVersion',POSTEXPIRATOR_VERSION);
1125
}
1126
}
1127
}
1128
add_action('admin_init','postexpirator_upgrade');
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.1.1
8
Author URI: http://postexpirator.tuxdocs.net/
9
Translation: Thierry (http://palijn.info)
10
Text Domain: post-expirator
18
add_action('plugins_loaded', 'postExpirator_init');
19
20
// Default Values
21
+ define('POSTEXPIRATOR_VERSION','2.1.1');
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'));
47
/**
48
* adds an 'Expires' column to the post display table.
49
*/
50
+ function expirationdate_add_column ($columns,$type) {
51
+ $defaults = get_option('expirationdateDefaults'.ucfirst($type));
52
+ if (!isset($defaults['activeMetaBox']) || $defaults['activeMetaBox'] == 'active') {
53
+ $columns['expirationdate'] = __('Expires','post-expirator');
54
+ }
55
+ return $columns;
56
+ }
57
+ add_filter ('manage_posts_columns', 'expirationdate_add_column', 10, 2);
58
+
59
+ /**
60
+ * adds an 'Expires' column to the page display table.
61
+ */
62
+ function expirationdate_add_column_page ($columns) {
63
+ $defaults = get_option('expirationdateDefaultsPage');
64
+ if (!isset($defaults['activeMetaBox']) || $defaults['activeMetaBox'] == 'active') {
65
+ $columns['expirationdate'] = __('Expires','post-expirator');
66
+ }
67
return $columns;
68
}
69
+ add_filter ('manage_pages_columns', 'expirationdate_add_column_page');
70
71
/**
72
* fills the 'Expires' column of the post display table.
87
*/
88
function expirationdate_meta_custom() {
89
$custom_post_types = get_post_types();
90
+ array_push($custom_post_types,'page');
91
foreach ($custom_post_types as $t) {
92
+ $defaults = get_option('expirationdateDefaults'.ucfirst($t));
93
+ if (!isset($defaults['activeMetaBox']) || $defaults['activeMetaBox'] == 'active') {
94
+ add_meta_box('expirationdatediv', __('Post Expirator','post-expirator'), 'expirationdate_meta_box', $t, 'side', 'core');
95
+ }
96
}
97
}
98
add_action ('add_meta_boxes','expirationdate_meta_custom');
99
123
$tz = get_option('timezone_string');
124
if ( $tz ) date_default_timezone_set( $tz );
125
126
+ $ts = time() + (strtotime($custom) - time());
127
128
if ( $tz ) date_default_timezone_set('UTC');
129
}
248
} elseif (sizeof($taxonomies) > 1 && !isset($defaults['taxonomy'])) {
249
echo '<p>'.__('More than 1 heirachical taxonomy detected. You must assign a default taxonomy on the settings screen.','post-expirator').'</p>';
250
} else {
251
+ $keys = array_keys($taxonomies);
252
+ $taxonomy = isset($defaults['taxonomy']) ? $defaults['taxonomy'] : $keys[0];
253
wp_terms_checklist(0, array( 'taxonomy' => $taxonomy, 'walker' => $walker, 'selected_cats' => $categories, 'checked_ontop' => false ) );
254
echo '<input type="hidden" name="taxonomy-heirarchical" value="'.$taxonomy.'" />';
255
}
803
if (isset($_POST['expirationdate_taxonomy-'.$type])) {
804
$defaults[$type]['taxonomy'] = $_POST['expirationdate_taxonomy-'.$type];
805
}
806
+ if (isset($_POST['expirationdate_activemeta-'.$type])) {
807
+ $defaults[$type]['activeMetaBox'] = $_POST['expirationdate_activemeta-'.$type];
808
+ }
809
810
//Save Settings
811
update_option('expirationdateDefaults'.ucfirst($type),$defaults[$type]);
828
$expiredautoenabled = '';
829
$expiredautodisabled = 'checked = "checked"';
830
}
831
+ if (isset($defaults['activeMetaBox']) && $defaults['activeMetaBox'] == 'inactive') {
832
+ $expiredactivemetaenabled = '';
833
+ $expiredactivemetadisabled = 'checked = "checked"';
834
+ } else {
835
+ $expiredactivemetaenabled = 'checked = "checked"';
836
+ $expiredactivemetadisabled = '';
837
+ }
838
print '<h4>Expiration values for: '.$type.'</h4>';
839
?>
840
<table class="form-table">
841
+ <tr valign-"top">
842
+ <th scope="row"><label for="expirationdate_activemeta-<?php echo $type ?>"><?php _e('Active:','post-expirator');?></label></th>
843
+ <td>
844
+ <input type="radio" name="expirationdate_activemeta-<?php echo $type ?>" id="expirationdate_activemeta-true-<?php echo $type ?>" value="active" <?php echo $expiredactivemetaenabled ?>/> <label for="expired-active-meta-true"><?php _e('Active','post-expirator');?></label>
845
+ <input type="radio" name="expirationdate_activemeta-<?php echo $type ?>" id="expirationdate_activemeta-false-<?php echo $type ?>" value="inactive" <?php echo $expiredactivemetadisabled ?>/> <label for="expired-active-meta-false"><?php _e('Inactive','post-expirator');?></label>
846
+ <br/>
847
+ <?php _e('Select whether the post expirator meta box is active for this post type.','post-expirator');?>
848
+ </td>
849
+ </tr>
850
<tr valign-"top">
851
<th scope="row"><label for="expirationdate_expiretype-<?php echo $type ?>"><?php _e('How to expire:','post-expirator'); ?></label></th>
852
<td>
1160
1161
update_option('postexpiratorVersion',POSTEXPIRATOR_VERSION);
1162
}
1163
+
1164
+ if (version_compare($version,'2.1.1') == -1) {
1165
+
1166
+ update_option('postexpiratorVersion',POSTEXPIRATOR_VERSION);
1167
+ }
1168
}
1169
}
1170
add_action('admin_init','postexpirator_upgrade');
readme.txt CHANGED
@@ -3,7 +3,7 @@ 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.1.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,6 +47,11 @@ This section describes how to install the plugin and get it working.
47
48
== Changelog ==
49
50
**Version 2.1.0**
51
52
* New: Added support for heirarchical custom taxonomy
3
Tags: expire, posts, pages, schedule
4
Requires at least: 3.2
5
Tested up to: 3.5.1
6
+ Stable tag: 2.1.1
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.1.1**
51
+
52
+ * FIX: Fixed php warning issue cause when post type defaults are not set
53
+ * NEW: Added the option to disable post expirator for certain post types if desired
54
+
55
**Version 2.1.0**
56
57
* New: Added support for heirarchical custom taxonomy