Add per-embed lesson-type and section options to the booking block
CI / Tests (PHP 8.1) (pull_request) Successful in 47s
CI / Tests (PHP 8.2) (pull_request) Successful in 54s
CI / No Debug Code (pull_request) Successful in 2s
CI / PHPStan (pull_request) Successful in 2m51s
CI / Coding Standards (pull_request) Successful in 2m56s
CI / Tests (PHP 8.3) (pull_request) Successful in 2m42s
CI / Build Plugin Zip (pull_request) Skipped
CI / Tests (PHP 8.1) (pull_request) Successful in 47s
CI / Tests (PHP 8.2) (pull_request) Successful in 54s
CI / No Debug Code (pull_request) Successful in 2s
CI / PHPStan (pull_request) Successful in 2m51s
CI / Coding Standards (pull_request) Successful in 2m56s
CI / Tests (PHP 8.3) (pull_request) Successful in 2m42s
CI / Build Plugin Zip (pull_request) Skipped
Three sidebar options on the Lesson Booking block, all mirrored as shortcode attributes and carried to the front end as data attributes on #us-booking-app (or as omitted containers): - Lesson type (lessonTypeId / lesson_type) pins the calendar to a single private-lesson type: only the times bookable as it are listed, and it is the only type bookable there, auto-selected on the registration form. A pinned type that is no longer offered says so instead of showing an empty calendar. - Show the lesson-type filter (showTypeFilter / show_filter) drops the "Show Only" control for studios that do not want it. - Sections (displayMode / show) embeds one half of the page — the booking calendar or the student's upcoming lessons — so the two can live on different pages. The script skips the work belonging to a missing half: no availability or catalog request for an upcoming-only embed, no bookings request for a booking-only one. An unrecognised value renders the whole page. The editor preview follows the same setting. Also fixes the expanded filter's first lesson type sharing a line with the "Lesson type" heading — the choices now sit in their own row beneath it. Co-Authored-By: Claude Opus 5 <[email protected]>
This commit is contained in:
@@ -27,6 +27,9 @@ Four blocks have sidebar (inspector) options:
|
||||
|---|---|---|---|
|
||||
| `us-scheduler/booking` | `loginPageId` (number) | `0` | Page the "log in to book a lesson" link points to for logged-out visitors. `0` = the WordPress login screen (with a redirect back to the current page). |
|
||||
| `us-scheduler/booking` | `autoRedirect` (boolean) | `false` | Send logged-out visitors straight to the login page instead of showing the link. |
|
||||
| `us-scheduler/booking` | `lessonTypeId` (number) | `0` | Pin the calendar to a single private-lesson type: only the times bookable as that type are listed, and it is the only type students can book here (auto-selected on the registration form). `0` = every type. Shortcode equivalent: `[us_booking lesson_type="…"]`. |
|
||||
| `us-scheduler/booking` | `showTypeFilter` (boolean) | `true` | Whether students get the **Show Only** button that narrows the calendar to chosen lesson types. Unused when a single type is pinned (there is nothing to choose). Shortcode equivalent: `[us_booking show_filter="no"]`. |
|
||||
| `us-scheduler/booking` | `displayMode` (string) | `both` | Which halves of the page to embed: `both`, `booking` (calendar only, no upcoming-lessons panel) or `upcoming` (the student's lessons only, nothing bookable) — so the two halves can live on different pages. Anything unrecognised falls back to `both`. Shortcode equivalent: `[us_booking show="booking"]`. |
|
||||
| `us-scheduler/student-login` | `bookingPageId` (number) | `0` | Page the "View available lessons" link points to for logged-in visitors, and the post-login redirect target. `0` = the current page. |
|
||||
| `us-scheduler/student-login` | `autoRedirect` (boolean) | `false` | Send logged-in visitors straight to the booking page instead of showing the link. Does nothing until a booking page is chosen. |
|
||||
| `us-scheduler/student-register` | `loginPageId` (number) | `0` | Page students continue to once registration finishes — the "Sign in to your account" link after they confirm their email, and the "Continue to your account" link an invited student gets on the spot. `0` = the WordPress login screen for the confirmation link, and no link at all for the (already signed-in) invited student. Shortcode equivalent: `[us_student_register login_page_id="…"]`. |
|
||||
@@ -38,7 +41,15 @@ the blocks fall back to their defaults. The group-classes block's class
|
||||
select is a dropdown of active group classes fetched from
|
||||
`GET /us-scheduler/v1/offerings?kind=group_class`; a stored class that is no
|
||||
longer offered shows as "Unavailable class #N" rather than silently falling
|
||||
back to all classes. The link targets are also available
|
||||
back to all classes. The booking block's lesson-type select works the same way
|
||||
against `?kind=private_lesson` ("Unavailable lesson type #N"), and the live
|
||||
page says so plainly when the pinned type has been withdrawn.
|
||||
|
||||
The booking block's options reach the front end as data attributes on
|
||||
`#us-booking-app` (`data-lesson-type`, `data-type-filter`) or as omitted
|
||||
containers (`displayMode`), which `assets/js/booking.js` reads on load — see
|
||||
`lesson-booking.md`. Its editor preview follows `displayMode`, showing the
|
||||
calendar, the upcoming-lessons panel, or both. The link targets are also available
|
||||
to the shortcodes as `[us_booking login_page_id="…"]` and
|
||||
`[us_student_login booking_page_id="…"]`; auto-redirect is block-only.
|
||||
|
||||
|
||||
@@ -58,6 +58,28 @@ instructor, the tied offering when there is one, otherwise a matching
|
||||
`duration_minutes`). The filter is a browsing aid only: the server re-checks
|
||||
every booking regardless.
|
||||
|
||||
Two block/shortcode options change what the filter has to work with (see
|
||||
`editor-blocks.md`), passed to the script as data attributes on
|
||||
`#us-booking-app`:
|
||||
|
||||
- **A pinned lesson type** (`data-lesson-type`) narrows the catalog to that one
|
||||
offering, so the page lists only the times bookable as it and books nothing
|
||||
else — the filter control hides itself, there being one type left. A pinned
|
||||
type that is no longer offered shows "This lesson type is not available for
|
||||
booking right now" rather than an empty calendar.
|
||||
- **Filter off** (`data-type-filter="0"`) drops the **Show Only** button
|
||||
entirely; every open time is listed, as before the filter existed.
|
||||
|
||||
## Embedding Halves of the Page
|
||||
The page has two halves — the booking calendar and the student's upcoming
|
||||
lessons — and the block/shortcode can embed either on its own (`displayMode` /
|
||||
`show`: `both` (default), `booking`, `upcoming`). The template simply omits the
|
||||
containers of the half that is not wanted, and the script skips the work that
|
||||
belongs to a missing container: an upcoming-only embed never requests
|
||||
availability or the offering catalog, and a booking-only embed never requests
|
||||
`GET /bookings`. An unrecognised value renders the whole page, so a typo cannot
|
||||
silently hide half of it.
|
||||
|
||||
## Cancellation
|
||||
Students cancel their own lessons via `POST /bookings/{id}/cancel` (idempotent).
|
||||
Cancelling marks the lesson `cancelled`, frees the availability slot for
|
||||
@@ -120,7 +142,7 @@ acceptance time and IP), and their intake-question answers. On **My Lessons** an
|
||||
instructor may only open their own lessons; the studio **Scheduler** may open any.
|
||||
|
||||
## Frontend Shortcodes
|
||||
- `[us_booking]` — student calendar + registration flow; requires `book_lesson` capability
|
||||
- `[us_booking]` — student calendar + registration flow; requires `book_lesson` capability. Attributes: `login_page_id`, `lesson_type` (pin one private-lesson offering), `show_filter` (`no` hides the **Show Only** filter), `show` (`both` / `booking` / `upcoming`)
|
||||
- `[us_student_login]` — front-end login form for students
|
||||
|
||||
## Implementation
|
||||
|
||||
Reference in New Issue
Block a user