我想在一个条件中添加这个多条件以使其简单,下面是我的代码。我想要的是" footer_widgets_columns"是4然后显示所有4列,如果3然后只显示等等,这段代码符合我的要求,但希望在一个条件下使其更紧凑,而不是一次又一次地写它
<section class="columns columns-<?php echo $data['footer_widgets_columns']; ?>">
<?php if($data['footer_widgets_columns']== 4){
$footer_col=3;
?>
<article class="col-md-<?php echo $footer_col ?>">
<?php
if (!function_exists('dynamic_sidebar') || !dynamic_sidebar('Footer Widget 1')):
endif;
?>
</article>
<article class="col-md-<?php echo $footer_col ?>">
<?php
if (!function_exists('dynamic_sidebar') || !dynamic_sidebar('Footer Widget 2')):
endif;
?>
</article>
<article class="col-md-<?php echo $footer_col ?>">
<?php
if (!function_exists('dynamic_sidebar') || !dynamic_sidebar('Footer Widget 3')):
endif;
?>
</article>
<article class="col-md-<?php echo $footer_col ?> last">
<?php
if (!function_exists('dynamic_sidebar') || !dynamic_sidebar('Footer Widget 4')):
endif;
?>
</article>
<?php
}
?>
<?php if($data['footer_widgets_columns']== 3){
$footer_col=4;
?>
<article class="col-md-<?php echo $footer_col ?>">
<?php
if (!function_exists('dynamic_sidebar') || !dynamic_sidebar('Footer Widget 1')):
endif;
?>
</article>
<article class="col-md-<?php echo $footer_col ?>">
<?php
if (!function_exists('dynamic_sidebar') || !dynamic_sidebar('Footer Widget 2')):
endif;
?>
</article>
<article class="col-md-<?php echo $footer_col ?>">
<?php
if (!function_exists('dynamic_sidebar') || !dynamic_sidebar('Footer Widget 3')):
endif;
?>
</article>
<?php
}
?>
<?php if($data['footer_widgets_columns']== 2){
$footer_col=6;
?>
<article class="col-md-<?php echo $footer_col ?>">
<?php
if (!function_exists('dynamic_sidebar') || !dynamic_sidebar('Footer Widget 1')):
endif;
?>
</article>
<article class="col-md-<?php echo $footer_col ?>">
<?php
if (!function_exists('dynamic_sidebar') || !dynamic_sidebar('Footer Widget 2')):
endif;
?>
</article>
<?php
}
?>
<?php if($data['footer_widgets_columns']== 1){
$footer_col=12;
?>
<article class="col-md-<?php echo $footer_col ?>">
<?php
if (!function_exists('dynamic_sidebar') || !dynamic_sidebar('Footer Widget 1')):
endif;
?>
</article>
<?php
}
?>
</section>
答案 0 :(得分:0)
您可以执行类似
的操作/usr/local/bin/ssh -q -o "StrictHostKeyChecking=no" -o "BatchMode=yes" -n ${host} "/usr/bin/uptime" & PID="$!"
# Allow 5 seconds to elapse before killing the command
sleep 5
kill "$PID"