Last active
November 18, 2018 08:15
-
-
Save kurosuke/ac45958850c07790750d52851b957e31 to your computer and use it in GitHub Desktop.
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
function shortcode_open_date_view($atts = '', $content = '') { | |
$tz = new DateTimeZone('Asia/Tokyo'); | |
// get now | |
$now = new DateTime('now', $tz); | |
$format = 'Y-m-d H:i:s'; | |
// get argment | |
extract(shortcode_atts([ | |
'open' => ''], $atts)); | |
// get argment open_date | |
$open_date = DateTime::createFromFormat($format, $open, $tz); | |
if ($now > $open_date) { | |
// view contents | |
// do shortcode in this shortcode | |
$content_expand = do_shortcode($content); | |
return $content_expand; | |
} else { | |
// not yet open date | |
return ''; | |
} | |
} | |
add_shortcode('open_date_view', 'shortcode_open_date_view'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment