Post Expirator - Version 2.1.2

Version Description

Important Update - Security Fixes - See Changelog

Download this release

Release Info

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

Code changes from version 2.1.1 to 2.1.2

Files changed (2) hide show
  1. post-expirator.php +83 -42
  2. readme.txt +15 -5
post-expirator.php CHANGED
@@ -4,7 +4,7 @@ Plugin Name: Post Expirator
4
  Plugin URI: http://wordpress.org/extend/plugins/post-expirator/
5
  Description: Allows you to add an expiration date (minute) to posts which you can configure to either delete the post, change it to a draft, or update the post categories at expiration time.
6
  Author: Aaron Axelsen
7
- Version: 2.1.1
8
  Author URI: http://postexpirator.tuxdocs.net/
9
  Translation: Thierry (http://palijn.info)
10
  Text Domain: post-expirator
@@ -403,7 +403,7 @@ function _scheduleExpiratorEvent($id,$ts,$opts) {
403
 
404
  if (wp_next_scheduled('postExpiratorExpire',array($id)) !== false) {
405
  wp_clear_scheduled_hook('postExpiratorExpire',array($id)); //Remove any existing hooks
406
- if (POSTEXPIRATOR_DEBUG) $debug->save(array('message' => $id.' -> UNSCHEDULED'));
407
  }
408
 
409
  wp_schedule_single_event($ts,'postExpiratorExpire',array($id));
@@ -604,8 +604,8 @@ function postExpiratorMenuTabs($tab) {
604
  if (empty($tab)) $tab = 'general';
605
  echo '<a href="'.admin_url('options-general.php?page=post-expirator.php&tab=general').'"'.($tab == 'general' ? ' style="font-weight: bold; text-decoration:none;"' : '').'>'.__('General Settings','post-expirator').'</a> | ';
606
  echo '<a href="'.admin_url('options-general.php?page=post-expirator.php&tab=defaults').'"'.($tab == 'defaults' ? ' style="font-weight: bold; text-decoration:none;"' : '').'>'.__('Defaults','post-expirator').'</a> | ';
607
- echo '<a href="'.admin_url('options-general.php?page=post-expirator.php&tab=diagnostics').'"'.($tab == 'diagnostics' ? ' style="font-weight: bold; text-decoration:none;"' : '').'>'.__('Diagnostics','post-expirator').'</a>';
608
- echo ' | <a href="'.admin_url('options-general.php?page=post-expirator.php&tab=viewdebug').'"'.($tab == 'viewdebug' ? ' style="font-weight: bold; text-decoration:none;"' : '').'>'.__('View Debug Logs','post-expirator').'</a>';
609
  echo '</p><hr/>';
610
  }
611
 
@@ -643,19 +643,27 @@ add_action('admin_menu', 'postExpiratorPluginMenu');
643
  * Show the Expiration Date options page
644
  */
645
  function postExpiratorMenuGeneral() {
646
-
647
  if (isset($_POST['expirationdateSave']) && $_POST['expirationdateSave']) {
648
- update_option('expirationdateDefaultDateFormat',$_POST['expired-default-date-format']);
649
- update_option('expirationdateDefaultTimeFormat',$_POST['expired-default-time-format']);
650
- update_option('expirationdateDisplayFooter',$_POST['expired-display-footer']);
651
- update_option('expirationdateFooterContents',$_POST['expired-footer-contents']);
652
- update_option('expirationdateFooterStyle',$_POST['expired-footer-style']);
653
- if (isset($_POST['expirationdate_category'])) update_option('expirationdateCategoryDefaults',$_POST['expirationdate_category']);
654
- update_option('expirationdateDefaultDate',$_POST['expired-default-expiration-date']);
655
- if ($_POST['expired-custom-expiration-date']) update_option('expirationdateDefaultDateCustom',$_POST['expired-custom-expiration-date']);
656
- echo "<div id='message' class='updated fade'><p>";
657
- _e('Saved Options!','post-expirator');
658
- echo "</p></div>";
 
 
 
 
 
 
 
 
 
659
  }
660
 
661
  // Get Option
@@ -688,6 +696,7 @@ function postExpiratorMenuGeneral() {
688
  </ul>
689
  </p>
690
  <form method="post" id="expirationdate_save_options">
 
691
  <h3><?php _e('Defaults','post-expirator'); ?></h3>
692
  <table class="form-table">
693
  <tr valign-"top">
@@ -792,28 +801,41 @@ function postExpiratorMenuDefaults() {
792
  array_unshift($types,'post','page');
793
 
794
  if (isset($_POST['expirationdateSaveDefaults'])) {
795
- $defaults = array();
796
- foreach ($types as $type) {
797
- if (isset($_POST['expirationdate_expiretype-'.$type])) {
798
- $defaults[$type]['expireType'] = $_POST['expirationdate_expiretype-'.$type];
799
- }
800
- if (isset($_POST['expirationdate_autoenable-'.$type])) {
801
- $defaults[$type]['autoEnable'] = intval($_POST['expirationdate_autoenable-'.$type]);
802
- }
803
- if (isset($_POST['expirationdate_taxonomy-'.$type])) {
804
- $defaults[$type]['taxonomy'] = $_POST['expirationdate_taxonomy-'.$type];
805
- }
806
- if (isset($_POST['expirationdate_activemeta-'.$type])) {
807
- $defaults[$type]['activeMetaBox'] = $_POST['expirationdate_activemeta-'.$type];
808
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
809
 
810
- //Save Settings
811
- update_option('expirationdateDefaults'.ucfirst($type),$defaults[$type]);
 
 
 
 
812
  }
813
  }
814
 
815
  ?>
816
  <form method="post">
 
817
  <h3><?php _e('Default Expiration Values','post-expirator');?></h3>
818
  <p>
819
  <?php _e('Use the values below to set the default actions/values to be used for each for the corresponding post types. These values can all be overwritten when creating/editing the post/page.','post-expirator'); ?>
@@ -886,22 +908,29 @@ function postExpiratorMenuDefaults() {
886
  }
887
 
888
  function postExpiratorMenuDiagnostics() {
889
- if (isset($_POST['debugging-disable'])) {
890
- update_option('expirationdateDebug',0);
891
- echo "<div id='message' class='updated fade'><p>"; _e('Debugging Disabled','post-expirator'); echo "</p></div>";
892
- } elseif (isset($_POST['debugging-enable'])) {
893
- update_option('expirationdateDebug',1);
894
- echo "<div id='message' class='updated fade'><p>"; _e('Debugging Enabled','post-expirator'); echo "</p></div>";
895
- } elseif (isset($_POST['purge-debug'])) {
896
- require_once(plugin_dir_path(__FILE__).'post-expirator-debug.php');
897
- $debug = new postExpiratorDebug();
898
- $debug->purge();
899
- echo "<div id='message' class='updated fade'><p>"; _e('Debugging Table Emptied','post-expirator'); echo "</p></div>";
 
 
 
 
 
 
900
  }
901
 
902
  $debug = postExpiratorDebug();
903
  ?>
904
  <form method="post" id="postExpiratorMenuUpgrade">
 
905
  <h3><?php _e('Advanced Diagnostics','post-expirator');?></h3>
906
  <table class="form-table">
907
  <tr valign-"top">
@@ -926,6 +955,18 @@ function postExpiratorMenuDiagnostics() {
926
  <input type="submit" class="button" name="purge-debug" id="purge-debug" value="<?php _e('Purge Debug Log','post-expirator');?>" />
927
  </td>
928
  </tr/>
 
 
 
 
 
 
 
 
 
 
 
 
929
  <tr valign-"top">
930
  <th scope="row"><label for="cron-schedule"><?php _e('Current Cron Schedule:','post-expirator');?></label></th>
931
  <td>
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.2
8
  Author URI: http://postexpirator.tuxdocs.net/
9
  Translation: Thierry (http://palijn.info)
10
  Text Domain: post-expirator
403
 
404
  if (wp_next_scheduled('postExpiratorExpire',array($id)) !== false) {
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));
604
  if (empty($tab)) $tab = 'general';
605
  echo '<a href="'.admin_url('options-general.php?page=post-expirator.php&tab=general').'"'.($tab == 'general' ? ' style="font-weight: bold; text-decoration:none;"' : '').'>'.__('General Settings','post-expirator').'</a> | ';
606
  echo '<a href="'.admin_url('options-general.php?page=post-expirator.php&tab=defaults').'"'.($tab == 'defaults' ? ' style="font-weight: bold; text-decoration:none;"' : '').'>'.__('Defaults','post-expirator').'</a> | ';
607
+ echo '<a href="'.admin_url('options-general.php?page=post-expirator.php&tab=diagnostics').'"'.($tab == 'diagnostics' ? ' style="font-weight: bold; text-decoration:none;"' : '').'>'.__('Diagnostics','post-expirator').'</a> | ';
608
+ echo '<a href="'.admin_url('options-general.php?page=post-expirator.php&tab=viewdebug').'"'.($tab == 'viewdebug' ? ' style="font-weight: bold; text-decoration:none;"' : '').'>'.__('View Debug Logs','post-expirator').'</a>';
609
  echo '</p><hr/>';
610
  }
611
 
643
  * Show the Expiration Date options page
644
  */
645
  function postExpiratorMenuGeneral() {
 
646
  if (isset($_POST['expirationdateSave']) && $_POST['expirationdateSave']) {
647
+ if ( !isset($_POST['_postExpiratorMenuGeneral_nonce']) || !wp_verify_nonce($_POST['_postExpiratorMenuGeneral_nonce'],'postExpiratorMenuGeneral') ) {
648
+ print 'Form Validation Failure: Sorry, your nonce did not verify.';
649
+ exit;
650
+ } else {
651
+ //Filter Content
652
+ foreach ($_POST as $key=>$value) {
653
+ $_POST[$key] = filter_input(INPUT_POST,$key,FILTER_SANITIZE_STRING);
654
+ }
655
+ update_option('expirationdateDefaultDateFormat',$_POST['expired-default-date-format']);
656
+ update_option('expirationdateDefaultTimeFormat',$_POST['expired-default-time-format']);
657
+ update_option('expirationdateDisplayFooter',$_POST['expired-display-footer']);
658
+ update_option('expirationdateFooterContents',$_POST['expired-footer-contents']);
659
+ update_option('expirationdateFooterStyle',$_POST['expired-footer-style']);
660
+ if (isset($_POST['expirationdate_category'])) update_option('expirationdateCategoryDefaults',$_POST['expirationdate_category']);
661
+ update_option('expirationdateDefaultDate',$_POST['expired-default-expiration-date']);
662
+ if ($_POST['expired-custom-expiration-date']) update_option('expirationdateDefaultDateCustom',$_POST['expired-custom-expiration-date']);
663
+ echo "<div id='message' class='updated fade'><p>";
664
+ _e('Saved Options!','post-expirator');
665
+ echo "</p></div>";
666
+ }
667
  }
668
 
669
  // Get Option
696
  </ul>
697
  </p>
698
  <form method="post" id="expirationdate_save_options">
699
+ <?php wp_nonce_field('postExpiratorMenuGeneral','_postExpiratorMenuGeneral_nonce'); ?>
700
  <h3><?php _e('Defaults','post-expirator'); ?></h3>
701
  <table class="form-table">
702
  <tr valign-"top">
801
  array_unshift($types,'post','page');
802
 
803
  if (isset($_POST['expirationdateSaveDefaults'])) {
804
+ if ( !isset($_POST['_postExpiratorMenuDefaults_nonce']) || !wp_verify_nonce($_POST['_postExpiratorMenuDefaults_nonce'],'postExpiratorMenuDefaults') ) {
805
+ print 'Form Validation Failure: Sorry, your nonce did not verify.';
806
+ exit;
807
+ } else {
808
+ //Filter Content
809
+ foreach ($_POST as $key=>$value) {
810
+ $_POST[$key] = filter_input(INPUT_POST,$key,FILTER_SANITIZE_STRING);
 
 
 
 
 
 
811
  }
812
+ $defaults = array();
813
+ foreach ($types as $type) {
814
+ if (isset($_POST['expirationdate_expiretype-'.$type])) {
815
+ $defaults[$type]['expireType'] = $_POST['expirationdate_expiretype-'.$type];
816
+ }
817
+ if (isset($_POST['expirationdate_autoenable-'.$type])) {
818
+ $defaults[$type]['autoEnable'] = intval($_POST['expirationdate_autoenable-'.$type]);
819
+ }
820
+ if (isset($_POST['expirationdate_taxonomy-'.$type])) {
821
+ $defaults[$type]['taxonomy'] = $_POST['expirationdate_taxonomy-'.$type];
822
+ }
823
+ if (isset($_POST['expirationdate_activemeta-'.$type])) {
824
+ $defaults[$type]['activeMetaBox'] = $_POST['expirationdate_activemeta-'.$type];
825
+ }
826
 
827
+ //Save Settings
828
+ update_option('expirationdateDefaults'.ucfirst($type),$defaults[$type]);
829
+ }
830
+ echo "<div id='message' class='updated fade'><p>";
831
+ _e('Saved Options!','post-expirator');
832
+ echo "</p></div>";
833
  }
834
  }
835
 
836
  ?>
837
  <form method="post">
838
+ <?php wp_nonce_field('postExpiratorMenuDefaults','_postExpiratorMenuDefaults_nonce'); ?>
839
  <h3><?php _e('Default Expiration Values','post-expirator');?></h3>
840
  <p>
841
  <?php _e('Use the values below to set the default actions/values to be used for each for the corresponding post types. These values can all be overwritten when creating/editing the post/page.','post-expirator'); ?>
908
  }
909
 
910
  function postExpiratorMenuDiagnostics() {
911
+ if ($_SERVER['REQUEST_METHOD'] == 'POST') {
912
+ if ( !isset($_POST['_postExpiratorMenuDiagnostics_nonce']) || !wp_verify_nonce($_POST['_postExpiratorMenuDiagnostics_nonce'],'postExpiratorMenuDiagnostics') ) {
913
+ print 'Form Validation Failure: Sorry, your nonce did not verify.';
914
+ exit;
915
+ }
916
+ if (isset($_POST['debugging-disable'])) {
917
+ update_option('expirationdateDebug',0);
918
+ echo "<div id='message' class='updated fade'><p>"; _e('Debugging Disabled','post-expirator'); echo "</p></div>";
919
+ } elseif (isset($_POST['debugging-enable'])) {
920
+ update_option('expirationdateDebug',1);
921
+ echo "<div id='message' class='updated fade'><p>"; _e('Debugging Enabled','post-expirator'); echo "</p></div>";
922
+ } elseif (isset($_POST['purge-debug'])) {
923
+ require_once(plugin_dir_path(__FILE__).'post-expirator-debug.php');
924
+ $debug = new postExpiratorDebug();
925
+ $debug->purge();
926
+ echo "<div id='message' class='updated fade'><p>"; _e('Debugging Table Emptied','post-expirator'); echo "</p></div>";
927
+ }
928
  }
929
 
930
  $debug = postExpiratorDebug();
931
  ?>
932
  <form method="post" id="postExpiratorMenuUpgrade">
933
+ <?php wp_nonce_field('postExpiratorMenuDiagnostics','_postExpiratorMenuDiagnostics_nonce'); ?>
934
  <h3><?php _e('Advanced Diagnostics','post-expirator');?></h3>
935
  <table class="form-table">
936
  <tr valign-"top">
955
  <input type="submit" class="button" name="purge-debug" id="purge-debug" value="<?php _e('Purge Debug Log','post-expirator');?>" />
956
  </td>
957
  </tr/>
958
+ <tr valign-"top">
959
+ <th scope="row"><?php _e('WP-Cron Status:','post-expirator');?></th>
960
+ <td>
961
+ <?php
962
+ if (defined('DISABLE_WP_CRON') && DISABLE_WP_CRON === true) {
963
+ _e('DISABLED','post-expirator');
964
+ } else {
965
+ _e('ENABLED - OK','post-expirator');
966
+ }
967
+ ?>
968
+ </td>
969
+ </tr/>
970
  <tr valign-"top">
971
  <th scope="row"><label for="cron-schedule"><?php _e('Current Cron Schedule:','post-expirator');?></label></th>
972
  <td>
readme.txt CHANGED
@@ -1,9 +1,9 @@
1
  === Post Expirator ===
2
  Contributors: axelseaa
3
  Tags: expire, posts, pages, schedule
4
- Requires at least: 3.2
5
- Tested up to: 3.5.1
6
- Stable tag: 2.1.1
7
 
8
  Allows you to add an expiration date to posts which you can configure to either delete the post, change it to a draft, or update the
9
  post categories.
@@ -47,10 +47,17 @@ This section describes how to install the plugin and get it working.
47
 
48
  == Changelog ==
49
 
 
 
 
 
 
 
 
50
  **Version 2.1.1**
51
 
52
- * FIX: Fixed php warning issue cause when post type defaults are not set
53
- * NEW: Added the option to disable post expirator for certain post types if desired
54
 
55
  **Version 2.1.0**
56
 
@@ -188,6 +195,9 @@ NOTE: After upgrading, you may need to reset the cron schedules. Following onsc
188
 
189
  == Upgrade Notice ==
190
 
 
 
 
191
  = 2.0.1 =
192
  Removes old scheduled hook - this was not done completely in the 2.0.0 upgrade
193
 
1
  === Post Expirator ===
2
  Contributors: axelseaa
3
  Tags: expire, posts, pages, schedule
4
+ Requires at least: 3.7
5
+ Tested up to: 3.8.1
6
+ Stable tag: 2.1.2
7
 
8
  Allows you to add an expiration date to posts which you can configure to either delete the post, change it to a draft, or update the
9
  post categories.
47
 
48
  == Changelog ==
49
 
50
+ **Version 2.1.2**
51
+
52
+ * Security: Added form nonce for protect agaisnt possible CSRF
53
+ * Security: Fixed XSS issue on settings pages
54
+ * New: Added check to show if WP_CRON is enabled on diagnostics page
55
+ * Fix: Minor Code Cleanup
56
+
57
  **Version 2.1.1**
58
 
59
+ * New: Added the option to disable post expirator for certain post types if desired
60
+ * Fix: Fixed php warning issue cause when post type defaults are not set
61
 
62
  **Version 2.1.0**
63
 
195
 
196
  == Upgrade Notice ==
197
 
198
+ = 2.1.2 =
199
+ Important Update - Security Fixes - See Changelog
200
+
201
  = 2.0.1 =
202
  Removes old scheduled hook - this was not done completely in the 2.0.0 upgrade
203