Adds a shortcode and function allowing you to force the contents of a post or page to appear or expire after a specific date, day and/or time.
After installation, simply use the shortcode [timed] around any post or page contents that you wish to appear or expire on a specific date and/or time.
Six parameters can be used - ondate, offdate, ontime, offtime, onday and offday.
ondate : Date after which you wish the content to appear, in format YYYYMMDD.
offdate : Date after which you wish the content to expire, in format YYYYMMDD.
ontime : Time after which you wish the content to appear, in format HHMM.
offtime : Time after which you wish the content to expire, in format HHMM.
onday : Day on which you wish the content to appear - 1 (for Monday) through 7 (for Sunday)
offday : Day on which you wish the content to expire - 1 (for Monday) through 7 (for Sunday)
If any of these aren't specified then a logical alternative is found - e.g. not specifying ondate or ontime means the text will appear immediately (until the conditions of any expiry date/time is met).
Here's some examples of use..
[timed offdate="20102412"]It's nearly Christmas![/timed]
This will cause the message to disappear after the 24th December 2010.
[timed ondate="20100101" offdate="20101231"]It's 2010[/timed]
This will cause the message to only appear during the year 2010.
[timed ondate="20100101" offdate="20101231" ontime="0800" offtime="1200"]It's between 8am and midday[/timed]
This will cause the message to appear between 8am and midday during the year 2010.
[timed onday="1" offday="3"]It's Monday to Wednesday[/timed]
This will cause the message to only appear Monday, Tuesday and Wednesday.
Function Call
If you wish to use this facility elsewhere in your theme - e.g. your sidebar - then you can do by calling a PHP function.
It uses the same parameters as above, each seperated by an ampersand.
For example...
simple_timed_content(ondate=20100101&offdate=20101231);
This will return either TRUE or FALSE depending on whether the content should be displayed or not. So, a full example may be...
<?php if (function_exists('simple_timed_content')) : ?>
<?php if (simple_timed_content("ondate=20100101&offdate=20101231")) : ?>
Some content goes here
<?php endif; ?>
<?php endif; ?>
This will only display the content if it's any date during the year 2010.
Requires: 2.0.0 or higher
Compatible up to: 3.0.5
Last Updated: 2010-10-25
Downloads: 1,577




