Skip to content

Commit 4aa8e93

Browse files
authored
Merge pull request ucsf-ckm#33 from stopfstedt/multiple-times-a-day
handles multiple opening hours per day.
2 parents 7187a5c + 6eeaf82 commit 4aa8e93

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

public/class-wplibcalhours-public.php

+8-6
Original file line numberDiff line numberDiff line change
@@ -247,12 +247,14 @@ protected function extract_hours( array $weeks_raw_data ) {
247247
$text = __( 'closed', 'wplibcalhours' );
248248
break;
249249
default:
250-
if ( array_key_exists( 'hours', $day_raw['times'] )
251-
&& ! empty( $day_raw['times']['hours'] )
252-
&& array_key_exists( 'from', $day_raw['times']['hours'][0] )
253-
&& array_key_exists( 'to', $day_raw['times']['hours'][0] )
254-
) {
255-
$text = $day_raw['times']['hours'][0]['from'] . ' - ' . $day_raw['times']['hours'][0]['to'];
250+
if ( array_key_exists( 'hours', $day_raw['times'] ) && ! empty( $day_raw['times']['hours'] )) {
251+
$hours_text = [];
252+
foreach( $day_raw['times']['hours'] as $hours ) {
253+
if (array_key_exists( 'from', $hours ) && array_key_exists( 'to', $hours )) {
254+
$hours_text[] = $hours['from'] . ' - ' . $hours['to'];
255+
}
256+
}
257+
$text = implode( '<br>', $hours_text );
256258
}
257259
}
258260
$days[ $day_raw['date'] ] = $text;

public/css/wplibcalhours-public.css

+4
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,7 @@
1313
.wplibcalhours .next {
1414
float: right;
1515
}
16+
17+
.wplibcalhours tbody td {
18+
vertical-align: top;
19+
}

0 commit comments

Comments
 (0)