'‹', 'right' => '›', 'doubleleft' => '«', 'doubleright' => '»' ); $arrows = apply_filters( 'radio_station_schedule_arrows', $arrows, 'table' ); // --- set cell info key order --- // 2.3.3.8: added for possible info rearrangement $infokeys = array( 'avatar', 'title', 'hosts', 'times', 'encore', 'file', 'excerpt', 'custom' ); $infokeys = apply_filters( 'radio_station_schedule_table_info_order', $infokeys ); // --- clear floats --- echo '
' . "\n"; // --- start master program table --- // 2.5.0: maybe add instance to element ID // 2.5.0: set oddeven variable $oddeven = 'even'; $id = ( 0 == $atts['instance'] ) ? '' : '-' . $atts['instance']; $table = '| ' . "\n"; // 2.3.3.9: added filters for week loader controls $table .= apply_filters( 'radio_station_schedule_loader_control', '', 'table', 'left', $atts['instance'] ); $table .= apply_filters( 'radio_station_schedule_loader_control', '', 'table', 'right', $atts['instance'] ); $table .= ' | ' . "\n"; // 2.5.0: set odd/even day variable $oddeven_day = 'even'; foreach ( $weekdays as $i => $weekday ) { // --- maybe skip all days but those specified --- // 2.3.2: improve days attribute checking logic $skip_day = false; if ( $atts['days'] ) { $days = explode( ',', $atts['days'] ); $found_day = false; foreach ( $days as $day ) { $day = trim( $day ); // 2.3.2: allow for numeric days (0=sunday to 6=saturday) if ( is_numeric( $day ) && ( $day > -1 ) && ( $day < 7 ) ) { $day = radio_station_get_weekday( $day ); } if ( trim( strtolower( $day ) ) == strtolower( $weekday ) ) { $found_day = true; } } if ( !$found_day ) { $skip_day = true; } } if ( !$skip_day ) { // --- set day column heading --- // 2.3.2: added check for short/long day display attribute if ( !in_array( $atts['display_day'], array( 'short', 'full', 'long' ) ) ) { $atts['display_day'] = 'short'; } if ( 'short' == $atts['display_day'] ) { $display_day = radio_station_translate_weekday( $weekday, true ); } elseif ( ( 'full' == $atts['display_day'] ) || ( 'long' == $atts['display_day'] ) ) { $display_day = radio_station_translate_weekday( $weekday, false ); } // --- get weekdate subheading --- // 2.3.2: set day start and end times // 2.3.2: add subheading adjustment for timezone // 2.3.2: replace strtotime with to_time function for timezone $weekdate = $weekdates[$weekday]; $day_start_time = radio_station_to_time( $weekdate . ' 00:00:00' ); $day_end_time = $day_start_time + ( 24 * 60 * 60 ); // 2.3.2: add attribute for date subheading format (see PHP date() format) // $subheading = date( 'jS M', strtotime( $weekdate ) ); if ( $atts['display_date'] ) { $date_subheading = radio_station_get_time( $atts['display_date'], $day_start_time ); } else { $date_subheading = radio_station_get_time( 'j', $day_start_time ); } // 2.3.2: add attribute for short or long month display $month = radio_station_get_time( 'F', $day_start_time ); if ( $atts['display_month'] && !in_array( $atts['display_month'], array( 'short', 'full', 'long' ) ) ) { $atts['display_month'] = 'short'; } if ( ( 'long' == $atts['display_month'] ) || ( 'full' == $atts['display_month'] ) ) { $date_subheading .= ' ' . radio_station_translate_month( $month, false ); } elseif ( 'short' == $atts['display_month'] ) { $date_subheading .= ' ' . radio_station_translate_month( $month, true ); } // --- set heading classes --- // 2.3.0: add day and check for highlighting // 2.5.0: add odd/even day class $classes = array( 'master-program-day', 'day-' . $i, strtolower( $weekday ), 'date-' . $weekdate ); $oddeven_day = ( 'even' == $oddeven_day ) ? 'odd' : 'even'; $classes[] = $oddeven_day . '-day'; if ( ( $now > $day_start_time ) && ( $now < $day_end_time ) ) { $classes[] = 'current-day'; // $classes[] = 'selected-day'; } $classlist = implode( ' ', $classes ); // --- output table column heading --- // 2.3.0: added left/right arrow responsive controls // 2.3.1: added (negative) return to arrow onclick functions // 2.3.2: added check for optional display_date attribute $table .= '' . "\n";
$table .= ' ' . "\n";
$table .= '' . $arrows['left'] . '' . "\n";
$table .= ' ' . "\n";
$table .= '' . "\n";
$table .= ' ' . "\n";
if ( $atts['display_date'] ) {
$table .= ' ' . "\n";
$table .= '' . esc_html( $date_subheading ) . ' ' . "\n";
}
$table .= '' . "\n";
$table .= '' . $arrows['right'] . '' . "\n";
$table .= ' ' . "\n";
// 2.3.2: add day start and end time date
$table .= '' . "\n";
$table .= '' . "\n";
$table .= ' | ' . "\n";
}
}
$table .= '
|---|---|
| ' . "\n";
if ( isset( $_GET['hourdebug'] ) && ( '1' === sanitize_text_field( $_GET['hourdebug'] ) ) ) {
$table .= '';
}
$table .= ' ';
$table .= esc_html( $hour_display );
$table .= ' ' . "\n";
$table .= '' . "\n"; $table .= '' . "\n"; $table .= ' | ' . "\n";
foreach ( $weekdays as $i => $weekday ) {
// --- maybe skip all days but those specified ---
// 2.3.2: improve days attribute checking logic
$skip_day = false;
if ( $atts['days'] ) {
$days = explode( ',', $atts['days'] );
$found_day = false;
foreach ( $days as $day ) {
$day = trim( $day );
// 2.3.2: allow for numeric days (0=sunday to 6=saturday)
if ( is_numeric( $day ) && ( $day > -1 ) && ( $day < 7 ) ) {
$day = radio_station_get_weekday( $day );
}
if ( trim( strtolower( $day ) ) == strtolower( $weekday ) ) {
$found_day = true;
}
}
if ( !$found_day ) {
$skip_day = true;
}
}
if ( !$skip_day ) {
// --- clear the cell ---
if ( isset( $cell ) ) {
unset( $cell );
}
$cellcontinued = $showcontinued = $overflow = $newshift = false;
$cellshifts = 0;
// --- get shifts for this day ---
if ( isset( $schedule[$weekday] ) ) {
$shifts = $schedule[$weekday];
} else {
$shifts = array();
}
$nextday = radio_station_get_next_day( $weekday );
$prevday = radio_station_get_previous_day( $weekday );
// --- get weekdates ---
$weekdate = $weekdates[$weekday];
// $nextdate = $weekdates[$nextday];
// --- get hour and next hour start and end times ---
// 2.3.1: fix to use untranslated hour (12 hr format bug)
// 2.3.2: replace strtotime with to_time function for timezone
$hour_start = radio_station_to_time( $weekdate . ' ' . $hour . ':00' );
$hour_end = $next_hour_start = $hour_start + ( 60 * 60 );
$next_hour_end = $hour_end + ( 60 * 60 );
// --- loop the shifts for this day ---
foreach ( $shifts as $shift ) {
$split_id = false;
if ( !isset( $shift['finished'] ) || !$shift['finished'] ) {
// --- get shift start and end times ---
// 2.3.2: replace strtotime with to_time function for timezone
// 2.3.2: fix to convert to 24 hour format first
$display = $nowplaying = false;
if ( '00:00 am' == $shift['start'] ) {
$shift_start_time = radio_station_to_time( $weekdate . ' 00:00' );
} else {
$shift_start_time = radio_station_convert_shift_time( $shift['start'] );
$shift_start_time = radio_station_to_time( $weekdate . ' ' . $shift_start_time );
}
if ( ( '11:59:59 pm' == $shift['end'] ) || ( '12:00 am' == $shift['end'] ) ) {
$shift_end_time = radio_station_to_time( $weekdate . ' 23:59:59' ) + 1;
} else {
$shift_end_time = radio_station_convert_shift_time( $shift['end'] );
$shift_end_time = radio_station_to_time( $weekdate . ' ' . $shift_end_time );
}
// --- get split shift real start and end times ---
// 2.3.2: added for shift display output
$real_shift_start = $real_shift_end = false;
if ( isset( $shift['split'] ) && $shift['split'] ) {
if ( isset( $shift['real_start'] ) ) {
$real_shift_start = radio_station_convert_shift_time( $shift['real_start'] );
$real_shift_start = radio_station_to_time( $weekdate . ' ' . $real_shift_start ) - ( 24 * 60 * 60 );
$split_id = strtolower( $prevday . '-' . $weekday );
} elseif ( isset( $shift['real_end'] ) ) {
$real_shift_end = radio_station_convert_shift_time( $shift['real_end'] );
$real_shift_end = radio_station_to_time( $weekdate . ' ' . $real_shift_end ) + ( 24 * 60 * 60 );
$split_id = strtolower( $weekday . '-' . $nextday );
}
}
// --- check if the shift is starting / started ---
if ( isset( $shift['started'] ) && $shift['started'] ) {
// - continue display of shift -
if ( !isset( $cell ) ) {
$cellcontinued = true;
}
$display = $showcontinued = true;
$cellshifts ++;
} elseif ( ( $shift_start_time == $hour_start )
|| ( ( $shift_start_time > $hour_start ) && ( $shift_start_time < $next_hour_start ) ) ) {
// - start display of shift -
$started = $shift['started'] = true;
$schedule[$weekday][$shift['start']] = $shift;
$display = $newshift = true;
// 2.3.1: reset showcontinued flag
$showcontinued = false;
$cellshifts ++;
}
// --- check if shift is current ---
if ( ( $now >= $shift_start_time ) && ( $now < $shift_end_time ) ) {
$nowplaying = true;
}
// --- check if shift finishes in this hour ---
if ( isset( $shift['started'] ) && $shift['started'] ) {
if ( $shift_end_time == $hour_end ) {
$finished = $shift['finished'] = true;
$schedule[$weekday][$shift['start']] = $shift;
// $fullcell = true;
} elseif ( $shift_end_time < $hour_end ) {
$finished = $shift['finished'] = true;
$schedule[$weekday][$shift['start']] = $shift;
// $percent = round( ( $shift_end_time - $hour_start ) / 3600 );
// $partcell = true;
} else {
$overflow = true;
}
}
if ( isset( $_GET['rs-shift-debug'] ) && ( '1' === sanitize_title( $_GET['rs-shift-debug'] ) ) ) {
if ( !isset( $shiftdebug ) ) {$shiftdebug = '';}
if ( $display ) {
$shiftdebug .= 'Now: ' . $now . ' (' . radio_station_get_time( 'datetime', $now ) . ') -- Today: ' . $today . '' . "\n";
$table .= ' ' . "\n";
if ( isset( $cell ) ) {
$table .= $cell;
}
$table .= ' ' . "\n";
$table .= ' | ' . "\n";
}
}
// --- close hour row ---
$table .= '