CI / Build Plugin Zip (pull_request) Has been skipped
CI / Tests (PHP 8.2) (pull_request) Successful in 45s
CI / PHPStan (pull_request) Successful in 2m48s
CI / Tests (PHP 8.1) (pull_request) Successful in 41s
CI / No Debug Code (pull_request) Failing after 2s
CI / Coding Standards (pull_request) Successful in 52s
CI / Tests (PHP 8.3) (pull_request) Successful in 2m36s
Availability windows were stored and served as a single bookable row, so a 9:00 AM-4:00 PM window showed to students as one giant slot and booking it consumed the whole day; past and multi-day windows also leaked into the booking page as nonsense entries. - Split windows into consecutive lesson-length slots on save (REST and admin form); each chunk is independently bookable and weekly recurrence creates a series per chunk so "reserve this time weekly" holds the same hour each week - Reject windows spanning multiple days or shorter than the lesson length (400 invalid_window) - Never return slots whose start has passed from GET /availability - Migrate pre-split rows: Plugin::boot re-runs the Installer on version change and AvailabilityRepository::splitOversizedWindows() rewrites unbooked same-day oversized windows in place - Display all times in 12-hour AM/PM form (booking page, wp-admin lists, editor previews) - Add a List | Week view toggle to the student booking page and the instructor availability page, with previous/next-week navigation honouring the site's start_of_week option (new WeekCalendar helper) Co-Authored-By: Claude Fable 5 <[email protected]>
42 lines
887 B
PHP
42 lines
887 B
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
namespace Unsupervised\Schedular;
|
|
|
|
use Unsupervised\Schedular\Auth\RoleManager;
|
|
use Unsupervised\Schedular\Availability\AvailabilityRepository;
|
|
|
|
class Installer {
|
|
|
|
public function run(): void {
|
|
$this->createTables();
|
|
$this->migrateData();
|
|
( new RoleManager() )->createRoles();
|
|
flush_rewrite_rules();
|
|
update_option( 'us_schedular_version', USC_VERSION );
|
|
}
|
|
|
|
private function createTables(): void {
|
|
global $wpdb;
|
|
if ( ! $wpdb instanceof \wpdb ) {
|
|
return;
|
|
}
|
|
$charset = $wpdb->get_charset_collate();
|
|
|
|
require_once ABSPATH . 'wp-admin/includes/upgrade.php';
|
|
|
|
foreach ( Schema::tables( $wpdb->prefix, $charset ) as $sql ) {
|
|
dbDelta( $sql );
|
|
}
|
|
}
|
|
|
|
private function migrateData(): void {
|
|
global $wpdb;
|
|
if ( ! $wpdb instanceof \wpdb ) {
|
|
return;
|
|
}
|
|
|
|
( new AvailabilityRepository( $wpdb ) )->splitOversizedWindows();
|
|
}
|
|
}
|