'broadcast', 'numberposts' => -1 ); $broadcasts = get_posts($broadcast_post); $palinsesto = []; foreach ($broadcasts as $post) { $on_air_day = $on_air_start = $on_air_end = $on_air_cadence = $on_air_start_date = ""; for ($d=0;$d<7;$d++) { $on_air_day = get_post_meta($post->ID, 'on_air_day_'.$d, true); $on_air_start = get_post_meta($post->ID, 'on_air_start_'.$d, true); $on_air_end = get_post_meta($post->ID, 'on_air_end_'.$d, true); $on_air_cadence = get_post_meta($post->ID, 'on_air_cadence_'.$d, true); $on_air_start_date = get_post_meta($post->ID, 'on_air_start_date_'.$d, true); if (empty($on_air_cadence) || empty($on_air_start_date)) { $on_air_cadence = "1"; } if (!empty($on_air_day)&&!empty($on_air_start)&&!empty($on_air_end)) { if (have_to_run_this_week($on_air_start_date, (int)$on_air_cadence)) { $palinsesto[(int)$on_air_day][(string)$on_air_start] = array( 'ID' => $post->ID, 'start' => $on_air_start, 'end' => $on_air_end, 'on_air' => true, 'title' => $post->post_title, 'excerpt' => $post->post_excerpt, 'thumb_url' => get_the_post_thumbnail_url($post->ID, 'full'), 'the_permalink' => get_permalink($post->ID), ); } } } $rerun_day = $rerun_start = $rerun_end = $rerun_cadence = $rerun_start_date = ""; for ($d=0;$d<7;$d++) { $rerun_day = get_post_meta($post->ID, 'rerun_day_'.$d, true); $rerun_start = get_post_meta($post->ID, 'rerun_start_'.$d, true); $rerun_end = get_post_meta($post->ID, 'rerun_end_'.$d, true); $rerun_cadence = get_post_meta($post->ID, 'rerun_cadence_'.$d, true); $rerun_start_date = get_post_meta($post->ID, 'rerun_start_date_'.$d, true); if (empty($rerun_cadence) || empty($rerun_start_date)) { $rerun_cadence = "1"; } if (!empty($rerun_day)&&!empty($rerun_start)&&!empty($rerun_end)) { if (have_to_run_this_week($rerun_start_date, (int)$rerun_cadence)) { $palinsesto[(int)$rerun_day][(string)$rerun_start] = array( 'ID' => $post->ID, 'start' => $rerun_start, 'end' => $rerun_end, 'on_air' => false, 'title' => $post->post_title, 'excerpt' => $post->post_excerpt, 'thumb_url' => get_the_post_thumbnail_url($post->ID, 'full'), 'the_permalink' => get_permalink($post->ID), ); } } } } ksort($palinsesto); // echo '
';
//  print_r($palinsesto);
//  echo '
'; $today = date("N"); for ($x=1;$x<=7;$x++) { /*echo '
';
        echo("$today,$x");
        echo '
';*/ if ($x == $today) $tabs .= "
  • ".$week_days[$x-1]."
  • "; else $tabs .= "
  • ".$week_days[$x-1]."
  • "; $content .= '
  • '; if (!empty($palinsesto[$x])) { ksort($palinsesto[$x]); foreach ($palinsesto[$x] as $hour => $broadcast) { $content .= '
    '; $content .= '

    '.$broadcast['title'].'

    '; $content .= ''; /* Indico sotto al titolo se la trasmissione รจ una replica o una diretta */ $content .= (!$broadcast['on_air']) ? "[replica]" : "[diretta]"; $content .= '

    '.$broadcast['start'].' - '.$broadcast['end'].'

    '; $content .= '

    '.$broadcast['excerpt'].'

    '; $content .= "
    "; } } $content .= '
  • '; } ?>