Skip to content

Commit 8fb788f

Browse files
authored
gpb-daily-service-booking-limit.php: Added new snippet
1 parent 11b6517 commit 8fb788f

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

gp-bookings/gpb-daily-service-booking-limit.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ public function __construct( array $args ) {
3131
$this->daily_limit = (int) $args['daily_limit'];
3232

3333
if ( empty( $this->service_ids ) || $this->daily_limit < 1 ) {
34-
return;
35-
}
34+
return;
35+
}
3636

3737
// Guard creation and REST availability so the cap is enforced everywhere.
38-
add_action( 'gpb_before_booking_created', array( $this, 'guard_booking_creation' ), 10, 2 );
38+
add_action( 'gpb_before_booking_created', array( $this, 'guard_booking_creation' ), 10, 2 );
3939
add_filter( 'rest_post_dispatch', array( $this, 'filter_rest_availability' ), 10, 3 );
4040
}
4141

@@ -109,7 +109,7 @@ public function filter_rest_availability( $response, $server, $request ) {
109109
return $response;
110110
}
111111

112-
private function exceeds_limit( array $dates, int $incoming_quantity = 0, ?int $exclude_booking_id = null ): bool {
112+
private function exceeds_limit( array $dates, int $incoming_quantity = 0, $exclude_booking_id = null ): bool {
113113
$dates = array_filter( array_unique( $dates ) );
114114
$totals = $dates ? $this->get_daily_totals( $dates, $exclude_booking_id ) : array();
115115

@@ -123,7 +123,7 @@ private function exceeds_limit( array $dates, int $incoming_quantity = 0, ?int $
123123
return false;
124124
}
125125

126-
private function get_daily_totals( array $dates, ?int $exclude_booking_id = null ): array {
126+
private function get_daily_totals( array $dates, $exclude_booking_id = null ): array {
127127
$dates = array_values( array_filter( array_unique( array_map( 'trim', $dates ) ) ) );
128128
if ( ! $dates ) {
129129
return array();
@@ -135,7 +135,7 @@ private function get_daily_totals( array $dates, ?int $exclude_booking_id = null
135135
return $this->get_totals_for_range( $start_datetime, $end_datetime, $exclude_booking_id );
136136
}
137137

138-
private function get_totals_for_range( string $start_datetime, string $end_datetime, ?int $exclude_booking_id = null ): array {
138+
private function get_totals_for_range( string $start_datetime, string $end_datetime, $exclude_booking_id = null ): array {
139139
if ( '' === $start_datetime || '' === $end_datetime ) {
140140
return array();
141141
}

0 commit comments

Comments
 (0)