Electric Studio Auto Post Expire

February 14, 2014

Electric Studio Auto Post Expire Plugin

Adds an expiry date and time to posts, pages, or custom post types after which the post becomes expired.

Adds an expiry date and time to posts, pages, or custom post types in which the post becomes a draft.

  • Supports custom post types
  • Allows admin to choose which post types can expire
  • Sets expired posts to drafts rather than deleting them
  • To show an expiry date on the frontend, use shortcode [expirydate] else function es_ape_exp_date()

Installation

  1. Upload electric-studio-auto-post-expire folder to the /wp-content/plugins/ directory
  2. Activate the plugin through the ‘Plugins’ menu in WordPress

Screenshots

  1. The options menu

    The options menu

  2. The added metabox to the edit post/page/attachment page

    The added metabox to the edit post/page/attachment page

FAQ

How does it work?

The plugin uses WordPress’s built-in cron functionality. Every set time it will check whether there’s anything to expire. Previously it checked on pageload, which was resource-intensive on high-traffic websites. You can check when it’s going to run next on the top of this page.

When will it run first?

As soon as you hit the “Save Changes” button. If it’s at 2am, then 2am, and then x interval you set.

If you want to reset the time (say, you want to run it every day at 4am), you need to set the frequence to something else, and then back to daily at 4am. Future release of the plugin may have a “run first at” option, but not just yet.

How do I disable the default expiration time?

Click on the input field (color will change red if you move your mouse over it) and Save Changes

How often should I run the check?

That depends on the traffic your site is getting, and the granularity you want to achieve.

If you need to expire a piece of content at 15:34, then I suggest setting 15 minutes and clicking Save Changes at any of these times past the hour: 4, 19, 34, 49 minutes.

If you have a very high-traffic site with a lot of content, then I suggest running it daily at the wee hours of the morning (or when you have the least ammount of traffic. Check your analytics).

It will run a complete loop of every post type, so it might take a while, and eat up server memory and CPU cycles for a bit, which means for a short time your site will be slower.

It says the next scheduled check runs in a negative amount of minutes. What gives?

That’s just cron and WordPress being silly. Refresh should solve that problem, but basically, WordPress thinks the next schedule is still in the past. It will get there, don’t worry.

That’s all I can think of right now. If you have any other questions, post them here, or the plugins WordPress plugin page. Use latter for bugs, and this one for general questions / feature requests though.

Can I use this plugin on more than one post type?

Yes you can since version 1.2

Can I show the expiry date on the front end of my site?

Yes, since version 1.3.5, I have included the shorted code of [expirydate format=”d-m-Y”] or for those that would like to build it into their template, you can use es_ape_exp_date( $format ). ($format is optional, and is the same as the PHP date formats (see http://uk.php.net/manual/en/function.date.php))

Changelog

1.6.10

  • Fixed one more line that was outputting notices

1.6.9

  • Refactored some of the internal code to prevent notices and warnings from populating the error_log
  • Introduced default values for some of the fields
  • New feature: added functionality to display how much time is left. Use es_time_left() within the loop. It will give you a human readable time difference in a variable, so you’ll need to use echo on that. Uses human_time_diff(), and accounts for the frequency of the cron job.

1.6.8

  • Fixed a bug where automatic expirations would fire hooks, manual ones wouldn’t. Now all will fire hooks.

1.6.7

  • Moved expiry functions over to built-in methods. Now hooks on post status transition and trash will also fire.

1.6.6

  • Fixed (hopefully) the random draft-set bug.

1.6.5

  • Changed comparison method for meta value.

1.6.4

  • Fixed cron scheduling. Mad props to MonkeyPress for spotting the problem! Thank you!

1.6.2

  • Removed some superfluous piece of code.

1.6.1

  • Added some logic to test for empty values in the date.

1.6

  • New feature: Default expiry time now added
  • New feature: Status can be chosen to go into once expired (not just draft)
  • New feature: Replaced functionality from pageload (init hook) to a cron job

1.5.5

  • Removed a blocking error message. This is a BETA thing, sometimes the expiry date/time will not save due to a nonce verification error which I’m looking into. (as of 15th October, 2012)

1.5.4

  • Removed a debugging related line.

1.5.3

  • If the nonce fails, the whole script would die(), but there’s a call to an undefined function. That has been added back. It provides troubleshooting for me.

1.5.2

  • Solved a problem that resulted in a warning if no post types are selected is now fixed (line 347) – thanks Kathy
  • Solved an erroneous function call resulting in a failure to activate plugin (line 98)

1.5

  • Added time as well, not just date. Uses current time, so make sure your timezone settings are properly configured (Settings->General)
  • Made it work under 3.4.2
  • Complete rewrite of the codebase
  • Now uses builtin jquery-ui-datepicker (instead of outside file)
  • Replaced raw SQL queries with proper WP functions
  • Since I inherited the plugin, some problems might crop up again. Help me weed them out 🙂

1.4

  • Added fallback for users with older versions of jquery that don’t have .on() function. Credit to Mark McLachlan for spotting this bug.
  • Cleaned up code to make it easier to read!
  • Put everthing into classes to tidy it up and the make it consistant with our other plugins
  • Worked on some future proofing
  • Put backward compatility for users using the esape_get_expiry_date() function so that it would work the same despite now being inside a class.
  • Minor Bug Fixes

1.3.5

  • Shortcode and function added for showing expiry date on front end.

1.2.2

  • jquery ui datepicker bug fixed

1.2.1

  • Fixed install and remove bug
  • Fixed date not showing in meta box bug

1.2

  • Allows the Selection of multiple post types
  • Uses WordPress Options API for the options page

1.1

  • Allows posts that have no expiry dates not to auto-expire

1.0

  • 1st Stable Version!

Details

  • Version: 1.6.10
  • Active installations: 90
  • WordPress Version: 3.0
  • Tested up to: 3.7.41

Ratings


5 Stars
4 Stars
3 Stars
2 Stars
1 Stars