Implement Phase 7: Contact Form 7 Integration (v0.7.0)
All checks were successful
Create Release Package / build-release (push) Successful in 1m1s
All checks were successful
Create Release Package / build-release (push) Successful in 1m1s
Add custom CF7 form tags for booking requests: - [bnb_building_select] - Building filter dropdown - [bnb_room_select] - Room selection with capacity data - [bnb_date_checkin/checkout] - Date pickers with validation - [bnb_guests] - Guest count with capacity limits Features: - Server-side validation for all fields - Real-time AJAX availability checking - Automatic price calculation display - Booking creation on form submission - Guest record creation/linking - Custom mail tags for CF7 templates Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
1087
src/Integration/CF7.php
Normal file
1087
src/Integration/CF7.php
Normal file
File diff suppressed because it is too large
Load Diff
@@ -16,6 +16,7 @@ use Magdev\WpBnb\Booking\Availability;
|
||||
use Magdev\WpBnb\Booking\EmailNotifier;
|
||||
use Magdev\WpBnb\Frontend\Search;
|
||||
use Magdev\WpBnb\Frontend\Shortcodes;
|
||||
use Magdev\WpBnb\Integration\CF7;
|
||||
use Magdev\WpBnb\Frontend\Widgets\AvailabilityCalendar;
|
||||
use Magdev\WpBnb\Frontend\Widgets\BuildingRooms;
|
||||
use Magdev\WpBnb\Frontend\Widgets\SimilarRooms;
|
||||
@@ -202,6 +203,11 @@ final class Plugin {
|
||||
|
||||
// Register widgets.
|
||||
add_action( 'widgets_init', array( $this, 'register_widgets' ) );
|
||||
|
||||
// Initialize Contact Form 7 integration if CF7 is active.
|
||||
if ( class_exists( 'WPCF7' ) ) {
|
||||
CF7::init();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -362,6 +368,43 @@ final class Plugin {
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
// Load CF7 integration assets if CF7 is active.
|
||||
if ( class_exists( 'WPCF7' ) ) {
|
||||
wp_enqueue_style(
|
||||
'wp-bnb-cf7',
|
||||
WP_BNB_URL . 'assets/css/cf7-integration.css',
|
||||
array( 'contact-form-7' ),
|
||||
WP_BNB_VERSION
|
||||
);
|
||||
|
||||
wp_enqueue_script(
|
||||
'wp-bnb-cf7',
|
||||
WP_BNB_URL . 'assets/js/cf7-integration.js',
|
||||
array( 'contact-form-7' ),
|
||||
WP_BNB_VERSION,
|
||||
true
|
||||
);
|
||||
|
||||
wp_localize_script(
|
||||
'wp-bnb-cf7',
|
||||
'wpBnbCF7',
|
||||
array(
|
||||
'ajaxUrl' => admin_url( 'admin-ajax.php' ),
|
||||
'nonce' => wp_create_nonce( 'wp_bnb_frontend_nonce' ),
|
||||
'i18n' => array(
|
||||
'selectRoom' => __( '-- Select Room --', 'wp-bnb' ),
|
||||
'checking' => __( 'Checking availability...', 'wp-bnb' ),
|
||||
'available' => __( 'Room is available!', 'wp-bnb' ),
|
||||
'unavailable' => __( 'Room is not available for these dates', 'wp-bnb' ),
|
||||
'invalidDateRange' => __( 'Check-out must be after check-in', 'wp-bnb' ),
|
||||
'capacityExceeded' => __( 'Maximum %d guests for this room', 'wp-bnb' ),
|
||||
'estimatedTotal' => __( 'Estimated Total', 'wp-bnb' ),
|
||||
'nights' => __( 'nights', 'wp-bnb' ),
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user