Post Expirator - Version 2.3.0

Version Description

Download this release

Release Info

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

Code changes from version 2.2.2 to 2.3.0

Files changed (2) hide show
  1. post-expirator.php +194 -29
  2. readme.txt +24 -6
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.2.2
8
  Author URI: http://postexpirator.tuxdocs.net/
9
  Text Domain: post-expirator
10
  */
@@ -17,12 +17,14 @@ function postExpirator_init() {
17
  add_action('plugins_loaded', 'postExpirator_init');
18
 
19
  // Default Values
20
- define('POSTEXPIRATOR_VERSION','2.2.2');
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'));
24
  define('POSTEXPIRATOR_FOOTERSTYLE','font-style: italic;');
25
  define('POSTEXPIRATOR_FOOTERDISPLAY','0');
 
 
26
  define('POSTEXPIRATOR_DEBUGDEFAULT','0');
27
  define('POSTEXPIRATOR_EXPIREDEFAULT','null');
28
 
@@ -40,7 +42,13 @@ add_filter('plugin_action_links', 'postExpirator_plugin_action_links', 10, 2);
40
  */
41
  add_action('admin_notices','postExpirationAdminNotice');
42
  function postExpirationAdminNotice() {
43
- // Currently not used
 
 
 
 
 
 
44
  }
45
 
46
  /**
@@ -527,12 +535,12 @@ function expirationdate_update_post_meta($id) {
527
 
528
  $ts = get_gmt_from_date("$year-$month-$day $hour:$minute:0",'U');
529
 
530
- if (isset($_POST['expirationdate_quickedit'])) {
531
- $ed = get_post_meta($id,'_expiration-date',true);
532
- if ($ed) {
533
- $opts = get_post_meta($id, '_expiration-date-options', true);
534
- }
535
- } else {
536
  $opts = array();
537
 
538
  // Schedule/Update Expiration
@@ -557,6 +565,8 @@ function expirationdate_update_post_meta($id) {
557
  function _scheduleExpiratorEvent($id,$ts,$opts) {
558
  $debug = postExpiratorDebug(); //check for/load debug
559
 
 
 
560
  if (wp_next_scheduled('postExpiratorExpire',array($id)) !== false) {
561
  wp_clear_scheduled_hook('postExpiratorExpire',array($id)); //Remove any existing hooks
562
  if (POSTEXPIRATOR_DEBUG) $debug->save(array('message' => $id.' -> EXISTING FOUND - UNSCHEDULED'));
@@ -573,6 +583,9 @@ function _scheduleExpiratorEvent($id,$ts,$opts) {
573
 
574
  function _unscheduleExpiratorEvent($id) {
575
  $debug = postExpiratorDebug(); // check for/load debug
 
 
 
576
  delete_post_meta($id, '_expiration-date');
577
  delete_post_meta($id, '_expiration-date-options');
578
 
@@ -604,8 +617,13 @@ function postExpiratorExpire($id) {
604
  return false;
605
  }
606
 
 
 
 
 
607
  $postoptions = get_post_meta($id,'_expiration-date-options',true);
608
  extract($postoptions);
 
609
 
610
  // Check for default expire only if not passed in
611
  if (empty($expireType)) {
@@ -629,18 +647,42 @@ function postExpiratorExpire($id) {
629
  if (wp_update_post(array('ID' => $id, 'post_status' => 'draft')) == 0) {
630
  if (POSTEXPIRATOR_DEBUG) $debug->save(array('message' => $id.' -> FAILED '.$expireType.' '.print_r($postoptions,true)));
631
  } else {
 
632
  if (POSTEXPIRATOR_DEBUG) $debug->save(array('message' => $id.' -> PROCESSED '.$expireType.' '.print_r($postoptions,true)));
633
  }
634
  } elseif ($expireType == 'private') {
635
  if (wp_update_post(array('ID' => $id, 'post_status' => 'private')) == 0) {
636
  if (POSTEXPIRATOR_DEBUG) $debug->save(array('message' => $id.' -> FAILED '.$expireType.' '.print_r($postoptions,true)));
637
  } else {
 
638
  if (POSTEXPIRATOR_DEBUG) $debug->save(array('message' => $id.' -> PROCESSED '.$expireType.' '.print_r($postoptions,true)));
639
  }
640
  } elseif ($expireType == 'delete') {
641
  if (wp_delete_post($id) === false) {
642
  if (POSTEXPIRATOR_DEBUG) $debug->save(array('message' => $id.' -> FAILED '.$expireType.' '.print_r($postoptions,true)));
643
  } else {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
644
  if (POSTEXPIRATOR_DEBUG) $debug->save(array('message' => $id.' -> PROCESSED '.$expireType.' '.print_r($postoptions,true)));
645
  }
646
  } elseif ($expireType == 'category') {
@@ -649,6 +691,7 @@ function postExpiratorExpire($id) {
649
  if (wp_update_post(array('ID' => $id, 'post_category' => $category)) == 0) {
650
  if (POSTEXPIRATOR_DEBUG) $debug->save(array('message' => $id.' -> FAILED '.$expireType.' '.print_r($postoptions,true)));
651
  } else {
 
652
  if (POSTEXPIRATOR_DEBUG) {
653
  $debug->save(array('message' => $id.' -> PROCESSED '.$expireType.' '.print_r($postoptions,true)));
654
  $debug->save(array('message' => $id.' -> CATEGORIES REPLACED '.print_r(_postExpiratorGetCatNames($category),true)));
@@ -660,6 +703,7 @@ function postExpiratorExpire($id) {
660
  if (is_wp_error(wp_set_object_terms($id,$terms,$categoryTaxonomy,false))) {
661
  if (POSTEXPIRATOR_DEBUG) $debug->save(array('message' => $id.' -> FAILED '.$expireType.' '.print_r($postoptions,true)));
662
  } else {
 
663
  if (POSTEXPIRATOR_DEBUG) {
664
  $debug->save(array('message' => $id.' -> PROCESSED '.$expireType.' '.print_r($postoptions,true)));
665
  $debug->save(array('message' => $id.' -> CATEGORIES REPLACED '.print_r(_postExpiratorGetCatNames($category),true)));
@@ -678,6 +722,7 @@ function postExpiratorExpire($id) {
678
  if (wp_update_post(array('ID' => $id, 'post_category' => $merged)) == 0) {
679
  if (POSTEXPIRATOR_DEBUG) $debug->save(array('message' => $id.' -> FAILED '.$expireType.' '.print_r($postoptions,true)));
680
  } else {
 
681
  if (POSTEXPIRATOR_DEBUG) {
682
  $debug->save(array('message' => $id.' -> PROCESSED '.$expireType.' '.print_r($postoptions,true)));
683
  $debug->save(array('message' => $id.' -> CATEGORIES ADDED '.print_r(_postExpiratorGetCatNames($category),true)));
@@ -689,6 +734,7 @@ function postExpiratorExpire($id) {
689
  if (is_wp_error(wp_set_object_terms($id,$terms,$categoryTaxonomy,true))) {
690
  if (POSTEXPIRATOR_DEBUG) $debug->save(array('message' => $id.' -> FAILED '.$expireType.' '.print_r($postoptions,true)));
691
  } else {
 
692
  if (POSTEXPIRATOR_DEBUG) {
693
  $debug->save(array('message' => $id.' -> PROCESSED '.$expireType.' '.print_r($postoptions,true)));
694
  $debug->save(array('message' => $id.' -> CATEGORIES ADDED '.print_r(_postExpiratorGetCatNames($category),true)));
@@ -712,6 +758,7 @@ function postExpiratorExpire($id) {
712
  if (wp_update_post(array('ID' => $id, 'post_category' => $merged)) == 0) {
713
  if (POSTEXPIRATOR_DEBUG) $debug->save(array('message' => $id.' -> FAILED '.$expireType.' '.print_r($postoptions,true)));
714
  } else {
 
715
  if (POSTEXPIRATOR_DEBUG) {
716
  $debug->save(array('message' => $id.' -> PROCESSED '.$expireType.' '.print_r($postoptions,true)));
717
  $debug->save(array('message' => $id.' -> CATEGORIES REMOVED '.print_r(_postExpiratorGetCatNames($category),true)));
@@ -730,6 +777,7 @@ function postExpiratorExpire($id) {
730
  if (is_wp_error(wp_set_object_terms($id,$terms,$categoryTaxonomy,false))) {
731
  if (POSTEXPIRATOR_DEBUG) $debug->save(array('message' => $id.' -> FAILED '.$expireType.' '.print_r($postoptions,true)));
732
  } else {
 
733
  if (POSTEXPIRATOR_DEBUG) {
734
  $debug->save(array('message' => $id.' -> PROCESSED '.$expireType.' '.print_r($postoptions,true)));
735
  $debug->save(array('message' => $id.' -> CATEGORIES REMOVED '.print_r(_postExpiratorGetCatNames($category),true)));
@@ -741,6 +789,53 @@ function postExpiratorExpire($id) {
741
  if (POSTEXPIRATOR_DEBUG) $debug->save(array('message' => $id.' -> CATEGORIES MISSING '.$expireType.' '.print_r($postoptions,true)));
742
  }
743
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
744
  }
745
  add_action('postExpiratorExpire','postExpiratorExpire');
746
 
@@ -810,6 +905,9 @@ function postExpiratorMenuGeneral() {
810
  update_option('expirationdateDefaultDateFormat',$_POST['expired-default-date-format']);
811
  update_option('expirationdateDefaultTimeFormat',$_POST['expired-default-time-format']);
812
  update_option('expirationdateDisplayFooter',$_POST['expired-display-footer']);
 
 
 
813
  update_option('expirationdateFooterContents',$_POST['expired-footer-contents']);
814
  update_option('expirationdateFooterStyle',$_POST['expired-footer-style']);
815
  if (isset($_POST['expirationdate_category'])) update_option('expirationdateCategoryDefaults',$_POST['expirationdate_category']);
@@ -825,6 +923,9 @@ function postExpiratorMenuGeneral() {
825
  $expirationdateDefaultDateFormat = get_option('expirationdateDefaultDateFormat',POSTEXPIRATOR_DATEFORMAT);
826
  $expirationdateDefaultTimeFormat = get_option('expirationdateDefaultTimeFormat',POSTEXPIRATOR_TIMEFORMAT);
827
  $expireddisplayfooter = get_option('expirationdateDisplayFooter',POSTEXPIRATOR_FOOTERDISPLAY);
 
 
 
828
  $expirationdateFooterContents = get_option('expirationdateFooterContents',POSTEXPIRATOR_FOOTERCONTENTS);
829
  $expirationdateFooterStyle = get_option('expirationdateFooterStyle',POSTEXPIRATOR_FOOTERSTYLE);
830
  $expirationdateDefaultDate = get_option('expirationdateDefaultDate',POSTEXPIRATOR_EXPIREDEFAULT);
@@ -838,6 +939,20 @@ function postExpiratorMenuGeneral() {
838
  $expireddisplayfooterdisabled = 'checked="checked"';
839
  else if ($expireddisplayfooter == 1)
840
  $expireddisplayfooterenabled = 'checked="checked"';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
841
  ?>
842
  <p>
843
  <?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'); ?>
@@ -854,7 +969,7 @@ function postExpiratorMenuGeneral() {
854
  <?php wp_nonce_field('postExpiratorMenuGeneral','_postExpiratorMenuGeneral_nonce'); ?>
855
  <h3><?php _e('Defaults','post-expirator'); ?></h3>
856
  <table class="form-table">
857
- <tr valign-"top">
858
  <th scope="row"><label for="expired-default-date-format"><?php _e('Date Format:','post-expirator');?></label></th>
859
  <td>
860
  <input type="text" name="expired-default-date-format" id="expired-default-date-format" value="<?php echo $expirationdateDefaultDateFormat ?>" size="25" /> (<?php echo date_i18n("$expirationdateDefaultDateFormat") ?>)
@@ -862,7 +977,7 @@ function postExpiratorMenuGeneral() {
862
  <?php _e('The default format to use when displaying the expiration date 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'); ?>
863
  </td>
864
  </tr>
865
- <tr valign-"top">
866
  <th scope="row"><label for="expired-default-time-format"><?php _e('Time Format:','post-expirator');?></label></th>
867
  <td>
868
  <input type="text" name="expired-default-time-format" id="expired-default-time-format" value="<?php echo $expirationdateDefaultTimeFormat ?>" size="25" /> (<?php echo date_i18n("$expirationdateDefaultTimeFormat") ?>)
@@ -870,7 +985,7 @@ function postExpiratorMenuGeneral() {
870
  <?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'); ?>
871
  </td>
872
  </tr>
873
- <tr valign-"top">
874
  <th scope="row"><label for="expired-default-expiration-date"><?php _e('Default Date/Time Duration:','post-expirator');?></label></th>
875
  <td>
876
  <select name="expired-default-expiration-date" id="expired-default-expiration-date" onchange="expirationdate_toggle_defaultdate(this)">
@@ -891,7 +1006,7 @@ function postExpiratorMenuGeneral() {
891
  </table>
892
  <h3><?php _e('Category Expiration','post-expirator');?></h3>
893
  <table class="form-table">
894
- <tr valign-"top">
895
  <th scope="row"><?php _e('Default Expiration Category','post-expirator');?>:</th>
896
  <td>
897
  <?php
@@ -908,19 +1023,53 @@ function postExpiratorMenuGeneral() {
908
  </tr>
909
  </table>
910
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
911
  <h3><?php _e('Post Footer Display','post-expirator');?></h3>
912
  <p><?php _e('Enabling this below will display the expiration date automatically at the end of any post which is set to expire.','post-expirator');?></p>
913
  <table class="form-table">
914
- <tr valign-"top">
915
  <th scope="row"><?php _e('Show in post footer?','post-expirator');?></th>
916
  <td>
917
- <input type="radio" name="expired-display-footer" id="expired-display-footer-true" value="1" <?php echo $expireddisplayfooterenabled ?>/> <label for="expired-display-footer-true"><?php _e('Enabled','post-expirator');?></label>
 
918
  <input type="radio" name="expired-display-footer" id="expired-display-footer-false" value="0" <?php echo $expireddisplayfooterdisabled ?>/> <label for="expired-display-footer-false"><?php _e('Disabled','post-expirator');?></label>
919
  <br/>
920
  <?php _e('This will enable or disable displaying the post expiration date in the post footer.','post-expirator');?>
921
  </td>
922
  </tr>
923
- <tr valign-"top">
924
  <th scope="row"><label for="expired-footer-contents"><?php _e('Footer Contents:','post-expirator');?></label></th>
925
  <td>
926
  <textarea id="expired-footer-contents" name="expired-footer-contents" rows="3" cols="50"><?php echo $expirationdateFooterContents; ?></textarea>
@@ -933,7 +1082,7 @@ function postExpiratorMenuGeneral() {
933
  </ul>
934
  </td>
935
  </tr>
936
- <tr valign-"top">
937
  <th scope="row"><label for="expired-footer-style"><?php _e('Footer Style:','post-expirator');?></label></th>
938
  <td>
939
  <input type="text" name="expired-footer-style" id="expired-footer-style" value="<?php echo $expirationdateFooterStyle ?>" size="25" />
@@ -977,6 +1126,7 @@ function postExpiratorMenuDefaults() {
977
  if (isset($_POST['expirationdate_activemeta-'.$type])) {
978
  $defaults[$type]['activeMetaBox'] = $_POST['expirationdate_activemeta-'.$type];
979
  }
 
980
 
981
  //Save Settings
982
  update_option('expirationdateDefaults'.ucfirst($type),$defaults[$type]);
@@ -999,6 +1149,7 @@ function postExpiratorMenuDefaults() {
999
  echo "<fieldset style='border: 1px solid black; border-radius: 6px; padding: 0px 12px; margin-bottom: 20px;'>";
1000
  echo "<legend>Post Type: $type</legend>";
1001
  $defaults = get_option('expirationdateDefaults'.ucfirst($type));
 
1002
  if (isset($defaults['autoEnable']) && $defaults['autoEnable'] == 1) {
1003
  $expiredautoenabled = 'checked = "checked"';
1004
  $expiredautodisabled = '';
@@ -1018,16 +1169,17 @@ function postExpiratorMenuDefaults() {
1018
  }
1019
  ?>
1020
  <table class="form-table">
1021
- <tr valign-"top">
1022
  <th scope="row"><label for="expirationdate_activemeta-<?php echo $type ?>"><?php _e('Active:','post-expirator');?></label></th>
1023
  <td>
1024
- <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>
 
1025
  <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>
1026
  <br/>
1027
  <?php _e('Select whether the post expirator meta box is active for this post type.','post-expirator');?>
1028
  </td>
1029
  </tr>
1030
- <tr valign-"top">
1031
  <th scope="row"><label for="expirationdate_expiretype-<?php echo $type ?>"><?php _e('How to expire:','post-expirator'); ?></label></th>
1032
  <td>
1033
  <?php echo _postExpiratorExpireType(array('name'=>'expirationdate_expiretype-'.$type,'selected' => $defaults['expireType'])); ?>
@@ -1036,21 +1188,31 @@ function postExpiratorMenuDefaults() {
1036
  <?php _e('Select the default expire action for the post type.','post-expirator');?>
1037
  </td>
1038
  </tr>
1039
- <tr valign-"top">
1040
  <th scope="row"><label for="expirationdate_autoenable-<?php echo $type ?>"><?php _e('Auto-Enable?','post-expirator');?></label></th>
1041
  <td>
1042
- <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>
 
1043
  <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>
1044
  <br/>
1045
  <?php _e('Select whether the post expirator is enabled for all new posts.','post-expirator');?>
1046
  </td>
1047
  </tr>
1048
- <tr valign-"top">
1049
  <th scope="row"><label for="expirationdate_taxonomy-<?php echo $type ?>"><?php _e('Taxonomy (hierarchical):','post-expirator'); ?></label></th>
1050
  <td>
1051
  <?php echo _postExpiratorTaxonomy(array('type' => $type, 'name'=>'expirationdate_taxonomy-'.$type,'selected' => $defaults['taxonomy'])); ?>
1052
  </td>
1053
  </tr>
 
 
 
 
 
 
 
 
 
1054
  </table>
1055
  </fieldset>
1056
  <?php
@@ -1089,7 +1251,7 @@ function postExpiratorMenuDiagnostics() {
1089
  <?php wp_nonce_field('postExpiratorMenuDiagnostics','_postExpiratorMenuDiagnostics_nonce'); ?>
1090
  <h3><?php _e('Advanced Diagnostics','post-expirator');?></h3>
1091
  <table class="form-table">
1092
- <tr valign-"top">
1093
  <th scope="row"><label for="postexpirator-log"><?php _e('Post Expirator Debug Logging:','post-expirator');?></label></th>
1094
  <td>
1095
  <?php
@@ -1105,13 +1267,13 @@ function postExpiratorMenuDiagnostics() {
1105
  <a href="<?php echo admin_url('options-general.php?page=post-expirator.php&tab=viewdebug') ?>">View Debug Logs</a>
1106
  </td>
1107
  </tr>
1108
- <tr valign-"top">
1109
  <th scope="row"><?php _e('Purge Debug Log:','post-expirator');?></th>
1110
  <td>
1111
  <input type="submit" class="button" name="purge-debug" id="purge-debug" value="<?php _e('Purge Debug Log','post-expirator');?>" />
1112
  </td>
1113
  </tr/>
1114
- <tr valign-"top">
1115
  <th scope="row"><?php _e('WP-Cron Status:','post-expirator');?></th>
1116
  <td>
1117
  <?php
@@ -1123,7 +1285,7 @@ function postExpiratorMenuDiagnostics() {
1123
  ?>
1124
  </td>
1125
  </tr/>
1126
- <tr valign-"top">
1127
  <th scope="row"><label for="cron-schedule"><?php _e('Current Cron Schedule:','post-expirator');?></label></th>
1128
  <td>
1129
  <?php _e('The below table will show all currently scheduled cron events with the next run time.','post-expirator');?><br/>
@@ -1366,7 +1528,7 @@ function postexpirator_upgrade() {
1366
  if (version_compare($version,'2.2.1') == -1) {
1367
  update_option('postexpiratorVersion',POSTEXPIRATOR_VERSION);
1368
  }
1369
- if (version_compare($version,'2.2.2') == -1) {
1370
  update_option('postexpiratorVersion',POSTEXPIRATOR_VERSION);
1371
  }
1372
  }
@@ -1469,7 +1631,10 @@ function _postExpiratorExpireType($opts) {
1469
  $rv[] = '<select name="'.$name.'" id="'.$id.'"'.($disabled == true ? ' disabled="disabled"' : '').' onchange="'.$onchange.'">';
1470
  $rv[] = '<option value="draft" '. ($selected == 'draft' ? 'selected="selected"' : '') . '>'.__('Draft','post-expirator').'</option>';
1471
  $rv[] = '<option value="delete" '. ($selected == 'delete' ? 'selected="selected"' : '') . '>'.__('Delete','post-expirator').'</option>';
 
1472
  $rv[] = '<option value="private" '. ($selected == 'private' ? 'selected="selected"' : '') . '>'.__('Private','post-expirator').'</option>';
 
 
1473
  if ($type != 'page') {
1474
  $rv[] = '<option value="category" '. ($selected == 'category' ? 'selected="selected"' : '') . '>'.__('Category: Replace','post-expirator').'</option>';
1475
  $rv[] = '<option value="category-add" '. ($selected == 'category-add' ? 'selected="selected"' : '') . '>'.__('Category: Add','post-expirator').'</option>';
@@ -1542,7 +1707,7 @@ function expiration_date_save_bulk_edit() {
1542
  $ed = get_post_meta($post_id,'_expiration-date',true);
1543
  if ($ed) {
1544
  $opts = get_post_meta($post_id, '_expiration-date-options', true);
1545
- _scheduleExpiratorEvent($post_id,$ts,$opts);
1546
  }
1547
  }
1548
  }
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.3.0
8
  Author URI: http://postexpirator.tuxdocs.net/
9
  Text Domain: post-expirator
10
  */
17
  add_action('plugins_loaded', 'postExpirator_init');
18
 
19
  // Default Values
20
+ define('POSTEXPIRATOR_VERSION','2.3.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'));
24
  define('POSTEXPIRATOR_FOOTERSTYLE','font-style: italic;');
25
  define('POSTEXPIRATOR_FOOTERDISPLAY','0');
26
+ define('POSTEXPIRATOR_EMAILNOTIFICATION','0');
27
+ define('POSTEXPIRATOR_EMAILNOTIFICATIONADMINS','0');
28
  define('POSTEXPIRATOR_DEBUGDEFAULT','0');
29
  define('POSTEXPIRATOR_EXPIREDEFAULT','null');
30
 
42
  */
43
  add_action('admin_notices','postExpirationAdminNotice');
44
  function postExpirationAdminNotice() {
45
+ // Check if WP-Cron is Enabled
46
+ #if (defined('DISABLE_WP_CRON') && DISABLE_WP_CRON === true) {
47
+ # $class = 'notice notice-error';
48
+ # $message = __( 'POST EXPIRATOR ERROR: WP-Cron is disabled on this server. This plugin requires WP-Cron and will not function until it is corrected.','post-expirator');
49
+ # $message .= '<br/><br/>' . __( ' If you have manually configured cron click here to dismiss this message.', 'post-expirator' );
50
+ # printf( '<div class="%1$s"><p>%2$s</p></div>', esc_attr( $class ), $message );
51
+ #}
52
  }
53
 
54
  /**
535
 
536
  $ts = get_gmt_from_date("$year-$month-$day $hour:$minute:0",'U');
537
 
538
+ if (isset($_POST['expirationdate_quickedit'])) {
539
+ $ed = get_post_meta($id,'_expiration-date',true);
540
+ if ($ed) {
541
+ $opts = get_post_meta($id, '_expiration-date-options', true);
542
+ }
543
+ } else {
544
  $opts = array();
545
 
546
  // Schedule/Update Expiration
565
  function _scheduleExpiratorEvent($id,$ts,$opts) {
566
  $debug = postExpiratorDebug(); //check for/load debug
567
 
568
+ do_action('postexpiratior_schedule',$id,$ts,$opts); // allow custom actions
569
+
570
  if (wp_next_scheduled('postExpiratorExpire',array($id)) !== false) {
571
  wp_clear_scheduled_hook('postExpiratorExpire',array($id)); //Remove any existing hooks
572
  if (POSTEXPIRATOR_DEBUG) $debug->save(array('message' => $id.' -> EXISTING FOUND - UNSCHEDULED'));
583
 
584
  function _unscheduleExpiratorEvent($id) {
585
  $debug = postExpiratorDebug(); // check for/load debug
586
+
587
+ do_action('postexpiratior_unschedule',$id); // allow custom actions
588
+
589
  delete_post_meta($id, '_expiration-date');
590
  delete_post_meta($id, '_expiration-date-options');
591
 
617
  return false;
618
  }
619
 
620
+ $posttype = get_post_type($id);
621
+ $posttitle = get_the_title($id);
622
+ $postlink = get_post_permalink($id);
623
+
624
  $postoptions = get_post_meta($id,'_expiration-date-options',true);
625
  extract($postoptions);
626
+ $ed = get_post_meta($id,'_expiration-date',true);
627
 
628
  // Check for default expire only if not passed in
629
  if (empty($expireType)) {
647
  if (wp_update_post(array('ID' => $id, 'post_status' => 'draft')) == 0) {
648
  if (POSTEXPIRATOR_DEBUG) $debug->save(array('message' => $id.' -> FAILED '.$expireType.' '.print_r($postoptions,true)));
649
  } else {
650
+ $emailBody = sprintf( __( '%s (%s) has expired at %s. Post status has been successfully changed to "%s".', 'post-expirator' ),'##POSTTITLE##','##POSTLINK##','##EXPIRATIONDATE##',strtoupper($expireType) );
651
  if (POSTEXPIRATOR_DEBUG) $debug->save(array('message' => $id.' -> PROCESSED '.$expireType.' '.print_r($postoptions,true)));
652
  }
653
  } elseif ($expireType == 'private') {
654
  if (wp_update_post(array('ID' => $id, 'post_status' => 'private')) == 0) {
655
  if (POSTEXPIRATOR_DEBUG) $debug->save(array('message' => $id.' -> FAILED '.$expireType.' '.print_r($postoptions,true)));
656
  } else {
657
+ $emailBody = sprintf( __( '%s (%s) has expired at %s. Post status has been successfully changed to "%s".', 'post-expirator' ),'##POSTTITLE##','##POSTLINK##','##EXPIRATIONDATE##',strtoupper($expireType) );
658
  if (POSTEXPIRATOR_DEBUG) $debug->save(array('message' => $id.' -> PROCESSED '.$expireType.' '.print_r($postoptions,true)));
659
  }
660
  } elseif ($expireType == 'delete') {
661
  if (wp_delete_post($id) === false) {
662
  if (POSTEXPIRATOR_DEBUG) $debug->save(array('message' => $id.' -> FAILED '.$expireType.' '.print_r($postoptions,true)));
663
  } else {
664
+ $emailBody = sprintf( __( '%s (%s) has expired at %s. Post status has been successfully changed to "%s".', 'post-expirator' ),'##POSTTITLE##','##POSTLINK##','##EXPIRATIONDATE##',strtoupper($expireType) );
665
+ if (POSTEXPIRATOR_DEBUG) $debug->save(array('message' => $id.' -> PROCESSED '.$expireType.' '.print_r($postoptions,true)));
666
+ }
667
+ } elseif ($expireType == 'trash') {
668
+ if (wp_trash_post($id) === false) {
669
+ if (POSTEXPIRATOR_DEBUG) $debug->save(array('message' => $id.' -> FAILED '.$expireType.' '.print_r($postoptions,true)));
670
+ } else {
671
+ $emailBody = sprintf( __( '%s (%s) has expired at %s. Post status has been successfully changed to "%s".', 'post-expirator' ),'##POSTTITLE##','##POSTLINK##','##EXPIRATIONDATE##',strtoupper($expireType) );
672
+ if (POSTEXPIRATOR_DEBUG) $debug->save(array('message' => $id.' -> PROCESSED '.$expireType.' '.print_r($postoptions,true)));
673
+ }
674
+ } elseif ($expireType == 'stick') {
675
+ if (stick_post($id) === false) {
676
+ if (POSTEXPIRATOR_DEBUG) $debug->save(array('message' => $id.' -> FAILED '.$expireType.' '.print_r($postoptions,true)));
677
+ } else {
678
+ $emailBody = sprintf( __( '%s (%s) has expired at %s. Post "%s" status has been successfully set.', 'post-expirator' ),'##POSTTITLE##','##POSTLINK##','##EXPIRATIONDATE##','STICKY' );
679
+ if (POSTEXPIRATOR_DEBUG) $debug->save(array('message' => $id.' -> PROCESSED '.$expireType.' '.print_r($postoptions,true)));
680
+ }
681
+ } elseif ($expireType == 'unstick') {
682
+ if (unstick_post($id) === false) {
683
+ if (POSTEXPIRATOR_DEBUG) $debug->save(array('message' => $id.' -> FAILED '.$expireType.' '.print_r($postoptions,true)));
684
+ } else {
685
+ $emailBody = sprintf( __( '%s (%s) has expired at %s. Post "%s" status has been successfully removed.', 'post-expirator' ),'##POSTTITLE##','##POSTLINK##','##EXPIRATIONDATE##','STICKY' );
686
  if (POSTEXPIRATOR_DEBUG) $debug->save(array('message' => $id.' -> PROCESSED '.$expireType.' '.print_r($postoptions,true)));
687
  }
688
  } elseif ($expireType == 'category') {
691
  if (wp_update_post(array('ID' => $id, 'post_category' => $category)) == 0) {
692
  if (POSTEXPIRATOR_DEBUG) $debug->save(array('message' => $id.' -> FAILED '.$expireType.' '.print_r($postoptions,true)));
693
  } else {
694
+ $emailBody = sprintf( __( '%s (%s) has expired at %s. Post "%s" have now been set to "%s".', 'post-expirator' ),'##POSTTITLE##','##POSTLINK##','##EXPIRATIONDATE##','CATEGORIES', implode(',',_postExpiratorGetCatNames($category)));
695
  if (POSTEXPIRATOR_DEBUG) {
696
  $debug->save(array('message' => $id.' -> PROCESSED '.$expireType.' '.print_r($postoptions,true)));
697
  $debug->save(array('message' => $id.' -> CATEGORIES REPLACED '.print_r(_postExpiratorGetCatNames($category),true)));
703
  if (is_wp_error(wp_set_object_terms($id,$terms,$categoryTaxonomy,false))) {
704
  if (POSTEXPIRATOR_DEBUG) $debug->save(array('message' => $id.' -> FAILED '.$expireType.' '.print_r($postoptions,true)));
705
  } else {
706
+ $emailBody = sprintf( __( '%s (%s) has expired at %s. Post "%s" have now been set to "%s".', 'post-expirator' ),'##POSTTITLE##','##POSTLINK##','##EXPIRATIONDATE##','CATEGORIES', implode(',',_postExpiratorGetCatNames($category)));
707
  if (POSTEXPIRATOR_DEBUG) {
708
  $debug->save(array('message' => $id.' -> PROCESSED '.$expireType.' '.print_r($postoptions,true)));
709
  $debug->save(array('message' => $id.' -> CATEGORIES REPLACED '.print_r(_postExpiratorGetCatNames($category),true)));
722
  if (wp_update_post(array('ID' => $id, 'post_category' => $merged)) == 0) {
723
  if (POSTEXPIRATOR_DEBUG) $debug->save(array('message' => $id.' -> FAILED '.$expireType.' '.print_r($postoptions,true)));
724
  } else {
725
+ $emailBody = sprintf( __( '%s (%s) has expired at %s. The following post "%s" have now been added: "%s". The full list of categories on the post are: "%s".', 'post-expirator' ),'##POSTTITLE##','##POSTLINK##','##EXPIRATIONDATE##','CATEGORIES', implode(',',_postExpiratorGetCatNames($category)),implode(',',_postExpiratorGetCatNames($merged)));
726
  if (POSTEXPIRATOR_DEBUG) {
727
  $debug->save(array('message' => $id.' -> PROCESSED '.$expireType.' '.print_r($postoptions,true)));
728
  $debug->save(array('message' => $id.' -> CATEGORIES ADDED '.print_r(_postExpiratorGetCatNames($category),true)));
734
  if (is_wp_error(wp_set_object_terms($id,$terms,$categoryTaxonomy,true))) {
735
  if (POSTEXPIRATOR_DEBUG) $debug->save(array('message' => $id.' -> FAILED '.$expireType.' '.print_r($postoptions,true)));
736
  } else {
737
+ $emailBody = sprintf( __( '%s (%s) has expired at %s. The following post "%s" have now been added: "%s". The full list of categories on the post are: "%s".', 'post-expirator' ),'##POSTTITLE##','##POSTLINK##','##EXPIRATIONDATE##','CATEGORIES', implode(',',_postExpiratorGetCatNames($category)),implode(',',_postExpiratorGetCatNames($merged)));
738
  if (POSTEXPIRATOR_DEBUG) {
739
  $debug->save(array('message' => $id.' -> PROCESSED '.$expireType.' '.print_r($postoptions,true)));
740
  $debug->save(array('message' => $id.' -> CATEGORIES ADDED '.print_r(_postExpiratorGetCatNames($category),true)));
758
  if (wp_update_post(array('ID' => $id, 'post_category' => $merged)) == 0) {
759
  if (POSTEXPIRATOR_DEBUG) $debug->save(array('message' => $id.' -> FAILED '.$expireType.' '.print_r($postoptions,true)));
760
  } else {
761
+ $emailBody = sprintf( __( '%s (%s) has expired at %s. The following post "%s" have now been removed: "%s". The full list of categories on the post are: "%s".', 'post-expirator' ),'##POSTTITLE##','##POSTLINK##','##EXPIRATIONDATE##','CATEGORIES', implode(',',_postExpiratorGetCatNames($category)),implode(',',_postExpiratorGetCatNames($merged)));
762
  if (POSTEXPIRATOR_DEBUG) {
763
  $debug->save(array('message' => $id.' -> PROCESSED '.$expireType.' '.print_r($postoptions,true)));
764
  $debug->save(array('message' => $id.' -> CATEGORIES REMOVED '.print_r(_postExpiratorGetCatNames($category),true)));
777
  if (is_wp_error(wp_set_object_terms($id,$terms,$categoryTaxonomy,false))) {
778
  if (POSTEXPIRATOR_DEBUG) $debug->save(array('message' => $id.' -> FAILED '.$expireType.' '.print_r($postoptions,true)));
779
  } else {
780
+ $emailBody = sprintf( __( '%s (%s) has expired at %s. The following post "%s" have now been removed: "%s". The full list of categories on the post are: "%s".', 'post-expirator' ),'##POSTTITLE##','##POSTLINK##','##EXPIRATIONDATE##','CATEGORIES', implode(',',_postExpiratorGetCatNames($category)),implode(',',_postExpiratorGetCatNames($merged)));
781
  if (POSTEXPIRATOR_DEBUG) {
782
  $debug->save(array('message' => $id.' -> PROCESSED '.$expireType.' '.print_r($postoptions,true)));
783
  $debug->save(array('message' => $id.' -> CATEGORIES REMOVED '.print_r(_postExpiratorGetCatNames($category),true)));
789
  if (POSTEXPIRATOR_DEBUG) $debug->save(array('message' => $id.' -> CATEGORIES MISSING '.$expireType.' '.print_r($postoptions,true)));
790
  }
791
  }
792
+
793
+ //Process Email
794
+ $emailenabled = get_option('expirationdateEmailNotification',POSTEXPIRATOR_EMAILNOTIFICATION);
795
+ if ($emailenabled == 1 && isset($emailBody)) {
796
+ $subj = sprintf( __('Post Expiration Complete "%s"', 'post-expirator'), $posttitle);
797
+ $emailBody = str_replace( "##POSTTITLE##", $posttitle, $emailBody );
798
+ $emailBody = str_replace( "##POSTLINK##", $postlink, $emailBody );
799
+ $emailBody = str_replace( "##EXPIRATIONDATE##", get_date_from_gmt(gmdate('Y-m-d H:i:s',$ed),get_option('date_format').' '.get_option('time_format')), $emailBody );
800
+
801
+ $emails = array();
802
+ // Get Blog Admins
803
+ $emailadmins = get_option('expirationdateEmailNotificationAdmins',POSTEXPIRATOR_EMAILNOTIFICATIONADMINS);
804
+ if ($emailadmins == 1) {
805
+ $blogusers = get_users('role=Administrator');
806
+ foreach ($blogusers as $user) {
807
+ $emails[] = $user->user_email;
808
+ }
809
+ }
810
+
811
+ // Get Global Notification Emails
812
+ $emaillist = get_option('expirationdateEmailNotificationList');
813
+ if (isset($emaillist) && !empty(trim($emaillist))) {
814
+ $vals = explode(',',$emaillist);
815
+ foreach ($vals as $val) {
816
+ $emails[] = trim($val);
817
+ }
818
+ }
819
+
820
+ // Get Post Type Notification Emails
821
+ $defaults = get_option('expirationdateDefaults'.ucfirst($posttype));
822
+ if (isset($defaults['emailnotification']) && !empty(trim($defaults['emailnotification']))) {
823
+ $vals = explode(',',$defaults['emailnotification']);
824
+ foreach ($vals as $val) {
825
+ $emails[] = trim($val);
826
+ }
827
+ }
828
+
829
+ // Send Emails
830
+ foreach ($emails as $email) {
831
+ if (wp_mail($email, sprintf(__('[%s] %s'), get_option('blogname'), $subj), $emailBody)) {
832
+ if (POSTEXPIRATOR_DEBUG) $debug->save(array('message' => $id.' -> EXPIRATION EMAIL SENT ('.$email.')'));
833
+ } else {
834
+ if (POSTEXPIRATOR_DEBUG) $debug->save(array('message' => $id.' -> EXPIRATION EMAIL FAILED ('.$email.')'));
835
+ }
836
+ }
837
+ }
838
+
839
  }
840
  add_action('postExpiratorExpire','postExpiratorExpire');
841
 
905
  update_option('expirationdateDefaultDateFormat',$_POST['expired-default-date-format']);
906
  update_option('expirationdateDefaultTimeFormat',$_POST['expired-default-time-format']);
907
  update_option('expirationdateDisplayFooter',$_POST['expired-display-footer']);
908
+ update_option('expirationdateEmailNotification',$_POST['expired-email-notification']);
909
+ update_option('expirationdateEmailNotificationAdmins',$_POST['expired-email-notification-admins']);
910
+ update_option('expirationdateEmailNotificationList',$_POST['expired-email-notification-list']);
911
  update_option('expirationdateFooterContents',$_POST['expired-footer-contents']);
912
  update_option('expirationdateFooterStyle',$_POST['expired-footer-style']);
913
  if (isset($_POST['expirationdate_category'])) update_option('expirationdateCategoryDefaults',$_POST['expirationdate_category']);
923
  $expirationdateDefaultDateFormat = get_option('expirationdateDefaultDateFormat',POSTEXPIRATOR_DATEFORMAT);
924
  $expirationdateDefaultTimeFormat = get_option('expirationdateDefaultTimeFormat',POSTEXPIRATOR_TIMEFORMAT);
925
  $expireddisplayfooter = get_option('expirationdateDisplayFooter',POSTEXPIRATOR_FOOTERDISPLAY);
926
+ $expiredemailnotification = get_option('expirationdateEmailNotification',POSTEXPIRATOR_EMAILNOTIFICATION);
927
+ $expiredemailnotificationadmins = get_option('expirationdateEmailNotificationAdmins',POSTEXPIRATOR_EMAILNOTIFICATIONADMINS);
928
+ $expiredemailnotificationlist = get_option('expirationdateEmailNotificationList','');
929
  $expirationdateFooterContents = get_option('expirationdateFooterContents',POSTEXPIRATOR_FOOTERCONTENTS);
930
  $expirationdateFooterStyle = get_option('expirationdateFooterStyle',POSTEXPIRATOR_FOOTERSTYLE);
931
  $expirationdateDefaultDate = get_option('expirationdateDefaultDate',POSTEXPIRATOR_EXPIREDEFAULT);
939
  $expireddisplayfooterdisabled = 'checked="checked"';
940
  else if ($expireddisplayfooter == 1)
941
  $expireddisplayfooterenabled = 'checked="checked"';
942
+
943
+ $expiredemailnotificationenabled = '';
944
+ $expiredemailnotificationdisabled = '';
945
+ if ($expiredemailnotification == 0)
946
+ $expiredemailnotificationdisabled = 'checked="checked"';
947
+ else if ($expiredemailnotification == 1)
948
+ $expiredemailnotificationenabled = 'checked="checked"';
949
+
950
+ $expiredemailnotificationadminsenabled = '';
951
+ $expiredemailnotificationadminsdisabled = '';
952
+ if ($expiredemailnotificationadmins == 0)
953
+ $expiredemailnotificationadminsdisabled = 'checked="checked"';
954
+ else if ($expiredemailnotificationadmins == 1)
955
+ $expiredemailnotificationadminsenabled = 'checked="checked"';
956
  ?>
957
  <p>
958
  <?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'); ?>
969
  <?php wp_nonce_field('postExpiratorMenuGeneral','_postExpiratorMenuGeneral_nonce'); ?>
970
  <h3><?php _e('Defaults','post-expirator'); ?></h3>
971
  <table class="form-table">
972
+ <tr valign="top">
973
  <th scope="row"><label for="expired-default-date-format"><?php _e('Date Format:','post-expirator');?></label></th>
974
  <td>
975
  <input type="text" name="expired-default-date-format" id="expired-default-date-format" value="<?php echo $expirationdateDefaultDateFormat ?>" size="25" /> (<?php echo date_i18n("$expirationdateDefaultDateFormat") ?>)
977
  <?php _e('The default format to use when displaying the expiration date 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'); ?>
978
  </td>
979
  </tr>
980
+ <tr valign="top">
981
  <th scope="row"><label for="expired-default-time-format"><?php _e('Time Format:','post-expirator');?></label></th>
982
  <td>
983
  <input type="text" name="expired-default-time-format" id="expired-default-time-format" value="<?php echo $expirationdateDefaultTimeFormat ?>" size="25" /> (<?php echo date_i18n("$expirationdateDefaultTimeFormat") ?>)
985
  <?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'); ?>
986
  </td>
987
  </tr>
988
+ <tr valign="top">
989
  <th scope="row"><label for="expired-default-expiration-date"><?php _e('Default Date/Time Duration:','post-expirator');?></label></th>
990
  <td>
991
  <select name="expired-default-expiration-date" id="expired-default-expiration-date" onchange="expirationdate_toggle_defaultdate(this)">
1006
  </table>
1007
  <h3><?php _e('Category Expiration','post-expirator');?></h3>
1008
  <table class="form-table">
1009
+ <tr valign="top">
1010
  <th scope="row"><?php _e('Default Expiration Category','post-expirator');?>:</th>
1011
  <td>
1012
  <?php
1023
  </tr>
1024
  </table>
1025
 
1026
+ <h3><?php _e('Expiration Email Notification','post-expirator');?></h3>
1027
+ <p><?php _e('Whenever a post expires, an email can be sent to alert users of the expiration.','post-expirator');?></p>
1028
+ <table class="form-table">
1029
+ <tr valign="top">
1030
+ <th scope="row"><?php _e('Enable Email Notification?','post-expirator');?></th>
1031
+ <td>
1032
+ <input type="radio" name="expired-email-notification" id="expired-email-notification-true" value="1" <?php echo $expiredemailnotificationenabled ?>/> <label for="expired-email-notification-true"><?php _e('Enabled','post-expirator');?></label>
1033
+ <br/>
1034
+ <input type="radio" name="expired-email-notification" id="expired-email-notification-false" value="0" <?php echo $expiredemailnotificationdisabled ?>/> <label for="expired-email-notification-false"><?php _e('Disabled','post-expirator');?></label>
1035
+ <br/>
1036
+ <?php _e('This will enable or disable the send of email notification on post expiration.','post-expirator');?>
1037
+ </td>
1038
+ </tr>
1039
+ <tr valign="top">
1040
+ <th scope="row"><?php _e('Include Blog Administrators?','post-expirator');?></th>
1041
+ <td>
1042
+ <input type="radio" name="expired-email-notification-admins" id="expired-email-notification-admins-true" value="1" <?php echo $expiredemailnotificationadminsenabled ?>/> <label for="expired-email-notification-admins-true"><?php _e('Enabled','post-expirator');?></label>
1043
+ <br/>
1044
+ <input type="radio" name="expired-email-notification-admins" id="expired-email-notification-admins-false" value="0" <?php echo $expiredemailnotificationadminsdisabled ?>/> <label for="expired-email-notification-admins-false"><?php _e('Disabled','post-expirator');?></label>
1045
+ <br/>
1046
+ <?php _e('This will include all users with the role of "Administrator" in the post expiration email.','post-expirator');?>
1047
+ </td>
1048
+ </tr>
1049
+ <tr valign="top">
1050
+ <th scope="row"><label for="expired-email-notification-list"><?php _e('Who to notify:','post-expirator'); ?></label></th>
1051
+ <td>
1052
+ <input class="large-text" type="text" name="expired-email-notification-list" id="expired-email-notification-list" value="<?php echo $expiredemailnotificationlist ?>" />
1053
+ <br/>
1054
+ <?php _e('Enter a comma seperate list of emails that you would like to be notified when the post expires. This will be applied to ALL post types. You can set post type specific emails on the Defaults tab.','post-expirator');?>
1055
+ </td>
1056
+ </tr>
1057
+ </table>
1058
+
1059
  <h3><?php _e('Post Footer Display','post-expirator');?></h3>
1060
  <p><?php _e('Enabling this below will display the expiration date automatically at the end of any post which is set to expire.','post-expirator');?></p>
1061
  <table class="form-table">
1062
+ <tr valign="top">
1063
  <th scope="row"><?php _e('Show in post footer?','post-expirator');?></th>
1064
  <td>
1065
+ <input type="radio" name="expired-display-footer" id="expired-display-footer-true" value="1" <?php echo $expireddisplayfooterenabled ?>/> <label for="expired-display-footer-true"><?php _e('Enabled','post-expirator');?></label>
1066
+ <br/>
1067
  <input type="radio" name="expired-display-footer" id="expired-display-footer-false" value="0" <?php echo $expireddisplayfooterdisabled ?>/> <label for="expired-display-footer-false"><?php _e('Disabled','post-expirator');?></label>
1068
  <br/>
1069
  <?php _e('This will enable or disable displaying the post expiration date in the post footer.','post-expirator');?>
1070
  </td>
1071
  </tr>
1072
+ <tr valign="top">
1073
  <th scope="row"><label for="expired-footer-contents"><?php _e('Footer Contents:','post-expirator');?></label></th>
1074
  <td>
1075
  <textarea id="expired-footer-contents" name="expired-footer-contents" rows="3" cols="50"><?php echo $expirationdateFooterContents; ?></textarea>
1082
  </ul>
1083
  </td>
1084
  </tr>
1085
+ <tr valign="top">
1086
  <th scope="row"><label for="expired-footer-style"><?php _e('Footer Style:','post-expirator');?></label></th>
1087
  <td>
1088
  <input type="text" name="expired-footer-style" id="expired-footer-style" value="<?php echo $expirationdateFooterStyle ?>" size="25" />
1126
  if (isset($_POST['expirationdate_activemeta-'.$type])) {
1127
  $defaults[$type]['activeMetaBox'] = $_POST['expirationdate_activemeta-'.$type];
1128
  }
1129
+ $defaults[$type]['emailnotification'] = $_POST['expirationdate_emailnotification-'.$type];
1130
 
1131
  //Save Settings
1132
  update_option('expirationdateDefaults'.ucfirst($type),$defaults[$type]);
1149
  echo "<fieldset style='border: 1px solid black; border-radius: 6px; padding: 0px 12px; margin-bottom: 20px;'>";
1150
  echo "<legend>Post Type: $type</legend>";
1151
  $defaults = get_option('expirationdateDefaults'.ucfirst($type));
1152
+
1153
  if (isset($defaults['autoEnable']) && $defaults['autoEnable'] == 1) {
1154
  $expiredautoenabled = 'checked = "checked"';
1155
  $expiredautodisabled = '';
1169
  }
1170
  ?>
1171
  <table class="form-table">
1172
+ <tr valign="top">
1173
  <th scope="row"><label for="expirationdate_activemeta-<?php echo $type ?>"><?php _e('Active:','post-expirator');?></label></th>
1174
  <td>
1175
+ <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>
1176
+ <br/>
1177
  <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>
1178
  <br/>
1179
  <?php _e('Select whether the post expirator meta box is active for this post type.','post-expirator');?>
1180
  </td>
1181
  </tr>
1182
+ <tr valign="top">
1183
  <th scope="row"><label for="expirationdate_expiretype-<?php echo $type ?>"><?php _e('How to expire:','post-expirator'); ?></label></th>
1184
  <td>
1185
  <?php echo _postExpiratorExpireType(array('name'=>'expirationdate_expiretype-'.$type,'selected' => $defaults['expireType'])); ?>
1188
  <?php _e('Select the default expire action for the post type.','post-expirator');?>
1189
  </td>
1190
  </tr>
1191
+ <tr valign="top">
1192
  <th scope="row"><label for="expirationdate_autoenable-<?php echo $type ?>"><?php _e('Auto-Enable?','post-expirator');?></label></th>
1193
  <td>
1194
+ <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>
1195
+ <br/>
1196
  <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>
1197
  <br/>
1198
  <?php _e('Select whether the post expirator is enabled for all new posts.','post-expirator');?>
1199
  </td>
1200
  </tr>
1201
+ <tr valign="top">
1202
  <th scope="row"><label for="expirationdate_taxonomy-<?php echo $type ?>"><?php _e('Taxonomy (hierarchical):','post-expirator'); ?></label></th>
1203
  <td>
1204
  <?php echo _postExpiratorTaxonomy(array('type' => $type, 'name'=>'expirationdate_taxonomy-'.$type,'selected' => $defaults['taxonomy'])); ?>
1205
  </td>
1206
  </tr>
1207
+ <tr valign="top">
1208
+ <th scope="row"><label for="expirationdate_emailnotification-<?php echo $type ?>"><?php _e('Who to notify:','post-expirator'); ?></label></th>
1209
+ <td>
1210
+ <input class="large-text" type="text" name="expirationdate_emailnotification-<?php echo $type ?>" id="expirationdate_emailnotification-<?php echo $type ?>" value="<?php echo $defaults['emailnotification']; ?>" />
1211
+ <br/>
1212
+ <?php _e('Enter a comma seperate list of emails that you would like to be notified when the post expires.','post-expirator');?>
1213
+ </td>
1214
+ </tr>
1215
+
1216
  </table>
1217
  </fieldset>
1218
  <?php
1251
  <?php wp_nonce_field('postExpiratorMenuDiagnostics','_postExpiratorMenuDiagnostics_nonce'); ?>
1252
  <h3><?php _e('Advanced Diagnostics','post-expirator');?></h3>
1253
  <table class="form-table">
1254
+ <tr valign="top">
1255
  <th scope="row"><label for="postexpirator-log"><?php _e('Post Expirator Debug Logging:','post-expirator');?></label></th>
1256
  <td>
1257
  <?php
1267
  <a href="<?php echo admin_url('options-general.php?page=post-expirator.php&tab=viewdebug') ?>">View Debug Logs</a>
1268
  </td>
1269
  </tr>
1270
+ <tr valign="top">
1271
  <th scope="row"><?php _e('Purge Debug Log:','post-expirator');?></th>
1272
  <td>
1273
  <input type="submit" class="button" name="purge-debug" id="purge-debug" value="<?php _e('Purge Debug Log','post-expirator');?>" />
1274
  </td>
1275
  </tr/>
1276
+ <tr valign="top">
1277
  <th scope="row"><?php _e('WP-Cron Status:','post-expirator');?></th>
1278
  <td>
1279
  <?php
1285
  ?>
1286
  </td>
1287
  </tr/>
1288
+ <tr valign="top">
1289
  <th scope="row"><label for="cron-schedule"><?php _e('Current Cron Schedule:','post-expirator');?></label></th>
1290
  <td>
1291
  <?php _e('The below table will show all currently scheduled cron events with the next run time.','post-expirator');?><br/>
1528
  if (version_compare($version,'2.2.1') == -1) {
1529
  update_option('postexpiratorVersion',POSTEXPIRATOR_VERSION);
1530
  }
1531
+ if (version_compare($version,'2.3.0') == -1) {
1532
  update_option('postexpiratorVersion',POSTEXPIRATOR_VERSION);
1533
  }
1534
  }
1631
  $rv[] = '<select name="'.$name.'" id="'.$id.'"'.($disabled == true ? ' disabled="disabled"' : '').' onchange="'.$onchange.'">';
1632
  $rv[] = '<option value="draft" '. ($selected == 'draft' ? 'selected="selected"' : '') . '>'.__('Draft','post-expirator').'</option>';
1633
  $rv[] = '<option value="delete" '. ($selected == 'delete' ? 'selected="selected"' : '') . '>'.__('Delete','post-expirator').'</option>';
1634
+ $rv[] = '<option value="trash" '. ($selected == 'trash' ? 'selected="selected"' : '') . '>'.__('Trash','post-expirator').'</option>';
1635
  $rv[] = '<option value="private" '. ($selected == 'private' ? 'selected="selected"' : '') . '>'.__('Private','post-expirator').'</option>';
1636
+ $rv[] = '<option value="stick" '. ($selected == 'stick' ? 'selected="selected"' : '') . '>'.__('Stick','post-expirator').'</option>';
1637
+ $rv[] = '<option value="unstick" '. ($selected == 'unstick' ? 'selected="selected"' : '') . '>'.__('Unstick','post-expirator').'</option>';
1638
  if ($type != 'page') {
1639
  $rv[] = '<option value="category" '. ($selected == 'category' ? 'selected="selected"' : '') . '>'.__('Category: Replace','post-expirator').'</option>';
1640
  $rv[] = '<option value="category-add" '. ($selected == 'category-add' ? 'selected="selected"' : '') . '>'.__('Category: Add','post-expirator').'</option>';
1707
  $ed = get_post_meta($post_id,'_expiration-date',true);
1708
  if ($ed) {
1709
  $opts = get_post_meta($post_id, '_expiration-date-options', true);
1710
+ #_scheduleExpiratorEvent($post_id,$ts,$opts);
1711
  }
1712
  }
1713
  }
readme.txt CHANGED
@@ -4,23 +4,32 @@ Donate link: http://aaron.axelsen.us/donate
4
  Tags: expire, posts, pages, schedule
5
  Requires at least: 4.0
6
  Tested up to: 4.8
7
- Stable tag: 2.2.2
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.
11
 
12
  == Description ==
13
 
14
- The Post Expirator plugin allows the user to set expiration dates for both posts and pages. There is a configuration option page in the plugins
15
- area that will allow you to seperataly control whether or not posts/pages are either deleted or changed to draft status. Additionally you can
16
- also choose to have the post categories change at expiration time. If you choose to change the post category, the default action of changing
17
- the status will be ignored.
18
 
19
- The plugin hooks into the wp cron processes and runs every minute by default, but can be configured to use any cron schedule (hourly, twicedaily, daily, etc).
 
 
 
 
 
 
 
 
 
 
20
 
21
  The expiration date can be displayed within the actual post by using the [postexpirator] tag. The format attribute will override the plugin
22
  default display format. See the [PHP Date Function](http://us2.php.net/manual/en/function.date.php) for valid date/time format options.
23
 
 
 
24
  Plugin homepage [WordPress Post Expirator](http://postexpirator.tuxdocs.net).
25
 
26
  New! [Feature Requests](http://postexpirator.uservoice.com) Please enter all feature requests here. Requests entered via the plugin website or support forum may be missed.
@@ -48,7 +57,16 @@ This section describes how to install the plugin and get it working.
48
 
49
  == Changelog ==
50
 
 
 
 
 
 
 
 
 
51
  **Version 2.2.2**
 
52
  * Fix: Quick Edit did not retain the expire type setting, and defaulted back to "Draft". This has been resolved.
53
 
54
  **Version 2.2.1**
4
  Tags: expire, posts, pages, schedule
5
  Requires at least: 4.0
6
  Tested up to: 4.8
7
+ Stable tag: 2.3.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.
11
 
12
  == Description ==
13
 
14
+ The Post Expirator plugin allows the user to set expiration dates for both posts and pages. There are a number of different ways that the posts can expire:
 
 
 
15
 
16
+ * Draft
17
+ * Delete
18
+ * Trash
19
+ * Private
20
+ * Stick
21
+ * Unstick
22
+ * Categories: Replace
23
+ * Categories: Add
24
+ * Categories: Remove
25
+
26
+ For each expiration event, a custom cron job will be schedule which will help reduce server overhead for busy sites.
27
 
28
  The expiration date can be displayed within the actual post by using the [postexpirator] tag. The format attribute will override the plugin
29
  default display format. See the [PHP Date Function](http://us2.php.net/manual/en/function.date.php) for valid date/time format options.
30
 
31
+ NOTE: This plugin REQUIRES that WP-CRON is setup and functional on your webhost. Some hosts do not support this, so please check and confirm if you run into issues using the plugin.
32
+
33
  Plugin homepage [WordPress Post Expirator](http://postexpirator.tuxdocs.net).
34
 
35
  New! [Feature Requests](http://postexpirator.uservoice.com) Please enter all feature requests here. Requests entered via the plugin website or support forum may be missed.
57
 
58
  == Changelog ==
59
 
60
+ **Version 2.3.0**
61
+
62
+ * New: Email notification upon post expiration. A global email can be set, blog admins can be selected and/or specific users based on post type can be notified.
63
+ * New: Expiration Option Added - Stick/Unstick post is now available.
64
+ * New: Expiration Option Added - Trash post is now available.
65
+ * New: Added custom actions that can be hooked into when expiration events are scheduled / unscheduled.
66
+ * Fix: Minor HTML Code Issues
67
+
68
  **Version 2.2.2**
69
+
70
  * Fix: Quick Edit did not retain the expire type setting, and defaulted back to "Draft". This has been resolved.
71
 
72
  **Version 2.2.1**