From bf2cb135ba3e0146f059b741526ff081f27dfa90 Mon Sep 17 00:00:00 2001 From: SebastianWiz <165194375+SebastianWiz@users.noreply.github.com> Date: Mon, 2 Feb 2026 13:01:31 -0800 Subject: [PATCH] `gpb-bookings-today-merge-tag.php`: Added new snippet for displaying all bookings for a service for the current day. --- gp-bookings/gpb-bookings-today-merge-tag.php | 101 +++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 gp-bookings/gpb-bookings-today-merge-tag.php diff --git a/gp-bookings/gpb-bookings-today-merge-tag.php b/gp-bookings/gpb-bookings-today-merge-tag.php new file mode 100644 index 000000000..cc3d95f4c --- /dev/null +++ b/gp-bookings/gpb-bookings-today-merge-tag.php @@ -0,0 +1,101 @@ +get_bookings_output( (int) $match[1], $format ), $text ); + } + + return $text; + } + + private function get_bookings_output( $service_id, $format ) { + $today = \GP_Bookings\Utils\DateTimeUtils::today(); + $bookings = \GP_Bookings\Queries\Booking_Query::get_bookings( array( + 'object_type' => 'service', + 'service_id' => $service_id, + 'start_date' => $today->format( 'Y-m-d H:i:s' ), + 'end_date' => $today->addDay()->format( 'Y-m-d H:i:s' ), + 'order' => 'ASC', + 'orderby' => 'start', + ) ); + + $lines = array(); + foreach ( $bookings as $booking ) { + if ( $booking instanceof \GP_Bookings\Booking && $booking->get_mode() === 'datetime-range' ) { + $line = $this->format_booking_line( $booking ); + if ( $line ) { + $lines[] = $line; + } + } + } + + if ( empty( $lines ) ) { + return ''; + } + + // Title + $title = sprintf( "Today's Bookings — %s", $today->format( 'F j, Y' ) ); + + return $format === 'html' + ? '' . esc_html( $title ) . '