所以我一直在我的wordpress网站上用php编码一个小的自定义行,它应该会自动显示下一次交付时间。
'现在它显示了两个自动更新的日期为两个星期的工作日。我希望他们是循环的,所以如果不到24小时,让我们说星期五交付你不能看到文本。它只会显示另一个选项。这是我目前的代码。
<p class="mb-4 fw-bold"><?php
_e('Järgmised tarneajad', 'esahver');
echo ": " ;
$now = strtotime("now");
$next_delivery = strtotime('next tuesday');
$limit_hours = 17;
$next_delivery_minus_hrs = strtotime('-' . $limit_hours . ' hours', $next_delivery);
$final_next_delivery = NULL;
if( $next_delivery_minus_hrs < $now ){ // past limit hours
$next2_delivery = strtotime('next tuesday', $next_delivery);
$final_next_delivery = wp_date( 'l, d.m.Y' , $next2_delivery);
} else {
$final_next_delivery = wp_date( 'l, d.m.Y' , $next_delivery );
}
$now1 = strtotime("now");
$next_delivery1 = strtotime('next friday');
$limit_hours1 = 17;
$next_delivery_minus_hrs1 = strtotime('-' . $limit_hours1 . ' hours', $next_delivery1);
$final_next_delivery1 = NULL;
if( $next_delivery_minus_hrs1 < $now ){ // past limit hours
$next2_delivery1 = strtotime('next friday', $next_delivery1);
$final_next_delivery1 = wp_date( 'l, d.m.Y' , $next2_delivery1);
} else {
$final_next_delivery1 = wp_date( 'l, d.m.Y' , $next_delivery1 );
}
echo $final_next_delivery;
echo "<input type='hidden' name='custom_delivery_date' value='".$final_next_delivery."'/>";
echo " & ";
echo $final_next_delivery1;
echo "<input type='hidden' name='custom_delivery_date' value='".$final_next_delivery1."'/>";
?>
</p>
我该如何处理这个问题?谢谢
我试过写一些不好的if句,但根本不管用。
1条答案
按热度按时间qfe3c7zg1#
您可以更简单地重构代码,