modified broadcast page

master
campi 2 years ago
parent 5f2b9137f0
commit 30ad48a2f3

@ -5,7 +5,42 @@
*/ */
?> ?>
<?php <?php
function create_onair_banner() {
$week = ["Luned&igrave","Marted&igrave","Mercoled&igrave","Gioved&igrave","Venerd&igrave","Sabato","Domenica"]; $week = ["Luned&igrave","Marted&igrave","Mercoled&igrave","Gioved&igrave","Venerd&igrave","Sabato","Domenica"];
$content = $day = $cadence = $start_time = "";
$day = get_post_meta(get_the_ID(), 'on_air_day_0', true);
if (empty($day)) {
$content .= '<p style="color:#0bfafa">---> Trasmissione conclusa <---</p>';
} else {
$x = 0;
do {
$start_time = get_post_meta(get_the_ID(), 'on_air_start_'.$x, true);
$cadence = get_post_meta(get_the_ID(), 'on_air_cadence_'.$x, true);
$litteral_day = $week[((int)$day) - 1];
switch((int) $cadence) {
case 2: //ogni 2 settimane
case 3: //ogni 3 settimane
case 4: //ogni 4 settimane
$text = "$cadence $litteral_day";
break;
case 5: //una volta al mese
$start_date = get_post_meta(get_the_ID(), 'on_air_start_date_'.$x, true);
$day_of_the_month = which_day_of_the_month(new DateTime($start_date));
$text = "{$day_of_the_month}a $litteral_day del mese";
break;
default: //settimanale e altro non gestito (errori, etc.)
$text = "$litteral_day";
break;
}
$content .= '<p style="color:#0bfafa">---> In diretta ogni '.$text.' dalle ore '.$start_time.' <---</p>';
$x = $x + 1;
$day = get_post_meta(get_the_ID(), 'on_air_day_'.$x, true);
} while (!empty($day));
}
return $content;
}
get_header();?> get_header();?>
<main> <main>
@ -26,18 +61,10 @@ get_header();?>
<figure style="margin-bottom:2em; width:45%; padding:1em; float:right"> <figure style="margin-bottom:2em; width:45%; padding:1em; float:right">
<?php echo get_the_post_thumbnail(get_the_ID(), 'full'); ?> <?php echo get_the_post_thumbnail(get_the_ID(), 'full'); ?>
</figure> </figure>
<?php <?php the_content(); ?>
the_content();
$on_air = get_post_meta(get_the_ID(), 'on_air_day_0', false);
$start_time = get_post_meta(get_the_ID(), 'on_air_start_0', false);
?>
<div class="on-air"> <div class="on-air">
<?php /*Se $onair[0] non è valorizzato la trasmissione non ha diretta e quindi è conclusa */ ?> <?php /*Se $onair[0] non è valorizzato la trasmissione non ha diretta e quindi è conclusa */ ?>
<?php if (empty($on_air[0])) { ?> <?php echo create_onair_banner(); ?>
<p style="color:#0bfafa">---> Trasmissione conclusa <---</p>
<?php } else { ?>
<p style="color:#0bfafa">---> In diretta ogni <?php echo $week[$on_air[0]-1]; ?> dalle ore <?php echo $start_time[0]; ?> <---</p>
<?php } ?>
</div> </div>
<br> <br>
<!-- Link all'archivio delle puntate --> <!-- Link all'archivio delle puntate -->
@ -53,22 +80,12 @@ $category_link = get_category_link( $category_id );
<?php <?php
$cat_id = get_post_meta(get_the_ID(), 'taxonomy_id', true); $cat_id = get_post_meta(get_the_ID(), 'taxonomy_id', true);
//$cat_id = get_the_category(get_the_ID());
/* echo '<pre>';
print_r($cat_id);
echo '</pre>';
*/
$last_posts = get_posts( $last_posts = get_posts(
array( array(
'numberposts' => 3, 'numberposts' => 3,
'category' => $cat_id 'category' => $cat_id
) )
); );
//echo '<pre>';
//print_r($last_posts);
//echo '</pre>';
foreach ($last_posts as $s_post) { foreach ($last_posts as $s_post) {
$american_data = explode(" ", $s_post->post_date); $american_data = explode(" ", $s_post->post_date);
$data_a = explode("-", $american_data[0]); ?> $data_a = explode("-", $american_data[0]); ?>

Loading…
Cancel
Save