Add frontend features with search, shortcodes, widgets, and blocks (v0.6.0)
All checks were successful
Create Release Package / build-release (push) Successful in 1m20s

- Room search with availability, capacity, room type, amenity, price range, and building filters
- AJAX-powered search with pagination and load more
- Shortcodes: [bnb_buildings], [bnb_rooms], [bnb_room_search], [bnb_building], [bnb_room]
- Widgets: Similar Rooms, Building Rooms, Availability Calendar
- Gutenberg blocks: Building, Room, Room Search, Buildings List, Rooms List
- Frontend CSS with responsive design and CSS custom properties
- Frontend JavaScript with SearchForm, CalendarWidget, AvailabilityForm, PriceCalculator

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-02-02 14:08:11 +01:00
parent 05f24fdec7
commit 864b8b2869
14 changed files with 5573 additions and 19 deletions

View File

@@ -11,14 +11,21 @@ namespace Magdev\WpBnb;
use Magdev\WpBnb\Admin\Calendar as CalendarAdmin;
use Magdev\WpBnb\Admin\Seasons as SeasonsAdmin;
use Magdev\WpBnb\Blocks\BlockRegistrar;
use Magdev\WpBnb\Booking\Availability;
use Magdev\WpBnb\Booking\EmailNotifier;
use Magdev\WpBnb\Frontend\Search;
use Magdev\WpBnb\Frontend\Shortcodes;
use Magdev\WpBnb\Frontend\Widgets\AvailabilityCalendar;
use Magdev\WpBnb\Frontend\Widgets\BuildingRooms;
use Magdev\WpBnb\Frontend\Widgets\SimilarRooms;
use Magdev\WpBnb\License\Manager as LicenseManager;
use Magdev\WpBnb\PostTypes\Booking;
use Magdev\WpBnb\PostTypes\Building;
use Magdev\WpBnb\PostTypes\Guest;
use Magdev\WpBnb\PostTypes\Room;
use Magdev\WpBnb\PostTypes\Service;
use Magdev\WpBnb\Pricing\Calculator;
use Magdev\WpBnb\Privacy\Manager as PrivacyManager;
use Magdev\WpBnb\Pricing\Season;
use Magdev\WpBnb\Taxonomies\Amenity;
@@ -165,7 +172,28 @@ final class Plugin {
* @return void
*/
private function init_frontend(): void {
// Frontend shortcodes, blocks, and widgets will be added here.
// Initialize search (registers AJAX handlers).
Search::init();
// Initialize shortcodes.
Shortcodes::init();
// Initialize Gutenberg blocks.
BlockRegistrar::init();
// Register widgets.
add_action( 'widgets_init', array( $this, 'register_widgets' ) );
}
/**
* Register frontend widgets.
*
* @return void
*/
public function register_widgets(): void {
register_widget( SimilarRooms::class );
register_widget( BuildingRooms::class );
register_widget( AvailabilityCalendar::class );
}
/**
@@ -282,6 +310,35 @@ final class Plugin {
WP_BNB_VERSION,
true
);
wp_localize_script(
'wp-bnb-frontend',
'wpBnbFrontend',
array(
'ajaxUrl' => admin_url( 'admin-ajax.php' ),
'nonce' => wp_create_nonce( 'wp_bnb_frontend_nonce' ),
'i18n' => array(
'searching' => __( 'Searching...', 'wp-bnb' ),
'noResults' => __( 'No rooms found matching your criteria.', 'wp-bnb' ),
'resultsFound' => __( '%d rooms found', 'wp-bnb' ),
'loadMore' => __( 'Load More', 'wp-bnb' ),
'viewDetails' => __( 'View Details', 'wp-bnb' ),
'perNight' => __( 'night', 'wp-bnb' ),
'guests' => __( 'guests', 'wp-bnb' ),
'invalidDateRange' => __( 'Check-out must be after check-in', 'wp-bnb' ),
'selectDates' => __( 'Please select check-in and check-out dates.', 'wp-bnb' ),
'available' => __( 'Room is available!', 'wp-bnb' ),
'notAvailable' => __( 'Sorry, the room is not available for these dates.', 'wp-bnb' ),
'totalPrice' => __( 'Total', 'wp-bnb' ),
'bookNow' => __( 'Book Now', 'wp-bnb' ),
'total' => __( 'Total', 'wp-bnb' ),
'nights' => __( 'nights', 'wp-bnb' ),
'basePrice' => __( 'Base', 'wp-bnb' ),
'weekendSurcharge' => __( 'Weekend surcharge', 'wp-bnb' ),
'season' => __( 'Season', 'wp-bnb' ),
),
)
);
}
/**