Created
February 8, 2013 01:10
-
-
Save INDIAN2020/4735751 to your computer and use it in GitHub Desktop.
display content after specified date
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Countdown timer shortcode, display content after specified date | |
use this : [cdt month="10" day="17" year="2011"] | |
This is content that will only be shown after a set number of days. | |
*/ | |
function content_countdown($atts, $content = null){ | |
extract(shortcode_atts(array( | |
'month' => '', | |
'day' => '', | |
'year' => '' | |
), $atts)); | |
$remain = ceil((mktime( 0,0,0,(int)$month,(int)$day,(int)$year) - time())/86400); | |
if( $remain > 1 ){ | |
return $daysremain = "<div class=\"event\">Just <b>($remain)</b> days until content is available</div>"; | |
}else if($remain == 1 ){ | |
return $daysremain = "<div class=\"event\">Just <b>($remain)</b> day until content is available</div>"; | |
}else{ | |
return $content; | |
} | |
} | |
add_shortcode('cdt', 'content_countdown'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment