Skip to content

Instantly share code, notes, and snippets.

@lynt-smitka
Created February 25, 2017 13:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lynt-smitka/8db9b3c416b1ae6c7cde3774b5afea47 to your computer and use it in GitHub Desktop.
Save lynt-smitka/8db9b3c416b1ae6c7cde3774b5afea47 to your computer and use it in GitHub Desktop.
function lynt_date_shortcode( $atts , $content = null ) {
$atts = shortcode_atts(
array(
'den' => 0,
'start' => '',
'stop' => '',
),
$atts,'lynt_date');
$den = intval($atts["den"]);
$start = strtotime($atts["start"]);
$stop = strtotime($atts["stop"]);
$ted = time();
if($ted > $start && $ted < $stop && intval(date('N',$ted)) === $den) {
return $content;
}
}
add_shortcode( 'lynt_date', 'lynt_date_shortcode' );
//[lynt_date den="5" start="17:30" stop="21:00"]TEXT[/lynt_date]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment