From 169f7b6a13540d06d36f991c0dc6e49d6a484a6c Mon Sep 17 00:00:00 2001 From: James Griffin Date: Thu, 23 Jul 2026 12:10:55 -0300 Subject: [PATCH] Accept whole days only for the studio cancellation cutoff The Studio Settings cutoff field now takes an integer number of days (step 1, coerced with Val::int) instead of allowing half-day fractions, and displays the stored hours rounded to whole days. Co-Authored-By: Claude Opus 4.8 --- src/Payment/StudioSettings.php | 12 ++++++------ templates/admin/settings.php | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Payment/StudioSettings.php b/src/Payment/StudioSettings.php index e1b6a04..662a325 100644 --- a/src/Payment/StudioSettings.php +++ b/src/Payment/StudioSettings.php @@ -134,8 +134,8 @@ class StudioSettings { $hstRate = $this->hstRate(); $stripeConfigured = $this->isStripeConfigured(); $openRegistration = $this->openRegistrationEnabled(); - // Stored in hours, surfaced to the admin in days. - $cancellationCutoffDays = $this->cancellationCutoffHours() / 24; + // Stored in hours, surfaced to the admin in whole days. + $cancellationCutoffDays = (int) round( $this->cancellationCutoffHours() / 24 ); include USC_PLUGIN_DIR . 'templates/admin/settings.php'; } @@ -162,10 +162,10 @@ class StudioSettings { $hstRate = isset( $_POST['hst_rate'] ) ? Val::float( $_POST['hst_rate'] ) : 0.0; update_option( self::OPT_HST_RATE, max( 0.0, $hstRate ) ); - // The cutoff is entered in days but stored in hours. - // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Val::float() coerces to float; slashes cannot survive numeric coercion. - $cutoffDays = isset( $_POST['cancellation_cutoff_days'] ) ? max( 0.0, Val::float( $_POST['cancellation_cutoff_days'] ) ) : 0.0; - update_option( self::OPT_CANCELLATION_CUTOFF_HOURS, (int) round( $cutoffDays * 24 ) ); + // The cutoff is entered in whole days but stored in hours. + // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Val::int() coerces to int; slashes cannot survive numeric coercion. + $cutoffDays = isset( $_POST['cancellation_cutoff_days'] ) ? max( 0, Val::int( $_POST['cancellation_cutoff_days'] ) ) : 0; + update_option( self::OPT_CANCELLATION_CUTOFF_HOURS, $cutoffDays * 24 ); $this->applyRegistrationMode( isset( $_POST['open_registration'] ) ); // phpcs:enable WordPress.Security.NonceVerification.Missing diff --git a/templates/admin/settings.php b/templates/admin/settings.php index 2250635..b394011 100644 --- a/templates/admin/settings.php +++ b/templates/admin/settings.php @@ -16,7 +16,7 @@ if (! defined('ABSPATH')) { * @var float $hstRate * @var bool $stripeConfigured * @var bool $openRegistration - * @var float $cancellationCutoffDays + * @var int $cancellationCutoffDays */ ?>
@@ -96,7 +96,7 @@ if (! defined('ABSPATH')) { - +