Post Expirator - Version 2.2.0

Version Description

Quick Edit/Bulk Edit Added. Sortable Expiration Date Fields Added

Download this release

Release Info

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

Code changes from version 2.1.4 to 2.2.0

Files changed (4) hide show
  1. admin-edit.js +89 -0
  2. post-expirator.php +250 -55
  3. readme.txt +12 -1
  4. style.css +3 -0
admin-edit.js ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ (function($) {
2
+
3
+ // we create a copy of the WP inline edit post function
4
+ var $wp_inline_edit = inlineEditPost.edit;
5
+
6
+ // and then we overwrite the function with our own code
7
+ inlineEditPost.edit = function( id ) {
8
+
9
+ // "call" the original WP edit function
10
+ // we don't want to leave WordPress hanging
11
+ $wp_inline_edit.apply( this, arguments );
12
+
13
+ // now we take care of our business
14
+
15
+ // get the post ID
16
+ var $post_id = 0;
17
+ if ( typeof( id ) == 'object' ) {
18
+ $post_id = parseInt( this.getId( id ) );
19
+ }
20
+
21
+ if ( $post_id > 0 ) {
22
+ // define the edit row
23
+ var $edit_row = $( '#edit-' + $post_id );
24
+
25
+ // get / set year
26
+ var $year = $( '#expirationdate_year-' + $post_id ).text();
27
+ $edit_row.find( 'input[name="expirationdate_year"]' ).val( $year );
28
+
29
+ // get / set month
30
+ var $month = $( '#expirationdate_month-' + $post_id ).text();
31
+ $edit_row.find( 'select[name="expirationdate_month"]' ).val( $month );
32
+
33
+ // get / set day
34
+ var $day = $( '#expirationdate_day-' + $post_id ).text();
35
+ $edit_row.find( 'input[name="expirationdate_day"]' ).val( $day );
36
+
37
+ // get / set hour
38
+ var $hour = $( '#expirationdate_hour-' + $post_id ).text();
39
+ $edit_row.find( 'input[name="expirationdate_hour"]' ).val( $hour );
40
+
41
+ // get / set minute
42
+ var $minute = $( '#expirationdate_minute-' + $post_id ).text();
43
+ $edit_row.find( 'input[name="expirationdate_minute"]' ).val( $minute );
44
+
45
+ var $enabled = $( '#expirationdate_enabled-' + $post_id ).text();
46
+ if ($enabled == "true") {
47
+ $edit_row.find( 'input[name="enable-expirationdate"]' ).prop( 'checked', true );
48
+ }
49
+ }
50
+ };
51
+
52
+ $( '#bulk_edit' ).live( 'click', function() {
53
+
54
+ // define the bulk edit row
55
+ var $bulk_row = $( '#bulk-edit' );
56
+
57
+ // get the selected post ids that are being edited
58
+ var $post_ids = new Array();
59
+ $bulk_row.find( '#bulk-titles' ).children().each( function() {
60
+ $post_ids.push( $( this ).attr( 'id' ).replace( /^(ttle)/i, '' ) );
61
+ });
62
+
63
+ // get the custom fields
64
+ var $expirationdate_month = $bulk_row.find( 'select[name="expirationdate_month"]' ).val();
65
+ var $expirationdate_day = $bulk_row.find( 'input[name="expirationdate_day"]' ).val();
66
+ var $expirationdate_year = $bulk_row.find( 'input[name="expirationdate_year"]' ).val();
67
+ var $expirationdate_hour = $bulk_row.find( 'input[name="expirationdate_hour"]' ).val();
68
+ var $expirationdate_minute = $bulk_row.find( 'input[name="expirationdate_minute"]' ).val();
69
+
70
+ // save the data
71
+ $.ajax({
72
+ url: ajaxurl, // this is a variable that WordPress has already defined for us
73
+ type: 'POST',
74
+ async: false,
75
+ cache: false,
76
+ data: {
77
+ action: 'manage_wp_posts_using_bulk_quick_save_bulk_edit', // this is the name of our WP AJAX function that we'll set up next
78
+ post_ids: $post_ids, // and these are the 2 parameters we're passing to our function
79
+ expirationdate_month: $expirationdate_month,
80
+ expirationdate_day: $expirationdate_day,
81
+ expirationdate_year: $expirationdate_year,
82
+ expirationdate_hour: $expirationdate_hour,
83
+ expirationdate_minute: $expirationdate_minute
84
+ }
85
+ });
86
+
87
+ });
88
+
89
+ })(jQuery);
post-expirator.php CHANGED
@@ -4,9 +4,8 @@ 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.4
8
  Author URI: http://postexpirator.tuxdocs.net/
9
- Translation: Thierry (http://palijn.info)
10
  Text Domain: post-expirator
11
  */
12
 
@@ -18,7 +17,7 @@ function postExpirator_init() {
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'));
@@ -39,14 +38,15 @@ add_filter('plugin_action_links', 'postExpirator_plugin_action_links', 10, 2);
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,$type) {
51
  $defaults = get_option('expirationdateDefaults'.ucfirst($type));
52
  if (!isset($defaults['activeMetaBox']) || $defaults['activeMetaBox'] == 'active') {
@@ -54,11 +54,47 @@ function expirationdate_add_column ($columns,$type) {
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') {
@@ -66,21 +102,135 @@ function expirationdate_add_column_page ($columns) {
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.
73
  */
 
 
74
  function expirationdate_show_value ($column_name) {
75
  global $post;
76
  $id = $post->ID;
77
  if ($column_name === 'expirationdate') {
78
  $ed = get_post_meta($id,'_expiration-date',true);
79
  echo ($ed ? get_date_from_gmt(gmdate('Y-m-d H:i:s',$ed),get_option('date_format').' '.get_option('time_format')) : __("Never",'post-expirator'));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
80
  }
81
  }
82
- add_action ('manage_posts_custom_column', 'expirationdate_show_value');
83
- add_action ('manage_pages_custom_column', 'expirationdate_show_value');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
84
 
85
  /**
86
  * Adds hooks to get the meta box added to pages and custom post types
@@ -100,7 +250,7 @@ add_action ('add_meta_boxes','expirationdate_meta_custom');
100
  /**
101
  * Actually adds the meta box
102
  */
103
- function expirationdate_meta_box($post) {
104
  // Get default month
105
  $expirationdatets = get_post_meta($post->ID,'_expiration-date',true);
106
  $firstsave = get_post_meta($post->ID,'_expiration-date-status',true);
@@ -122,9 +272,7 @@ function expirationdate_meta_box($post) {
122
  else {
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
  }
130
  $defaultmonth = get_date_from_gmt(gmdate('Y-m-d H:i:s',$ts),'m');
@@ -132,7 +280,7 @@ function expirationdate_meta_box($post) {
132
  $defaultyear = get_date_from_gmt(gmdate('Y-m-d H:i:s',$ts),'Y');;
133
  $defaulthour = get_date_from_gmt(gmdate('Y-m-d H:i:s',$ts),'H');
134
  $defaultminute = get_date_from_gmt(gmdate('Y-m-d H:i:s',$ts),'i');
135
- }
136
 
137
  $enabled = '';
138
  $disabled = ' disabled="disabled"';
@@ -173,10 +321,10 @@ function expirationdate_meta_box($post) {
173
  $rv[] = '<th style="text-align: left;">'.__('Month','post-expirator').'</th>';
174
  $rv[] = '<th style="text-align: left;">'.__('Day','post-expirator').'</th>';
175
  $rv[] = '</tr><tr>';
176
- $rv[] = '<td>';
177
  $rv[] = '<select name="expirationdate_year" id="expirationdate_year"'.$disabled.'>';
178
  $currentyear = date('Y');
179
-
180
  if ($defaultyear < $currentyear) $currentyear = $defaultyear;
181
 
182
  for($i = $currentyear; $i < $currentyear + 8; $i++) {
@@ -198,7 +346,7 @@ function expirationdate_meta_box($post) {
198
  $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>';
199
  }
200
 
201
- $rv[] = '</select>';
202
  $rv[] = '</td><td>';
203
  $rv[] = '<input type="text" id="expirationdate_day" name="expirationdate_day" value="'.$defaultday.'" size="2"'.$disabled.' />,';
204
  $rv[] = '</td></tr><tr>';
@@ -304,14 +452,13 @@ function expirationdate_ajax_add_meta(expireenable) {
304
  }
305
  var enable = 'false';
306
  }
307
-
308
  return true;
309
  }
310
  function expirationdate_toggle_category(id) {
311
  if (id.options[id.selectedIndex].value == 'category') {
312
  jQuery('#expired-category-selection').show();
313
  } else if (id.options[id.selectedIndex].value == 'category-add') {
314
- jQuery('#expired-category-selection').show(); //TEMP
315
  } else if (id.options[id.selectedIndex].value == 'category-remove') {
316
  jQuery('#expired-category-selection').show(); //TEMP
317
  } else {
@@ -336,7 +483,7 @@ add_action('admin_head', 'expirationdate_js_admin_header' );
336
  * Get correct URL (HTTP or HTTPS)
337
  */
338
  function expirationdate_get_blog_url() {
339
- if (is_multisite())
340
  echo network_home_url('/');
341
  else
342
  echo home_url('/');
@@ -345,6 +492,7 @@ function expirationdate_get_blog_url() {
345
  /**
346
  * Called when post is saved - stores expiration-date meta value
347
  */
 
348
  function expirationdate_update_post_meta($id) {
349
  // don't run the echo if this is an auto save
350
  if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE )
@@ -355,8 +503,10 @@ function expirationdate_update_post_meta($id) {
355
  if ( $posttype == 'revision' )
356
  return;
357
 
358
- if (!isset($_POST['expirationdate_formcheck']))
359
- return;
 
 
360
 
361
  if (isset($_POST['enable-expirationdate'])) {
362
  $default = get_option('expirationdateDefaultDate',POSTEXPIRATOR_EXPIREDEFAULT);
@@ -390,13 +540,12 @@ function expirationdate_update_post_meta($id) {
390
  }
391
  }
392
  }
393
-
394
  _scheduleExpiratorEvent($id,$ts,$opts);
395
  } else {
396
  _unscheduleExpiratorEvent($id);
397
  }
398
  }
399
- add_action('save_post','expirationdate_update_post_meta');
400
 
401
  function _scheduleExpiratorEvent($id,$ts,$opts) {
402
  $debug = postExpiratorDebug(); //check for/load debug
@@ -405,8 +554,8 @@ function _scheduleExpiratorEvent($id,$ts,$opts) {
405
  wp_clear_scheduled_hook('postExpiratorExpire',array($id)); //Remove any existing hooks
406
  if (POSTEXPIRATOR_DEBUG) $debug->save(array('message' => $id.' -> EXISTING FOUND - UNSCHEDULED'));
407
  }
408
-
409
- wp_schedule_single_event($ts,'postExpiratorExpire',array($id));
410
  if (POSTEXPIRATOR_DEBUG) $debug->save(array('message' => $id.' -> SCHEDULED at '.date_i18n('r',$ts).' '.'('.$ts.') with options '.print_r($opts,true)));
411
 
412
  // Update Post Meta
@@ -417,7 +566,7 @@ function _scheduleExpiratorEvent($id,$ts,$opts) {
417
 
418
  function _unscheduleExpiratorEvent($id) {
419
  $debug = postExpiratorDebug(); // check for/load debug
420
- delete_post_meta($id, '_expiration-date');
421
  delete_post_meta($id, '_expiration-date-options');
422
 
423
  // Delete Scheduled Expiration
@@ -438,7 +587,7 @@ function _unscheduleExpiratorEvent($id) {
438
  function postExpiratorExpire($id) {
439
  $debug = postExpiratorDebug(); //check for/load debug
440
 
441
- if (empty($id)) {
442
  if (POSTEXPIRATOR_DEBUG) $debug->save(array('message' => 'No Post ID found - exiting'));
443
  return false;
444
  }
@@ -538,7 +687,7 @@ function postExpiratorExpire($id) {
538
  $debug->save(array('message' => $id.' -> CATEGORIES ADDED '.print_r(_postExpiratorGetCatNames($category),true)));
539
  $debug->save(array('message' => $id.' -> CATEGORIES COMPLETE '.print_r(_postExpiratorGetCatNames($category),true)));
540
  }
541
- }
542
  }
543
  } else {
544
  if (POSTEXPIRATOR_DEBUG) $debug->save(array('message' => $id.' -> CATEGORIES MISSING '.$expireType.' '.print_r($postoptions,true)));
@@ -551,7 +700,7 @@ function postExpiratorExpire($id) {
551
  foreach ($cats as $cat) {
552
  if (!in_array($cat,$category)) {
553
  $merged[] = $cat;
554
- }
555
  }
556
  if (wp_update_post(array('ID' => $id, 'post_category' => $merged)) == 0) {
557
  if (POSTEXPIRATOR_DEBUG) $debug->save(array('message' => $id.' -> FAILED '.$expireType.' '.print_r($postoptions,true)));
@@ -579,7 +728,7 @@ function postExpiratorExpire($id) {
579
  $debug->save(array('message' => $id.' -> CATEGORIES REMOVED '.print_r(_postExpiratorGetCatNames($category),true)));
580
  $debug->save(array('message' => $id.' -> CATEGORIES COMPLETE '.print_r(_postExpiratorGetCatNames($category),true)));
581
  }
582
- }
583
  }
584
  } else {
585
  if (POSTEXPIRATOR_DEBUG) $debug->save(array('message' => $id.' -> CATEGORIES MISSING '.$expireType.' '.print_r($postoptions,true)));
@@ -594,7 +743,7 @@ function _postExpiratorGetCatNames($cats) {
594
  $out[$cat] = get_the_category_by_id($cat);
595
  }
596
  return $out;
597
- }
598
 
599
  /**
600
  * Build the menu for the options page
@@ -840,6 +989,8 @@ function postExpiratorMenuDefaults() {
840
  </p>
841
  <?php
842
  foreach ($types as $type) {
 
 
843
  $defaults = get_option('expirationdateDefaults'.ucfirst($type));
844
  if (isset($defaults['autoEnable']) && $defaults['autoEnable'] == 1) {
845
  $expiredautoenabled = 'checked = "checked"';
@@ -854,8 +1005,10 @@ function postExpiratorMenuDefaults() {
854
  } else {
855
  $expiredactivemetaenabled = 'checked = "checked"';
856
  $expiredactivemetadisabled = '';
857
- }
858
- print '<h4>Expiration values for: '.$type.'</h4>';
 
 
859
  ?>
860
  <table class="form-table">
861
  <tr valign-"top">
@@ -871,7 +1024,7 @@ function postExpiratorMenuDefaults() {
871
  <th scope="row"><label for="expirationdate_expiretype-<?php echo $type ?>"><?php _e('How to expire:','post-expirator'); ?></label></th>
872
  <td>
873
  <?php echo _postExpiratorExpireType(array('name'=>'expirationdate_expiretype-'.$type,'selected' => $defaults['expireType'])); ?>
874
- </select>
875
  <br/>
876
  <?php _e('Select the default expire action for the post type.','post-expirator');?>
877
  </td>
@@ -889,12 +1042,10 @@ function postExpiratorMenuDefaults() {
889
  <th scope="row"><label for="expirationdate_taxonomy-<?php echo $type ?>"><?php _e('Taxonomy (hierarchical):','post-expirator'); ?></label></th>
890
  <td>
891
  <?php echo _postExpiratorTaxonomy(array('type' => $type, 'name'=>'expirationdate_taxonomy-'.$type,'selected' => $defaults['taxonomy'])); ?>
892
- </select>
893
- <br/>
894
- <?php _e('Select the hierarchical taxonomy to be used for "category" based expiration.','post-expirator');?>
895
  </td>
896
  </tr>
897
  </table>
 
898
  <?php
899
  }
900
  ?>
@@ -930,7 +1081,7 @@ function postExpiratorMenuDiagnostics() {
930
  <form method="post" id="postExpiratorMenuUpgrade">
931
  <?php wp_nonce_field('postExpiratorMenuDiagnostics','_postExpiratorMenuDiagnostics_nonce'); ?>
932
  <h3><?php _e('Advanced Diagnostics','post-expirator');?></h3>
933
- <table class="form-table">
934
  <tr valign-"top">
935
  <th scope="row"><label for="postexpirator-log"><?php _e('Post Expirator Debug Logging:','post-expirator');?></label></th>
936
  <td>
@@ -969,7 +1120,6 @@ function postExpiratorMenuDiagnostics() {
969
  <th scope="row"><label for="cron-schedule"><?php _e('Current Cron Schedule:','post-expirator');?></label></th>
970
  <td>
971
  <?php _e('The below table will show all currently scheduled cron events with the next run time.','post-expirator');?><br/>
972
-
973
  <table>
974
  <tr>
975
  <th style="width: 200px;"><?php _e('Date','post-expirator');?></th>
@@ -986,7 +1136,7 @@ function postExpiratorMenuDiagnostics() {
986
  $arrkey = array_keys($eventvalue);
987
  print '<td>';
988
  foreach ($arrkey as $eventguid) {
989
- print '<table><tr>';
990
  if (empty($eventvalue[$eventguid]['args'])) {
991
  print '<td>No Arguments</td>';
992
  } else {
@@ -1042,15 +1192,15 @@ function postexpirator_shortcode($atts) {
1042
 
1043
  if (empty($dateformat)) {
1044
  global $expirationdateDefaultDateFormat;
1045
- $dateformat = $expirationdateDefaultDateFormat;
1046
  }
1047
 
1048
  if (empty($timeformat)) {
1049
  global $expirationdateDefaultTimeFormat;
1050
- $timeformat = $expirationdateDefaultTimeFormat;
1051
  }
1052
 
1053
- if ($type == 'full')
1054
  $format = $dateformat.' '.$timeformat;
1055
  else if ($type == 'date')
1056
  $format = $dateformat;
@@ -1077,7 +1227,7 @@ function postexpirator_add_footer($text) {
1077
  $timeformat = get_option('expirationdateDefaultTimeFormat',POSTEXPIRATOR_TIMEFORMAT);
1078
  $expirationdateFooterContents = get_option('expirationdateFooterContents',POSTEXPIRATOR_FOOTERCONTENTS);
1079
  $expirationdateFooterStyle = get_option('expirationdateFooterStyle',POSTEXPIRATOR_FOOTERSTYLE);
1080
-
1081
  $search = array(
1082
  'EXPIRATIONFULL',
1083
  'EXPIRATIONDATE',
@@ -1160,7 +1310,7 @@ function postexpirator_upgrade() {
1160
  $opts['expireType'] = strtolower(get_option('expirationdateExpiredPostStatus','Draft'));
1161
  }
1162
 
1163
- $cat = get_post_meta($result->post_id,'_expiration-date-category',true);
1164
  if ((isset($cat) && !empty($cat))) {
1165
  $opts['category'] = $cat;
1166
  $opts['expireType'] = 'category';
@@ -1191,24 +1341,26 @@ function postexpirator_upgrade() {
1191
  wp_clear_scheduled_hook('expirationdate_delete_'.$current_blog->blog_id);
1192
  } else
1193
  wp_clear_scheduled_hook('expirationdate_delete');
1194
-
1195
  update_option('postexpiratorVersion',POSTEXPIRATOR_VERSION);
1196
  }
1197
 
1198
  if (version_compare($version,'2.1.0') == -1) {
1199
-
1200
  update_option('postexpiratorVersion',POSTEXPIRATOR_VERSION);
1201
  }
1202
 
1203
  if (version_compare($version,'2.1.1') == -1) {
1204
-
 
 
 
1205
  update_option('postexpiratorVersion',POSTEXPIRATOR_VERSION);
1206
  }
1207
  }
1208
  }
1209
  add_action('admin_init','postexpirator_upgrade');
1210
 
1211
- /**
1212
  * Called at plugin activation
1213
  */
1214
  function postexpirator_activate () {
@@ -1284,7 +1436,7 @@ class Walker_PostExpirator_Category_Checklist extends Walker {
1284
  $class = in_array( $category->term_id, $popular_cats ) ? ' class="expirator-category"' : '';
1285
  $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>';
1286
  }
1287
-
1288
  function end_el(&$output, $category, $depth = 0, $args = array()) {
1289
  $output .= "</li>\n";
1290
  }
@@ -1311,7 +1463,7 @@ function _postExpiratorExpireType($opts) {
1311
  $rv[] = '<option value="category-remove" '. ($selected == 'category-remove' ? 'selected="selected"' : '') . '>'.__('Category: Remove','post-expirator').'</option>';
1312
  }
1313
  $rv[] = '</select>';
1314
- return implode("<br/>/n",$rv);
1315
  }
1316
 
1317
  function _postExpiratorTaxonomy($opts) {
@@ -1330,11 +1482,54 @@ function _postExpiratorTaxonomy($opts) {
1330
  if (empty($taxonomies)) $disabled = true;
1331
 
1332
  $rv = array();
1333
- $rv[] = '<select name="'.$name.'" id="'.$id.'"'.($disabled == true ? ' disabled="disabled"' : '').' onchange="'.$onchange.'">';
1334
- foreach ($taxonomies as $taxonomy) {
1335
- $rv[] = '<option value="'.$taxonomy->name.'" '. ($selected == $taxonomy->name ? 'selected="selected"' : '') . '>'.$taxonomy->name.'</option>';
 
 
 
 
 
 
 
1336
  }
 
 
1337
 
1338
- $rv[] = '</select>';
1339
- return implode("<br/>/n",$rv);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1340
  }
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.2.0
8
  Author URI: http://postexpirator.tuxdocs.net/
 
9
  Text Domain: post-expirator
10
  */
11
 
17
  add_action('plugins_loaded', 'postExpirator_init');
18
 
19
  // Default Values
20
+ define('POSTEXPIRATOR_VERSION','2.2.0');
21
  define('POSTEXPIRATOR_DATEFORMAT',__('l F jS, Y','post-expirator'));
22
  define('POSTEXPIRATOR_TIMEFORMAT',__('g:ia','post-expirator'));
23
  define('POSTEXPIRATOR_FOOTERCONTENTS',__('Post expires at EXPIRATIONTIME on EXPIRATIONDATE','post-expirator'));
38
  /**
39
  * Add admin notice hook if cron schedule needs to be reset
40
  */
41
+ add_action('admin_notices','postExpirationAdminNotice');
42
  function postExpirationAdminNotice() {
43
  // Currently not used
44
  }
 
45
 
46
  /**
47
  * adds an 'Expires' column to the post display table.
48
  */
49
+ add_filter ('manage_posts_columns', 'expirationdate_add_column', 10, 2);
50
  function expirationdate_add_column ($columns,$type) {
51
  $defaults = get_option('expirationdateDefaults'.ucfirst($type));
52
  if (!isset($defaults['activeMetaBox']) || $defaults['activeMetaBox'] == 'active') {
54
  }
55
  return $columns;
56
  }
57
+
58
+ add_action( 'init', 'init_managesortablecolumns', 100 );
59
+ function init_managesortablecolumns (){
60
+ $post_types = get_post_types(array('public'=>true));
61
+ foreach( $post_types as $post_type ){
62
+ add_filter( 'manage_edit-' . $post_type . '_sortable_columns', 'expirationdate_sortable_column' );
63
+ }
64
+ }
65
+ function expirationdate_sortable_column($columns) {
66
+ $columns['expirationdate'] = 'expirationdate';
67
+ return $columns;
68
+ }
69
+
70
+ add_action( 'pre_get_posts', 'my_expirationdate_orderby' );
71
+ function my_expirationdate_orderby( $query ) {
72
+ if( ! is_admin() )
73
+ return;
74
+
75
+ $orderby = $query->get( 'orderby');
76
+
77
+ if( 'expirationdate' == $orderby ) {
78
+ $query->set('meta_query',array(
79
+ 'relation' => 'OR',
80
+ array(
81
+ 'key' => '_expiration-date',
82
+ 'compare' => 'EXISTS'
83
+ ),
84
+ array(
85
+ 'key' => '_expiration-date',
86
+ 'compare' => 'NOT EXISTS',
87
+ 'value' => ''
88
+ )
89
+ ));
90
+ $query->set('orderby','meta_value_num');
91
+ }
92
+ }
93
 
94
  /**
95
  * adds an 'Expires' column to the page display table.
96
  */
97
+ add_filter ('manage_pages_columns', 'expirationdate_add_column_page');
98
  function expirationdate_add_column_page ($columns) {
99
  $defaults = get_option('expirationdateDefaultsPage');
100
  if (!isset($defaults['activeMetaBox']) || $defaults['activeMetaBox'] == 'active') {
102
  }
103
  return $columns;
104
  }
 
105
 
106
  /**
107
  * fills the 'Expires' column of the post display table.
108
  */
109
+ add_action ('manage_posts_custom_column', 'expirationdate_show_value');
110
+ add_action ('manage_pages_custom_column', 'expirationdate_show_value');
111
  function expirationdate_show_value ($column_name) {
112
  global $post;
113
  $id = $post->ID;
114
  if ($column_name === 'expirationdate') {
115
  $ed = get_post_meta($id,'_expiration-date',true);
116
  echo ($ed ? get_date_from_gmt(gmdate('Y-m-d H:i:s',$ed),get_option('date_format').' '.get_option('time_format')) : __("Never",'post-expirator'));
117
+
118
+ //Values for Quick Edit
119
+ if ($ed) {
120
+ $year = get_date_from_gmt(gmdate('Y-m-d H:i:s',$ed),'Y');
121
+ $month = get_date_from_gmt(gmdate('Y-m-d H:i:s',$ed),'m');
122
+ $day = get_date_from_gmt(gmdate('Y-m-d H:i:s',$ed),'d');
123
+ $hour = get_date_from_gmt(gmdate('Y-m-d H:i:s',$ed),'H');
124
+ $minute = get_date_from_gmt(gmdate('Y-m-d H:i:s',$ed),'i');
125
+ echo '<span id="expirationdate_year-'.$id.'" style="display: none;">'.$year.'</span>';
126
+ echo '<span id="expirationdate_month-'.$id.'" style="display: none;">'.$month.'</span>';
127
+ echo '<span id="expirationdate_day-'.$id.'" style="display: none;">'.$day.'</span>';
128
+ echo '<span id="expirationdate_hour-'.$id.'" style="display: none;">'.$hour.'</span>';
129
+ echo '<span id="expirationdate_minute-'.$id.'" style="display: none;">'.$minute.'</span>';
130
+ echo '<span id="expirationdate_enabled-'.$id.'" style="display: none;">true</span>';
131
+ } else {
132
+ echo '<span id="expirationdate_year-'.$id.'" style="display: none;">'.date('Y').'</span>';
133
+ echo '<span id="expirationdate_month-'.$id.'" style="display: none;">'.date('m').'</span>';
134
+ echo '<span id="expirationdate_day-'.$id.'" style="display: none;">'.date('d').'</span>';
135
+ echo '<span id="expirationdate_hour-'.$id.'" style="display: none;">'.date('H').'</span>';
136
+ echo '<span id="expirationdate_minute-'.$id.'" style="display: none;">'.date('i').'</span>';
137
+ echo '<span id="expirationdate_enabled-'.$id.'" style="display: none;">false</span>';
138
+ }
139
  }
140
  }
141
+
142
+
143
+ add_action( 'quick_edit_custom_box', 'display_expirationdate_quickedit', 10, 2 );
144
+ function display_expirationdate_quickedit( $column_name, $post_type ) {
145
+ if ($column_name != 'expirationdate') return;
146
+ ?>
147
+ <div style="clear:both"></div>
148
+ <fieldset class="inline-edit-col-left post-expirator-quickedit">
149
+ <div class="inline-edit-col">
150
+ <div class="inline-edit-group">
151
+ <span class="title">Post Expirator</span>
152
+ <p><input name="enable-expirationdate" type="checkbox" /><span class="title">Enable Post Expiration</span></p>
153
+ <fieldset class="inline-edit-date">
154
+ <legend><span class="title">Expires</span></legend>
155
+ <div class="timestamp-wrap">
156
+ <label><span class="screen-reader-text">Month</span>
157
+ <select name="expirationdate_month">
158
+ <option value="01" data-text="Jan">01-Jan</option>
159
+ <option value="02" data-text="Feb">02-Feb</option>
160
+ <option value="03" data-text="Mar">03-Mar</option>
161
+ <option value="04" data-text="Apr">04-Apr</option>
162
+ <option value="05" data-text="May">05-May</option>
163
+ <option value="06" data-text="Jun">06-Jun</option>
164
+ <option value="07" data-text="Jul">07-Jul</option>
165
+ <option value="08" data-text="Aug">08-Aug</option>
166
+ <option value="09" data-text="Sep">09-Sep</option>
167
+ <option value="10" data-text="Oct">10-Oct</option>
168
+ <option value="11" data-text="Nov">11-Nov</option>
169
+ <option value="12" data-text="Dec">12-Dec</option>
170
+ </select>
171
+ </label>
172
+ <label><span class="screen-reader-text">Day</span>
173
+ <input name="expirationdate_day" value="" size="2" maxlength="2" autocomplete="off" type="text"></label>,
174
+ <label><span class="screen-reader-text">Year</span>
175
+ <input name="expirationdate_year" value="" size="4" maxlength="4" autocomplete="off" type="text"></label> @
176
+ <label><span class="screen-reader-text">Hour</span>
177
+ <input name="expirationdate_hour" value="" size="2" maxlength="2" autocomplete="off" type="text"></label>:
178
+ <label><span class="screen-reader-text">Minute</span>
179
+ <input name="expirationdate_minute" value="" size="2" maxlength="2" autocomplete="off" type="text"></label></div>
180
+ <input name="expirationdate_quickedit" value="true" type="hidden"/>
181
+ </fieldset>
182
+ </div>
183
+ </div>
184
+ </fieldset>
185
+ <?php
186
+
187
+ }
188
+
189
+ add_action( 'bulk_edit_custom_box', 'display_expirationdate_bulkedit', 10, 2 );
190
+ function display_expirationdate_bulkedit( $column_name, $post_type ) {
191
+ if ($column_name != 'expirationdate') return;
192
+ ?>
193
+ <div style="clear:both"></div>
194
+ <div class="inline-edit-col post-expirator-quickedit">
195
+ <div class="inline-edit-col">
196
+ <div class="inline-edit-group">
197
+ <span class="title"><?php echo __('Post Expirator: Will only update expiration date if already configured on post.','post-expirator'); ?></span>
198
+ <fieldset class="inline-edit-date">
199
+ <legend><span class="title">Expires</span></legend>
200
+ <div class="timestamp-wrap">
201
+ <label><span class="screen-reader-text">Month</span>
202
+ <select name="expirationdate_month">
203
+ <option value="false">- No Change -</option>
204
+ <option value="01" data-text="Jan">01-Jan</option>
205
+ <option value="02" data-text="Feb">02-Feb</option>
206
+ <option value="03" data-text="Mar">03-Mar</option>
207
+ <option value="04" data-text="Apr">04-Apr</option>
208
+ <option value="05" data-text="May">05-May</option>
209
+ <option value="06" data-text="Jun">06-Jun</option>
210
+ <option value="07" data-text="Jul">07-Jul</option>
211
+ <option value="08" data-text="Aug">08-Aug</option>
212
+ <option value="09" data-text="Sep">09-Sep</option>
213
+ <option value="10" data-text="Oct">10-Oct</option>
214
+ <option value="11" data-text="Nov">11-Nov</option>
215
+ <option value="12" data-text="Dec">12-Dec</option>
216
+ </select>
217
+ </label>
218
+ <label><span class="screen-reader-text">Day</span>
219
+ <input name="expirationdate_day" placeholder="Day" value="" size="2" maxlength="2" autocomplete="off" type="text"></label>,
220
+ <label><span class="screen-reader-text">Year</span>
221
+ <input name="expirationdate_year" placeholder="Year" value="" size="4" maxlength="4" autocomplete="off" type="text"></label> @
222
+ <label><span class="screen-reader-text">Hour</span>
223
+ <input name="expirationdate_hour" placeholder="Hour" value="" size="2" maxlength="2" autocomplete="off" type="text"></label>:
224
+ <label><span class="screen-reader-text">Minute</span>
225
+ <input name="expirationdate_minute" placeholder="Min" value="" size="2" maxlength="2" autocomplete="off" type="text"></label></div>
226
+ <input name="expirationdate_quickedit" value="true" type="hidden"/>
227
+ </fieldset>
228
+ </div>
229
+ </div>
230
+ </div>
231
+ <?php
232
+
233
+ }
234
 
235
  /**
236
  * Adds hooks to get the meta box added to pages and custom post types
250
  /**
251
  * Actually adds the meta box
252
  */
253
+ function expirationdate_meta_box($post) {
254
  // Get default month
255
  $expirationdatets = get_post_meta($post->ID,'_expiration-date',true);
256
  $firstsave = get_post_meta($post->ID,'_expiration-date-status',true);
272
  else {
273
  $tz = get_option('timezone_string');
274
  if ( $tz ) date_default_timezone_set( $tz );
 
275
  $ts = time() + (strtotime($custom) - time());
 
276
  if ( $tz ) date_default_timezone_set('UTC');
277
  }
278
  $defaultmonth = get_date_from_gmt(gmdate('Y-m-d H:i:s',$ts),'m');
280
  $defaultyear = get_date_from_gmt(gmdate('Y-m-d H:i:s',$ts),'Y');;
281
  $defaulthour = get_date_from_gmt(gmdate('Y-m-d H:i:s',$ts),'H');
282
  $defaultminute = get_date_from_gmt(gmdate('Y-m-d H:i:s',$ts),'i');
283
+ }
284
 
285
  $enabled = '';
286
  $disabled = ' disabled="disabled"';
321
  $rv[] = '<th style="text-align: left;">'.__('Month','post-expirator').'</th>';
322
  $rv[] = '<th style="text-align: left;">'.__('Day','post-expirator').'</th>';
323
  $rv[] = '</tr><tr>';
324
+ $rv[] = '<td>';
325
  $rv[] = '<select name="expirationdate_year" id="expirationdate_year"'.$disabled.'>';
326
  $currentyear = date('Y');
327
+
328
  if ($defaultyear < $currentyear) $currentyear = $defaultyear;
329
 
330
  for($i = $currentyear; $i < $currentyear + 8; $i++) {
346
  $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>';
347
  }
348
 
349
+ $rv[] = '</select>';
350
  $rv[] = '</td><td>';
351
  $rv[] = '<input type="text" id="expirationdate_day" name="expirationdate_day" value="'.$defaultday.'" size="2"'.$disabled.' />,';
352
  $rv[] = '</td></tr><tr>';
452
  }
453
  var enable = 'false';
454
  }
 
455
  return true;
456
  }
457
  function expirationdate_toggle_category(id) {
458
  if (id.options[id.selectedIndex].value == 'category') {
459
  jQuery('#expired-category-selection').show();
460
  } else if (id.options[id.selectedIndex].value == 'category-add') {
461
+ jQuery('#expired-category-selection').show(); //TEMP
462
  } else if (id.options[id.selectedIndex].value == 'category-remove') {
463
  jQuery('#expired-category-selection').show(); //TEMP
464
  } else {
483
  * Get correct URL (HTTP or HTTPS)
484
  */
485
  function expirationdate_get_blog_url() {
486
+ if (is_multisite())
487
  echo network_home_url('/');
488
  else
489
  echo home_url('/');
492
  /**
493
  * Called when post is saved - stores expiration-date meta value
494
  */
495
+ add_action('save_post','expirationdate_update_post_meta');
496
  function expirationdate_update_post_meta($id) {
497
  // don't run the echo if this is an auto save
498
  if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE )
503
  if ( $posttype == 'revision' )
504
  return;
505
 
506
+ if (!isset($_POST['expirationdate_quickedit'])) {
507
+ if (!isset($_POST['expirationdate_formcheck']))
508
+ return;
509
+ }
510
 
511
  if (isset($_POST['enable-expirationdate'])) {
512
  $default = get_option('expirationdateDefaultDate',POSTEXPIRATOR_EXPIREDEFAULT);
540
  }
541
  }
542
  }
543
+
544
  _scheduleExpiratorEvent($id,$ts,$opts);
545
  } else {
546
  _unscheduleExpiratorEvent($id);
547
  }
548
  }
 
549
 
550
  function _scheduleExpiratorEvent($id,$ts,$opts) {
551
  $debug = postExpiratorDebug(); //check for/load debug
554
  wp_clear_scheduled_hook('postExpiratorExpire',array($id)); //Remove any existing hooks
555
  if (POSTEXPIRATOR_DEBUG) $debug->save(array('message' => $id.' -> EXISTING FOUND - UNSCHEDULED'));
556
  }
557
+
558
+ wp_schedule_single_event($ts,'postExpiratorExpire',array($id));
559
  if (POSTEXPIRATOR_DEBUG) $debug->save(array('message' => $id.' -> SCHEDULED at '.date_i18n('r',$ts).' '.'('.$ts.') with options '.print_r($opts,true)));
560
 
561
  // Update Post Meta
566
 
567
  function _unscheduleExpiratorEvent($id) {
568
  $debug = postExpiratorDebug(); // check for/load debug
569
+ delete_post_meta($id, '_expiration-date');
570
  delete_post_meta($id, '_expiration-date-options');
571
 
572
  // Delete Scheduled Expiration
587
  function postExpiratorExpire($id) {
588
  $debug = postExpiratorDebug(); //check for/load debug
589
 
590
+ if (empty($id)) {
591
  if (POSTEXPIRATOR_DEBUG) $debug->save(array('message' => 'No Post ID found - exiting'));
592
  return false;
593
  }
687
  $debug->save(array('message' => $id.' -> CATEGORIES ADDED '.print_r(_postExpiratorGetCatNames($category),true)));
688
  $debug->save(array('message' => $id.' -> CATEGORIES COMPLETE '.print_r(_postExpiratorGetCatNames($category),true)));
689
  }
690
+ }
691
  }
692
  } else {
693
  if (POSTEXPIRATOR_DEBUG) $debug->save(array('message' => $id.' -> CATEGORIES MISSING '.$expireType.' '.print_r($postoptions,true)));
700
  foreach ($cats as $cat) {
701
  if (!in_array($cat,$category)) {
702
  $merged[] = $cat;
703
+ }
704
  }
705
  if (wp_update_post(array('ID' => $id, 'post_category' => $merged)) == 0) {
706
  if (POSTEXPIRATOR_DEBUG) $debug->save(array('message' => $id.' -> FAILED '.$expireType.' '.print_r($postoptions,true)));
728
  $debug->save(array('message' => $id.' -> CATEGORIES REMOVED '.print_r(_postExpiratorGetCatNames($category),true)));
729
  $debug->save(array('message' => $id.' -> CATEGORIES COMPLETE '.print_r(_postExpiratorGetCatNames($category),true)));
730
  }
731
+ }
732
  }
733
  } else {
734
  if (POSTEXPIRATOR_DEBUG) $debug->save(array('message' => $id.' -> CATEGORIES MISSING '.$expireType.' '.print_r($postoptions,true)));
743
  $out[$cat] = get_the_category_by_id($cat);
744
  }
745
  return $out;
746
+ }
747
 
748
  /**
749
  * Build the menu for the options page
989
  </p>
990
  <?php
991
  foreach ($types as $type) {
992
+ echo "<fieldset style='border: 1px solid black; border-radius: 6px; padding: 0px 12px; margin-bottom: 20px;'>";
993
+ echo "<legend>Post Type: $type</legend>";
994
  $defaults = get_option('expirationdateDefaults'.ucfirst($type));
995
  if (isset($defaults['autoEnable']) && $defaults['autoEnable'] == 1) {
996
  $expiredautoenabled = 'checked = "checked"';
1005
  } else {
1006
  $expiredactivemetaenabled = 'checked = "checked"';
1007
  $expiredactivemetadisabled = '';
1008
+ }
1009
+ if (!isset($defaults['taxonomy'])) {
1010
+ $defaults['taxonomy'] = false;
1011
+ }
1012
  ?>
1013
  <table class="form-table">
1014
  <tr valign-"top">
1024
  <th scope="row"><label for="expirationdate_expiretype-<?php echo $type ?>"><?php _e('How to expire:','post-expirator'); ?></label></th>
1025
  <td>
1026
  <?php echo _postExpiratorExpireType(array('name'=>'expirationdate_expiretype-'.$type,'selected' => $defaults['expireType'])); ?>
1027
+ </select>
1028
  <br/>
1029
  <?php _e('Select the default expire action for the post type.','post-expirator');?>
1030
  </td>
1042
  <th scope="row"><label for="expirationdate_taxonomy-<?php echo $type ?>"><?php _e('Taxonomy (hierarchical):','post-expirator'); ?></label></th>
1043
  <td>
1044
  <?php echo _postExpiratorTaxonomy(array('type' => $type, 'name'=>'expirationdate_taxonomy-'.$type,'selected' => $defaults['taxonomy'])); ?>
 
 
 
1045
  </td>
1046
  </tr>
1047
  </table>
1048
+ </fieldset>
1049
  <?php
1050
  }
1051
  ?>
1081
  <form method="post" id="postExpiratorMenuUpgrade">
1082
  <?php wp_nonce_field('postExpiratorMenuDiagnostics','_postExpiratorMenuDiagnostics_nonce'); ?>
1083
  <h3><?php _e('Advanced Diagnostics','post-expirator');?></h3>
1084
+ <table class="form-table">
1085
  <tr valign-"top">
1086
  <th scope="row"><label for="postexpirator-log"><?php _e('Post Expirator Debug Logging:','post-expirator');?></label></th>
1087
  <td>
1120
  <th scope="row"><label for="cron-schedule"><?php _e('Current Cron Schedule:','post-expirator');?></label></th>
1121
  <td>
1122
  <?php _e('The below table will show all currently scheduled cron events with the next run time.','post-expirator');?><br/>
 
1123
  <table>
1124
  <tr>
1125
  <th style="width: 200px;"><?php _e('Date','post-expirator');?></th>
1136
  $arrkey = array_keys($eventvalue);
1137
  print '<td>';
1138
  foreach ($arrkey as $eventguid) {
1139
+ print '<table><tr>';
1140
  if (empty($eventvalue[$eventguid]['args'])) {
1141
  print '<td>No Arguments</td>';
1142
  } else {
1192
 
1193
  if (empty($dateformat)) {
1194
  global $expirationdateDefaultDateFormat;
1195
+ $dateformat = $expirationdateDefaultDateFormat;
1196
  }
1197
 
1198
  if (empty($timeformat)) {
1199
  global $expirationdateDefaultTimeFormat;
1200
+ $timeformat = $expirationdateDefaultTimeFormat;
1201
  }
1202
 
1203
+ if ($type == 'full')
1204
  $format = $dateformat.' '.$timeformat;
1205
  else if ($type == 'date')
1206
  $format = $dateformat;
1227
  $timeformat = get_option('expirationdateDefaultTimeFormat',POSTEXPIRATOR_TIMEFORMAT);
1228
  $expirationdateFooterContents = get_option('expirationdateFooterContents',POSTEXPIRATOR_FOOTERCONTENTS);
1229
  $expirationdateFooterStyle = get_option('expirationdateFooterStyle',POSTEXPIRATOR_FOOTERSTYLE);
1230
+
1231
  $search = array(
1232
  'EXPIRATIONFULL',
1233
  'EXPIRATIONDATE',
1310
  $opts['expireType'] = strtolower(get_option('expirationdateExpiredPostStatus','Draft'));
1311
  }
1312
 
1313
+ $cat = get_post_meta($result->post_id,'_expiration-date-category',true);
1314
  if ((isset($cat) && !empty($cat))) {
1315
  $opts['category'] = $cat;
1316
  $opts['expireType'] = 'category';
1341
  wp_clear_scheduled_hook('expirationdate_delete_'.$current_blog->blog_id);
1342
  } else
1343
  wp_clear_scheduled_hook('expirationdate_delete');
1344
+
1345
  update_option('postexpiratorVersion',POSTEXPIRATOR_VERSION);
1346
  }
1347
 
1348
  if (version_compare($version,'2.1.0') == -1) {
 
1349
  update_option('postexpiratorVersion',POSTEXPIRATOR_VERSION);
1350
  }
1351
 
1352
  if (version_compare($version,'2.1.1') == -1) {
1353
+ update_option('postexpiratorVersion',POSTEXPIRATOR_VERSION);
1354
+ }
1355
+
1356
+ if (version_compare($version,'2.2.0') == -1) {
1357
  update_option('postexpiratorVersion',POSTEXPIRATOR_VERSION);
1358
  }
1359
  }
1360
  }
1361
  add_action('admin_init','postexpirator_upgrade');
1362
 
1363
+ /**
1364
  * Called at plugin activation
1365
  */
1366
  function postexpirator_activate () {
1436
  $class = in_array( $category->term_id, $popular_cats ) ? ' class="expirator-category"' : '';
1437
  $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>';
1438
  }
1439
+
1440
  function end_el(&$output, $category, $depth = 0, $args = array()) {
1441
  $output .= "</li>\n";
1442
  }
1463
  $rv[] = '<option value="category-remove" '. ($selected == 'category-remove' ? 'selected="selected"' : '') . '>'.__('Category: Remove','post-expirator').'</option>';
1464
  }
1465
  $rv[] = '</select>';
1466
+ return implode("<br/>\n",$rv);
1467
  }
1468
 
1469
  function _postExpiratorTaxonomy($opts) {
1482
  if (empty($taxonomies)) $disabled = true;
1483
 
1484
  $rv = array();
1485
+ if ($taxonomies) {
1486
+ $rv[] = '<select name="'.$name.'" id="'.$id.'"'.($disabled == true ? ' disabled="disabled"' : '').' onchange="'.$onchange.'">';
1487
+ foreach ($taxonomies as $taxonomy) {
1488
+ $rv[] = '<option value="'.$taxonomy->name.'" '. ($selected == $taxonomy->name ? 'selected="selected"' : '') . '>'.$taxonomy->name.'</option>';
1489
+ }
1490
+
1491
+ $rv[] = '</select>';
1492
+ $rv[] = __('Select the hierarchical taxonomy to be used for "category" based expiration.','post-expirator');
1493
+ } else {
1494
+ $rv[] = 'No taxonomies found for post type.';
1495
  }
1496
+ return implode("<br/>\n",$rv);
1497
+ }
1498
 
1499
+ add_action( 'admin_print_scripts-edit.php', 'expirationdate_quickedit_javascript' );
1500
+ function expirationdate_quickedit_javascript() {
1501
+ // if using code as plugin
1502
+ wp_enqueue_script( 'manage-wp-posts-using-bulk-quick-edit', trailingslashit( plugin_dir_url( __FILE__ ) ) . 'admin-edit.js', array( 'jquery', 'inline-edit-post' ), '', true );
1503
+
1504
+ }
1505
+
1506
+ /**
1507
+ * Receieve AJAX call from bulk edit to process save
1508
+ */
1509
+ add_action( 'wp_ajax_manage_wp_posts_using_bulk_quick_save_bulk_edit', 'expiration_date_save_bulk_edit' );
1510
+ function expiration_date_save_bulk_edit() {
1511
+ // we need the post IDs
1512
+ $post_ids = ( isset( $_POST[ 'post_ids' ] ) && !empty( $_POST[ 'post_ids' ] ) ) ? $_POST[ 'post_ids' ] : NULL;
1513
+
1514
+ // if we have post IDs
1515
+ if ( ! empty( $post_ids ) && is_array( $post_ids ) ) {
1516
+
1517
+ // if no change, do nothing
1518
+ if ($_POST['expirationdate_month'] == "false") return;
1519
+
1520
+ $month = intval($_POST['expirationdate_month']);
1521
+ $day = intval($_POST['expirationdate_day']);
1522
+ $year = intval($_POST['expirationdate_year']);
1523
+ $hour = intval($_POST['expirationdate_hour']);
1524
+ $minute = intval($_POST['expirationdate_minute']);
1525
+ $ts = get_gmt_from_date("$year-$month-$day $hour:$minute:0",'U');
1526
+
1527
+ foreach( $post_ids as $post_id ) {
1528
+ // Only update posts that already have expiration date set. Ignore Others
1529
+ $ed = get_post_meta($post_id,'_expiration-date',true);
1530
+ if ($ed) {
1531
+ update_post_meta($post_id, '_expiration-date', $ts);
1532
+ }
1533
+ }
1534
+ }
1535
  }
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: http://aaron.axelsen.us/donate
4
  Tags: expire, posts, pages, schedule
5
  Requires at least: 4.0
6
  Tested up to: 4.7
7
- Stable tag: 2.1.4
8
 
9
  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
10
  post categories.
@@ -48,6 +48,14 @@ This section describes how to install the plugin and get it working.
48
 
49
  == Changelog ==
50
 
 
 
 
 
 
 
 
 
51
  **Version 2.1.4**
52
 
53
  * Fix: PHP Strict errors with 5.4+
@@ -205,6 +213,9 @@ NOTE: After upgrading, you may need to reset the cron schedules. Following onsc
205
 
206
  == Upgrade Notice ==
207
 
 
 
 
208
  = 2.1.4 =
209
  Fixed PHP Strict errors with 5.4+
210
  Removed temporary timezone conversion functions
4
  Tags: expire, posts, pages, schedule
5
  Requires at least: 4.0
6
  Tested up to: 4.7
7
+ Stable tag: 2.2.0
8
 
9
  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
10
  post categories.
48
 
49
  == Changelog ==
50
 
51
+ **Version 2.2.0**
52
+
53
+ * New: Quick Edit - setting expiration date and toggling post expiration status can now be done via quick edit.
54
+ * New: Bulk Edit - changing expiration date on posts that already are configured can now be done via bulk edit.
55
+ * New: Added ability to order by Expiration Date in dashboard.
56
+ * New: Adjusted formatting on defaults page. Multiple post types are now displayed cleaner.
57
+ * Fix: Minor Code Cleanup
58
+
59
  **Version 2.1.4**
60
 
61
  * Fix: PHP Strict errors with 5.4+
213
 
214
  == Upgrade Notice ==
215
 
216
+ = 2.2.0 =
217
+ Quick Edit/Bulk Edit Added. Sortable Expiration Date Fields Added
218
+
219
  = 2.1.4 =
220
  Fixed PHP Strict errors with 5.4+
221
  Removed temporary timezone conversion functions
style.css CHANGED
@@ -26,3 +26,6 @@
26
  font-style: italic;
27
  font-size: x-small;
28
  }
 
 
 
26
  font-style: italic;
27
  font-size: x-small;
28
  }
29
+ .post-expirator-quickedit input {
30
+ font-size: 12px;
31
+ }