SO网友:E. Jaep
基于@mmm answer,我的代码如下所示:
extract(shortcode_atts(array(
\'start\' => \'\'
), $attributes));
extract(shortcode_atts(array(
\'end\' => \'\'
), $attributes));
if (($start_timestamp = strtotime($start)) === false) {
$error = new WP_Error(\'unable to parse\', \'Unable to parse start timestamp\', $start);
scheduler_log($error);
return \'\';
}
if (($end_timestamp = strtotime($end)) === false) {
$error = new WP_Error(\'unable to parse\', \'Unable to parse end timestamp\', $end);
scheduler_log($error);
return \'\';
}
date_default_timezone_set("Europe/Zurich");
$now = strtotime("now");
if($now>=$start_timestamp && $now<=$end_timestamp){
return $content;
}
else{
return \'\';
}