diff --git a/CLAUDE.md b/CLAUDE.md index 9bfbaab..2ba18a5 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -1,4 +1,4 @@ -# WordPress BnB Management +# WordPress BnB Manager **Author:** Marco Graetsch **Author URL:** @@ -234,9 +234,18 @@ wp-bnb/ │ ├── Admin/ # Admin pages │ │ ├── Calendar.php # Availability calendar page │ │ └── Seasons.php # Seasons management page +│ ├── Blocks/ # Gutenberg blocks +│ │ └── BlockRegistrar.php # Block registration and rendering │ ├── Booking/ # Booking system │ │ ├── Availability.php # Availability checking │ │ └── EmailNotifier.php # Email notifications +│ ├── Frontend/ # Frontend components +│ │ ├── Search.php # Room search and AJAX handlers +│ │ ├── Shortcodes.php # All shortcode handlers +│ │ └── Widgets/ # WordPress widgets +│ │ ├── AvailabilityCalendar.php +│ │ ├── BuildingRooms.php +│ │ └── SimilarRooms.php │ ├── License/ │ │ └── Manager.php # License management │ ├── PostTypes/ # Custom post types @@ -256,10 +265,12 @@ wp-bnb/ ├── assets/ │ ├── css/ │ │ ├── admin.css # Admin styles -│ │ └── frontend.css # Frontend styles +│ │ ├── blocks-editor.css # Gutenberg editor styles +│ │ └── frontend.css # Frontend styles (~1250 lines) │ └── js/ │ ├── admin.js # Admin scripts -│ └── frontend.js # Frontend scripts +│ ├── blocks-editor.js # Gutenberg editor scripts +│ └── frontend.js # Frontend scripts (~825 lines) ├── templates/ # Twig templates (future) ├── languages/ # Translation files (future) └── releases/ # Release packages (git-ignored) @@ -560,3 +571,85 @@ Admin features always work; frontend requires valid license. - Same namespace classes can reference each other directly without use statements - Services meta box renders before pricing meta box so services total is available - Grand total calculation happens both on save (server-side) and on change (client-side JS) + +### 2026-02-02 - Version 0.6.0 (Frontend Features) + +**Completed:** + +- Created `src/Frontend/Search.php` class + - Room search with multiple filters: availability, capacity, room type, amenities, price range, building + - AJAX endpoints: `wp_bnb_search_rooms`, `wp_bnb_get_availability`, `wp_bnb_get_calendar`, `wp_bnb_calculate_price` + - Pagination support with configurable per_page + - Room data formatting for JSON responses with thumbnails, pricing, amenities + - Price range filtering using Calculator integration + - Availability filtering using Availability class +- Created `src/Frontend/Shortcodes.php` class + - `[bnb_buildings]` - Buildings list/grid with layout, columns, limit, orderby options + - `[bnb_rooms]` - Rooms list/grid with building, room_type, amenities filters + - `[bnb_room_search]` - Interactive search form with results container + - `[bnb_building id="X"]` - Single building display with rooms + - `[bnb_room id="X"]` - Single room display with availability form + - Grid system with 1-4 column support + - Sorting options: title, date, price, capacity +- Created `src/Frontend/Widgets/` directory with three widgets + - `SimilarRooms.php` - Shows rooms from same building/room type + - `BuildingRooms.php` - Lists all rooms in a building + - `AvailabilityCalendar.php` - Mini calendar with booking status + - All widgets extend `WP_Widget` with form/update/widget methods + - Auto-detection of current building/room from page context +- Created `src/Blocks/BlockRegistrar.php` class + - Five Gutenberg blocks: Building, Room, Room Search, Buildings List, Rooms List + - Server-side rendering using shortcode system + - Block editor assets (CSS/JS) enqueuing + - Block data localization with buildings, rooms, room types, amenities + - `render_callback` functions for each block type +- Created `assets/js/blocks-editor.js` + - Block registration using `wp.blocks.registerBlockType` + - InspectorControls for sidebar settings panels + - ServerSideRender for live preview in editor + - Attribute definitions matching shortcode parameters +- Created `assets/css/blocks-editor.css` + - Minimal editor styling for block placeholders + - Preview container styling +- Updated `assets/css/frontend.css` (~1250 lines) + - CSS custom properties for theming (colors, spacing, border-radius) + - Building and room card components + - Search form with field groups + - Results grid with responsive columns + - Calendar widget with availability states (available, booked, past, today) + - Legend styling + - Responsive breakpoints: 480px, 768px, 1024px +- Updated `assets/js/frontend.js` (~825 lines) + - `WpBnb` namespace with utility methods (ajax, formatDate, parseDate, debounce) + - `SearchForm` class: form submission, date validation, results rendering, load more + - `CalendarWidget` class: month navigation, AJAX calendar loading + - `AvailabilityForm` class: availability checking on single room pages + - `PriceCalculator` class: real-time price calculation with breakdown + - XSS-safe DOM construction using textContent instead of innerHTML +- Updated `src/Plugin.php` + - Added use statements for new frontend classes + - `init_frontend()` initializes Search, Shortcodes, BlockRegistrar + - `register_widgets()` method for widget registration + - `wp_localize_script()` adds AJAX URL, nonce, i18n strings to frontend +- Updated version to 0.6.0 in both plugin header and constant +- Updated CHANGELOG.md with comprehensive v0.6.0 release notes +- Updated PLAN.md to mark Phase 6 complete + +**Learnings:** + +- Server-side rendered Gutenberg blocks avoid complex build processes and ensure PHP/JS output consistency +- Shortcode system works well as render backend for blocks via `render_callback` +- Widget auto-detection from page context (`is_singular()`, `get_the_ID()`) reduces configuration +- CSS custom properties enable easy theming without modifying core styles +- AJAX nonce verification requires `wp_ajax_nopriv_` for non-logged-in users in frontend search +- Calendar data from `Availability::get_calendar_data()` provides consistent format for PHP and JS rendering +- XSS prevention in JS: use `textContent` for user data, `createElement` for structure +- Frontend components require license check (`LicenseManager::is_license_valid()`) before initialization +- Block editor requires separate script handle from frontend to avoid conflicts + +**Released:** + +- Committed: `864b8b2` on dev branch +- Merged to main (fast-forward) +- Tagged: `v0.6.0` +- Pushed to origin: dev, main, v0.6.0