2 Commits

Author SHA1 Message Date
a784d92cc9 Add CF7 tag generator buttons for admin form editor (v0.7.1)
All checks were successful
Create Release Package / build-release (push) Successful in 59s
- Register tag generators via wpcf7_admin_init hook
- Add BnB Building select tag generator with first_as_label option
- Add BnB Room select tag generator with building_field and include_price options
- Add BnB Check-in date tag generator with min/max advance options
- Add BnB Check-out date tag generator with checkin_field and min/max nights options
- Add BnB Guests count tag generator with room_field and min/max/default options
- All generators support id and class attribute configuration
- Remove bug from Known Bugs section in CLAUDE.md

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-03 17:00:26 +01:00
f61dca5f45 Update CLAUDE.md with v0.7.0 session history
Document CF7 integration implementation details:
- Directory structure updated with Integration folder
- New CF7 assets (JS, CSS) documented
- Session history with learnings and patterns

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-03 16:34:00 +01:00
4 changed files with 649 additions and 3 deletions

View File

@@ -5,6 +5,19 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [0.7.1] - 2026-02-03
### Added
- CF7 Admin Tag Generator buttons:
- Tag generator buttons appear in CF7 form editor for all WP BnB custom tags
- BnB Building select with first option label configuration
- BnB Room select with building field linking and price display options
- BnB Check-in date with min/max advance booking days
- BnB Check-out date with check-in field linking and min/max nights
- BnB Guests count with room field linking and min/max/default values
- All generators support id and class attribute configuration
## [0.7.0] - 2026-02-03 ## [0.7.0] - 2026-02-03
### Added ### Added

View File

@@ -40,7 +40,7 @@ This project is proudly **"vibe-coded"** using Claude.AI - the entire codebase w
### Known Bugs ### Known Bugs
No known bugs at this time. (none)
## Technical Stack ## Technical Stack
@@ -260,6 +260,8 @@ wp-bnb/
│ │ ├── Calculator.php # Price calculation │ │ ├── Calculator.php # Price calculation
│ │ ├── PricingTier.php # Pricing tier enum │ │ ├── PricingTier.php # Pricing tier enum
│ │ └── Season.php # Seasonal pricing │ │ └── Season.php # Seasonal pricing
│ ├── Integration/ # Third-party integrations
│ │ └── CF7.php # Contact Form 7 integration
│ └── Taxonomies/ # Custom taxonomies │ └── Taxonomies/ # Custom taxonomies
│ ├── Amenity.php # Amenity taxonomy (tags) │ ├── Amenity.php # Amenity taxonomy (tags)
│ └── RoomType.php # Room type taxonomy (categories) │ └── RoomType.php # Room type taxonomy (categories)
@@ -270,10 +272,12 @@ wp-bnb/
│ ├── css/ │ ├── css/
│ │ ├── admin.css # Admin styles │ │ ├── admin.css # Admin styles
│ │ ├── blocks-editor.css # Gutenberg editor styles │ │ ├── blocks-editor.css # Gutenberg editor styles
│ │ ├── cf7-integration.css # CF7 form styles
│ │ └── frontend.css # Frontend styles (~1250 lines) │ │ └── frontend.css # Frontend styles (~1250 lines)
│ └── js/ │ └── js/
│ ├── admin.js # Admin scripts │ ├── admin.js # Admin scripts
│ ├── blocks-editor.js # Gutenberg editor scripts │ ├── blocks-editor.js # Gutenberg editor scripts
│ ├── cf7-integration.js # CF7 form scripts
│ └── frontend.js # Frontend scripts (~825 lines) │ └── frontend.js # Frontend scripts (~825 lines)
├── templates/ # Twig templates (future) ├── templates/ # Twig templates (future)
├── languages/ # Translation files (future) ├── languages/ # Translation files (future)
@@ -742,3 +746,65 @@ Admin features always work; frontend requires valid license.
- `use_block_editor_for_post_type` filter disables Gutenberg per post type - `use_block_editor_for_post_type` filter disables Gutenberg per post type
- Post types with `show_in_rest => true` get Gutenberg by default, which hides traditional meta boxes - Post types with `show_in_rest => true` get Gutenberg by default, which hides traditional meta boxes
- Form-based admin interfaces (data entry) should use classic editor, not block editor - Form-based admin interfaces (data entry) should use classic editor, not block editor
### 2026-02-03 - Version 0.7.0 (Contact Form 7 Integration)
**Completed:**
- Created `src/Integration/CF7.php` (~750 lines)
- Custom form tags: `[bnb_building_select]`, `[bnb_room_select]`, `[bnb_date_checkin]`, `[bnb_date_checkout]`, `[bnb_guests]`
- Server-side validation for all custom tags
- Availability validation in `wpcf7_before_send_mail` hook
- Automatic booking creation on form submission via `wpcf7_mail_sent`
- Guest record creation/linking using `find_or_create_guest()` pattern
- Custom mail tags: `[_bnb_room_name]`, `[_bnb_building_name]`, `[_bnb_calculated_price]`, `[_bnb_nights]`, `[_bnb_booking_reference]`
- Form type detection via CSS class `wp-bnb-booking-form`
- Created `assets/js/cf7-integration.js` (~230 lines)
- Building-based room filtering (rooms dropdown updates when building selected)
- Date validation (check-out after check-in, no past dates)
- Guest capacity validation against room limits
- AJAX availability checking with status display
- AJAX price calculation with formatted display
- Debounced updates to prevent excessive requests
- Created `assets/css/cf7-integration.css` (~200 lines)
- Two-column responsive form layout
- Availability status indicators (checking spinner, available checkmark, unavailable X)
- Price display formatting
- Capacity warning styling
- Dark mode support via `prefers-color-scheme`
- Print styles (hide interactive elements)
- Updated `src/Plugin.php`
- Added `use Magdev\WpBnb\Integration\CF7` import
- CF7 initialization in `init_frontend()` when WPCF7 class exists
- CF7 assets enqueuing with localized i18n strings
- Updated `README.md` with comprehensive CF7 documentation
- Custom form tags reference with options
- Example booking form template
- Example inquiry form template
- Custom mail tags documentation
**Files Created:**
- `src/Integration/CF7.php` - Main CF7 integration class
- `assets/js/cf7-integration.js` - Frontend JavaScript
- `assets/css/cf7-integration.css` - Form styling
**Learnings:**
- CF7 custom tags registered via `wpcf7_add_form_tag()` with callback functions
- Validation filters follow pattern `wpcf7_validate_{tag_name}`
- `wpcf7_before_send_mail` can abort submission by setting `$abort` to true and adding validation error
- `wpcf7_mail_sent` fires after successful email, ideal for booking creation
- Custom mail tags via `wpcf7_special_mail_tags` filter receive submission data
- Form type detection by CSS class more reliable than checking for specific tags
- Room dropdown with `data-building` attributes enables client-side filtering
- AJAX endpoints reuse existing `wp_bnb_get_availability` and `wp_bnb_calculate_price` actions
- CF7 assets should depend on `contact-form-7` script/style handles
- Guest linking uses email as unique identifier for find-or-create pattern
**Released:**
- Committed: `28350aa` on dev branch
- Merged to main (fast-forward)
- Tagged: `v0.7.0`
- Pushed to origin: dev, main, v0.7.0

View File

@@ -46,6 +46,9 @@ final class CF7 {
// Register custom form tags. // Register custom form tags.
add_action( 'wpcf7_init', array( self::class, 'register_form_tags' ) ); add_action( 'wpcf7_init', array( self::class, 'register_form_tags' ) );
// Register tag generators for admin.
add_action( 'wpcf7_admin_init', array( self::class, 'register_tag_generators' ), 60 );
// Register validation filters. // Register validation filters.
add_filter( 'wpcf7_validate_bnb_room_select', array( self::class, 'validate_room_select' ), 10, 2 ); add_filter( 'wpcf7_validate_bnb_room_select', array( self::class, 'validate_room_select' ), 10, 2 );
add_filter( 'wpcf7_validate_bnb_room_select*', array( self::class, 'validate_room_select' ), 10, 2 ); add_filter( 'wpcf7_validate_bnb_room_select*', array( self::class, 'validate_room_select' ), 10, 2 );
@@ -119,6 +122,570 @@ final class CF7 {
); );
} }
/**
* Register tag generators for CF7 admin.
*
* @return void
*/
public static function register_tag_generators(): void {
if ( ! class_exists( 'WPCF7_TagGenerator' ) ) {
return;
}
$tag_generator = \WPCF7_TagGenerator::get_instance();
// Building select tag generator.
$tag_generator->add(
'bnb_building_select',
__( 'BnB building', 'wp-bnb' ),
array( self::class, 'tag_generator_building_select' ),
array( 'version' => '2' )
);
// Room select tag generator.
$tag_generator->add(
'bnb_room_select',
__( 'BnB room', 'wp-bnb' ),
array( self::class, 'tag_generator_room_select' ),
array( 'version' => '2' )
);
// Check-in date tag generator.
$tag_generator->add(
'bnb_date_checkin',
__( 'BnB check-in', 'wp-bnb' ),
array( self::class, 'tag_generator_date_checkin' ),
array( 'version' => '2' )
);
// Check-out date tag generator.
$tag_generator->add(
'bnb_date_checkout',
__( 'BnB check-out', 'wp-bnb' ),
array( self::class, 'tag_generator_date_checkout' ),
array( 'version' => '2' )
);
// Guests count tag generator.
$tag_generator->add(
'bnb_guests',
__( 'BnB guests', 'wp-bnb' ),
array( self::class, 'tag_generator_guests' ),
array( 'version' => '2' )
);
}
/**
* Tag generator callback for building select.
*
* @param \WPCF7_ContactForm $contact_form Contact form object.
* @param array $options Tag generator options.
* @return void
*/
public static function tag_generator_building_select( $contact_form, $options = array() ): void {
$field_id = $options['content'] ?? 'wpcf7-tg-pane-bnb_building_select';
$field_type = 'bnb_building_select';
?>
<header class="description-box">
<h3><?php esc_html_e( 'BnB Building Select', 'wp-bnb' ); ?></h3>
<p><?php esc_html_e( 'Generates a dropdown to select a building. Use this to filter rooms by building.', 'wp-bnb' ); ?></p>
</header>
<div class="control-box">
<fieldset>
<legend id="<?php echo esc_attr( $field_id ); ?>-required-legend">
<?php esc_html_e( 'Field type', 'wp-bnb' ); ?>
</legend>
<label>
<input type="checkbox" name="required" aria-describedby="<?php echo esc_attr( $field_id ); ?>-required-legend" />
<?php esc_html_e( 'Required field', 'wp-bnb' ); ?>
</label>
</fieldset>
<fieldset>
<legend id="<?php echo esc_attr( $field_id ); ?>-name-legend">
<?php esc_html_e( 'Name', 'wp-bnb' ); ?>
</legend>
<input type="text" name="name" class="tg-name oneline" id="<?php echo esc_attr( $field_id ); ?>-name"
aria-describedby="<?php echo esc_attr( $field_id ); ?>-name-legend"
value="building" pattern="[A-Za-z][A-Za-z0-9_\-]*" />
</fieldset>
<fieldset>
<legend id="<?php echo esc_attr( $field_id ); ?>-first-as-label-legend">
<?php esc_html_e( 'First option label', 'wp-bnb' ); ?>
</legend>
<input type="text" name="first_as_label" class="option oneline"
id="<?php echo esc_attr( $field_id ); ?>-first-as-label"
aria-describedby="<?php echo esc_attr( $field_id ); ?>-first-as-label-legend"
placeholder="<?php esc_attr_e( '-- Select Building --', 'wp-bnb' ); ?>" />
</fieldset>
<fieldset>
<legend id="<?php echo esc_attr( $field_id ); ?>-id-legend">
<?php esc_html_e( 'Id attribute', 'wp-bnb' ); ?>
</legend>
<input type="text" name="id" class="idvalue oneline option"
id="<?php echo esc_attr( $field_id ); ?>-id"
aria-describedby="<?php echo esc_attr( $field_id ); ?>-id-legend" />
</fieldset>
<fieldset>
<legend id="<?php echo esc_attr( $field_id ); ?>-class-legend">
<?php esc_html_e( 'Class attribute', 'wp-bnb' ); ?>
</legend>
<input type="text" name="class" class="classvalue oneline option"
id="<?php echo esc_attr( $field_id ); ?>-class"
aria-describedby="<?php echo esc_attr( $field_id ); ?>-class-legend" />
</fieldset>
</div>
<footer class="insert-box">
<div class="flex-container">
<input type="text" name="<?php echo esc_attr( $field_type ); ?>" class="tag code" readonly onfocus="this.select()" />
<button type="button" class="button button-primary tag-generator-insert-button">
<?php esc_html_e( 'Insert Tag', 'wp-bnb' ); ?>
</button>
</div>
<p class="mail-tag-tip">
<?php
printf(
/* translators: %s: mail tag */
esc_html__( 'Use this tag in the Mail tab: %s', 'wp-bnb' ),
'<strong><span class="mail-tag"></span></strong>'
);
?>
</p>
</footer>
<?php
}
/**
* Tag generator callback for room select.
*
* @param \WPCF7_ContactForm $contact_form Contact form object.
* @param array $options Tag generator options.
* @return void
*/
public static function tag_generator_room_select( $contact_form, $options = array() ): void {
$field_id = $options['content'] ?? 'wpcf7-tg-pane-bnb_room_select';
$field_type = 'bnb_room_select';
?>
<header class="description-box">
<h3><?php esc_html_e( 'BnB Room Select', 'wp-bnb' ); ?></h3>
<p><?php esc_html_e( 'Generates a dropdown to select a room. Rooms are grouped by building and include capacity information.', 'wp-bnb' ); ?></p>
</header>
<div class="control-box">
<fieldset>
<legend id="<?php echo esc_attr( $field_id ); ?>-required-legend">
<?php esc_html_e( 'Field type', 'wp-bnb' ); ?>
</legend>
<label>
<input type="checkbox" name="required" aria-describedby="<?php echo esc_attr( $field_id ); ?>-required-legend" checked />
<?php esc_html_e( 'Required field', 'wp-bnb' ); ?>
</label>
</fieldset>
<fieldset>
<legend id="<?php echo esc_attr( $field_id ); ?>-name-legend">
<?php esc_html_e( 'Name', 'wp-bnb' ); ?>
</legend>
<input type="text" name="name" class="tg-name oneline" id="<?php echo esc_attr( $field_id ); ?>-name"
aria-describedby="<?php echo esc_attr( $field_id ); ?>-name-legend"
value="room" pattern="[A-Za-z][A-Za-z0-9_\-]*" />
</fieldset>
<fieldset>
<legend id="<?php echo esc_attr( $field_id ); ?>-building-field-legend">
<?php esc_html_e( 'Building field name', 'wp-bnb' ); ?>
</legend>
<input type="text" name="building_field" class="option oneline"
id="<?php echo esc_attr( $field_id ); ?>-building-field"
aria-describedby="<?php echo esc_attr( $field_id ); ?>-building-field-legend"
placeholder="building" />
<p class="description">
<?php esc_html_e( 'Enter the name of a building select field to filter rooms by selected building.', 'wp-bnb' ); ?>
</p>
</fieldset>
<fieldset>
<legend id="<?php echo esc_attr( $field_id ); ?>-include-price-legend">
<?php esc_html_e( 'Display options', 'wp-bnb' ); ?>
</legend>
<label>
<input type="checkbox" name="include_price" class="option" value="true"
aria-describedby="<?php echo esc_attr( $field_id ); ?>-include-price-legend" />
<?php esc_html_e( 'Include price in room options', 'wp-bnb' ); ?>
</label>
</fieldset>
<fieldset>
<legend id="<?php echo esc_attr( $field_id ); ?>-id-legend">
<?php esc_html_e( 'Id attribute', 'wp-bnb' ); ?>
</legend>
<input type="text" name="id" class="idvalue oneline option"
id="<?php echo esc_attr( $field_id ); ?>-id"
aria-describedby="<?php echo esc_attr( $field_id ); ?>-id-legend" />
</fieldset>
<fieldset>
<legend id="<?php echo esc_attr( $field_id ); ?>-class-legend">
<?php esc_html_e( 'Class attribute', 'wp-bnb' ); ?>
</legend>
<input type="text" name="class" class="classvalue oneline option"
id="<?php echo esc_attr( $field_id ); ?>-class"
aria-describedby="<?php echo esc_attr( $field_id ); ?>-class-legend" />
</fieldset>
</div>
<footer class="insert-box">
<div class="flex-container">
<input type="text" name="<?php echo esc_attr( $field_type ); ?>" class="tag code" readonly onfocus="this.select()" />
<button type="button" class="button button-primary tag-generator-insert-button">
<?php esc_html_e( 'Insert Tag', 'wp-bnb' ); ?>
</button>
</div>
<p class="mail-tag-tip">
<?php
printf(
/* translators: %s: mail tag */
esc_html__( 'Use this tag in the Mail tab: %s', 'wp-bnb' ),
'<strong><span class="mail-tag"></span></strong>'
);
?>
</p>
</footer>
<?php
}
/**
* Tag generator callback for check-in date.
*
* @param \WPCF7_ContactForm $contact_form Contact form object.
* @param array $options Tag generator options.
* @return void
*/
public static function tag_generator_date_checkin( $contact_form, $options = array() ): void {
$field_id = $options['content'] ?? 'wpcf7-tg-pane-bnb_date_checkin';
$field_type = 'bnb_date_checkin';
?>
<header class="description-box">
<h3><?php esc_html_e( 'BnB Check-in Date', 'wp-bnb' ); ?></h3>
<p><?php esc_html_e( 'Generates a date picker for check-in date selection with automatic validation.', 'wp-bnb' ); ?></p>
</header>
<div class="control-box">
<fieldset>
<legend id="<?php echo esc_attr( $field_id ); ?>-required-legend">
<?php esc_html_e( 'Field type', 'wp-bnb' ); ?>
</legend>
<label>
<input type="checkbox" name="required" aria-describedby="<?php echo esc_attr( $field_id ); ?>-required-legend" checked />
<?php esc_html_e( 'Required field', 'wp-bnb' ); ?>
</label>
</fieldset>
<fieldset>
<legend id="<?php echo esc_attr( $field_id ); ?>-name-legend">
<?php esc_html_e( 'Name', 'wp-bnb' ); ?>
</legend>
<input type="text" name="name" class="tg-name oneline" id="<?php echo esc_attr( $field_id ); ?>-name"
aria-describedby="<?php echo esc_attr( $field_id ); ?>-name-legend"
value="check_in" pattern="[A-Za-z][A-Za-z0-9_\-]*" />
</fieldset>
<fieldset>
<legend id="<?php echo esc_attr( $field_id ); ?>-min-advance-legend">
<?php esc_html_e( 'Minimum advance booking (days)', 'wp-bnb' ); ?>
</legend>
<input type="number" name="min_advance" class="option oneline" min="0" max="365"
id="<?php echo esc_attr( $field_id ); ?>-min-advance"
aria-describedby="<?php echo esc_attr( $field_id ); ?>-min-advance-legend"
placeholder="0" />
<p class="description">
<?php esc_html_e( 'Minimum days in advance required for booking (0 = today).', 'wp-bnb' ); ?>
</p>
</fieldset>
<fieldset>
<legend id="<?php echo esc_attr( $field_id ); ?>-max-advance-legend">
<?php esc_html_e( 'Maximum advance booking (days)', 'wp-bnb' ); ?>
</legend>
<input type="number" name="max_advance" class="option oneline" min="1" max="730"
id="<?php echo esc_attr( $field_id ); ?>-max-advance"
aria-describedby="<?php echo esc_attr( $field_id ); ?>-max-advance-legend"
placeholder="365" />
<p class="description">
<?php esc_html_e( 'Maximum days in advance allowed for booking.', 'wp-bnb' ); ?>
</p>
</fieldset>
<fieldset>
<legend id="<?php echo esc_attr( $field_id ); ?>-id-legend">
<?php esc_html_e( 'Id attribute', 'wp-bnb' ); ?>
</legend>
<input type="text" name="id" class="idvalue oneline option"
id="<?php echo esc_attr( $field_id ); ?>-id"
aria-describedby="<?php echo esc_attr( $field_id ); ?>-id-legend" />
</fieldset>
<fieldset>
<legend id="<?php echo esc_attr( $field_id ); ?>-class-legend">
<?php esc_html_e( 'Class attribute', 'wp-bnb' ); ?>
</legend>
<input type="text" name="class" class="classvalue oneline option"
id="<?php echo esc_attr( $field_id ); ?>-class"
aria-describedby="<?php echo esc_attr( $field_id ); ?>-class-legend" />
</fieldset>
</div>
<footer class="insert-box">
<div class="flex-container">
<input type="text" name="<?php echo esc_attr( $field_type ); ?>" class="tag code" readonly onfocus="this.select()" />
<button type="button" class="button button-primary tag-generator-insert-button">
<?php esc_html_e( 'Insert Tag', 'wp-bnb' ); ?>
</button>
</div>
<p class="mail-tag-tip">
<?php
printf(
/* translators: %s: mail tag */
esc_html__( 'Use this tag in the Mail tab: %s', 'wp-bnb' ),
'<strong><span class="mail-tag"></span></strong>'
);
?>
</p>
</footer>
<?php
}
/**
* Tag generator callback for check-out date.
*
* @param \WPCF7_ContactForm $contact_form Contact form object.
* @param array $options Tag generator options.
* @return void
*/
public static function tag_generator_date_checkout( $contact_form, $options = array() ): void {
$field_id = $options['content'] ?? 'wpcf7-tg-pane-bnb_date_checkout';
$field_type = 'bnb_date_checkout';
?>
<header class="description-box">
<h3><?php esc_html_e( 'BnB Check-out Date', 'wp-bnb' ); ?></h3>
<p><?php esc_html_e( 'Generates a date picker for check-out date selection with automatic validation against check-in.', 'wp-bnb' ); ?></p>
</header>
<div class="control-box">
<fieldset>
<legend id="<?php echo esc_attr( $field_id ); ?>-required-legend">
<?php esc_html_e( 'Field type', 'wp-bnb' ); ?>
</legend>
<label>
<input type="checkbox" name="required" aria-describedby="<?php echo esc_attr( $field_id ); ?>-required-legend" checked />
<?php esc_html_e( 'Required field', 'wp-bnb' ); ?>
</label>
</fieldset>
<fieldset>
<legend id="<?php echo esc_attr( $field_id ); ?>-name-legend">
<?php esc_html_e( 'Name', 'wp-bnb' ); ?>
</legend>
<input type="text" name="name" class="tg-name oneline" id="<?php echo esc_attr( $field_id ); ?>-name"
aria-describedby="<?php echo esc_attr( $field_id ); ?>-name-legend"
value="check_out" pattern="[A-Za-z][A-Za-z0-9_\-]*" />
</fieldset>
<fieldset>
<legend id="<?php echo esc_attr( $field_id ); ?>-checkin-field-legend">
<?php esc_html_e( 'Check-in field name', 'wp-bnb' ); ?>
</legend>
<input type="text" name="checkin_field" class="option oneline"
id="<?php echo esc_attr( $field_id ); ?>-checkin-field"
aria-describedby="<?php echo esc_attr( $field_id ); ?>-checkin-field-legend"
placeholder="check_in" />
<p class="description">
<?php esc_html_e( 'Enter the name of the check-in date field for date validation.', 'wp-bnb' ); ?>
</p>
</fieldset>
<fieldset>
<legend id="<?php echo esc_attr( $field_id ); ?>-min-nights-legend">
<?php esc_html_e( 'Minimum nights', 'wp-bnb' ); ?>
</legend>
<input type="number" name="min_nights" class="option oneline" min="1" max="365"
id="<?php echo esc_attr( $field_id ); ?>-min-nights"
aria-describedby="<?php echo esc_attr( $field_id ); ?>-min-nights-legend"
placeholder="1" />
</fieldset>
<fieldset>
<legend id="<?php echo esc_attr( $field_id ); ?>-max-nights-legend">
<?php esc_html_e( 'Maximum nights', 'wp-bnb' ); ?>
</legend>
<input type="number" name="max_nights" class="option oneline" min="1" max="365"
id="<?php echo esc_attr( $field_id ); ?>-max-nights"
aria-describedby="<?php echo esc_attr( $field_id ); ?>-max-nights-legend"
placeholder="365" />
</fieldset>
<fieldset>
<legend id="<?php echo esc_attr( $field_id ); ?>-id-legend">
<?php esc_html_e( 'Id attribute', 'wp-bnb' ); ?>
</legend>
<input type="text" name="id" class="idvalue oneline option"
id="<?php echo esc_attr( $field_id ); ?>-id"
aria-describedby="<?php echo esc_attr( $field_id ); ?>-id-legend" />
</fieldset>
<fieldset>
<legend id="<?php echo esc_attr( $field_id ); ?>-class-legend">
<?php esc_html_e( 'Class attribute', 'wp-bnb' ); ?>
</legend>
<input type="text" name="class" class="classvalue oneline option"
id="<?php echo esc_attr( $field_id ); ?>-class"
aria-describedby="<?php echo esc_attr( $field_id ); ?>-class-legend" />
</fieldset>
</div>
<footer class="insert-box">
<div class="flex-container">
<input type="text" name="<?php echo esc_attr( $field_type ); ?>" class="tag code" readonly onfocus="this.select()" />
<button type="button" class="button button-primary tag-generator-insert-button">
<?php esc_html_e( 'Insert Tag', 'wp-bnb' ); ?>
</button>
</div>
<p class="mail-tag-tip">
<?php
printf(
/* translators: %s: mail tag */
esc_html__( 'Use this tag in the Mail tab: %s', 'wp-bnb' ),
'<strong><span class="mail-tag"></span></strong>'
);
?>
</p>
</footer>
<?php
}
/**
* Tag generator callback for guests count.
*
* @param \WPCF7_ContactForm $contact_form Contact form object.
* @param array $options Tag generator options.
* @return void
*/
public static function tag_generator_guests( $contact_form, $options = array() ): void {
$field_id = $options['content'] ?? 'wpcf7-tg-pane-bnb_guests';
$field_type = 'bnb_guests';
?>
<header class="description-box">
<h3><?php esc_html_e( 'BnB Guests Count', 'wp-bnb' ); ?></h3>
<p><?php esc_html_e( 'Generates a number input for guest count with validation against room capacity.', 'wp-bnb' ); ?></p>
</header>
<div class="control-box">
<fieldset>
<legend id="<?php echo esc_attr( $field_id ); ?>-required-legend">
<?php esc_html_e( 'Field type', 'wp-bnb' ); ?>
</legend>
<label>
<input type="checkbox" name="required" aria-describedby="<?php echo esc_attr( $field_id ); ?>-required-legend" checked />
<?php esc_html_e( 'Required field', 'wp-bnb' ); ?>
</label>
</fieldset>
<fieldset>
<legend id="<?php echo esc_attr( $field_id ); ?>-name-legend">
<?php esc_html_e( 'Name', 'wp-bnb' ); ?>
</legend>
<input type="text" name="name" class="tg-name oneline" id="<?php echo esc_attr( $field_id ); ?>-name"
aria-describedby="<?php echo esc_attr( $field_id ); ?>-name-legend"
value="guests" pattern="[A-Za-z][A-Za-z0-9_\-]*" />
</fieldset>
<fieldset>
<legend id="<?php echo esc_attr( $field_id ); ?>-room-field-legend">
<?php esc_html_e( 'Room field name', 'wp-bnb' ); ?>
</legend>
<input type="text" name="room_field" class="option oneline"
id="<?php echo esc_attr( $field_id ); ?>-room-field"
aria-describedby="<?php echo esc_attr( $field_id ); ?>-room-field-legend"
placeholder="room" />
<p class="description">
<?php esc_html_e( 'Enter the name of the room select field to validate against room capacity.', 'wp-bnb' ); ?>
</p>
</fieldset>
<fieldset>
<legend id="<?php echo esc_attr( $field_id ); ?>-min-legend">
<?php esc_html_e( 'Minimum guests', 'wp-bnb' ); ?>
</legend>
<input type="number" name="min" class="option oneline" min="1" max="50"
id="<?php echo esc_attr( $field_id ); ?>-min"
aria-describedby="<?php echo esc_attr( $field_id ); ?>-min-legend"
placeholder="1" />
</fieldset>
<fieldset>
<legend id="<?php echo esc_attr( $field_id ); ?>-max-legend">
<?php esc_html_e( 'Maximum guests', 'wp-bnb' ); ?>
</legend>
<input type="number" name="max" class="option oneline" min="1" max="50"
id="<?php echo esc_attr( $field_id ); ?>-max"
aria-describedby="<?php echo esc_attr( $field_id ); ?>-max-legend"
placeholder="10" />
</fieldset>
<fieldset>
<legend id="<?php echo esc_attr( $field_id ); ?>-default-legend">
<?php esc_html_e( 'Default value', 'wp-bnb' ); ?>
</legend>
<input type="number" name="default" class="option oneline" min="1" max="50"
id="<?php echo esc_attr( $field_id ); ?>-default"
aria-describedby="<?php echo esc_attr( $field_id ); ?>-default-legend"
placeholder="1" />
</fieldset>
<fieldset>
<legend id="<?php echo esc_attr( $field_id ); ?>-id-legend">
<?php esc_html_e( 'Id attribute', 'wp-bnb' ); ?>
</legend>
<input type="text" name="id" class="idvalue oneline option"
id="<?php echo esc_attr( $field_id ); ?>-id"
aria-describedby="<?php echo esc_attr( $field_id ); ?>-id-legend" />
</fieldset>
<fieldset>
<legend id="<?php echo esc_attr( $field_id ); ?>-class-legend">
<?php esc_html_e( 'Class attribute', 'wp-bnb' ); ?>
</legend>
<input type="text" name="class" class="classvalue oneline option"
id="<?php echo esc_attr( $field_id ); ?>-class"
aria-describedby="<?php echo esc_attr( $field_id ); ?>-class-legend" />
</fieldset>
</div>
<footer class="insert-box">
<div class="flex-container">
<input type="text" name="<?php echo esc_attr( $field_type ); ?>" class="tag code" readonly onfocus="this.select()" />
<button type="button" class="button button-primary tag-generator-insert-button">
<?php esc_html_e( 'Insert Tag', 'wp-bnb' ); ?>
</button>
</div>
<p class="mail-tag-tip">
<?php
printf(
/* translators: %s: mail tag */
esc_html__( 'Use this tag in the Mail tab: %s', 'wp-bnb' ),
'<strong><span class="mail-tag"></span></strong>'
);
?>
</p>
</footer>
<?php
}
/** /**
* Render building select tag. * Render building select tag.
* *

View File

@@ -3,7 +3,7 @@
* Plugin Name: WP BnB Management * Plugin Name: WP BnB Management
* Plugin URI: https://src.bundespruefstelle.ch/magdev/wp-bnb * Plugin URI: https://src.bundespruefstelle.ch/magdev/wp-bnb
* Description: A comprehensive Bed & Breakfast management system for WordPress. Manage buildings, rooms, bookings, and guests. * Description: A comprehensive Bed & Breakfast management system for WordPress. Manage buildings, rooms, bookings, and guests.
* Version: 0.7.0 * Version: 0.7.1
* Requires at least: 6.0 * Requires at least: 6.0
* Requires PHP: 8.3 * Requires PHP: 8.3
* Author: Marco Graetsch * Author: Marco Graetsch
@@ -24,7 +24,7 @@ if ( ! defined( 'ABSPATH' ) ) {
} }
// Plugin version constant - MUST match Version in header above. // Plugin version constant - MUST match Version in header above.
define( 'WP_BNB_VERSION', '0.7.0' ); define( 'WP_BNB_VERSION', '0.7.1' );
// Plugin path constants. // Plugin path constants.
define( 'WP_BNB_PATH', plugin_dir_path( __FILE__ ) ); define( 'WP_BNB_PATH', plugin_dir_path( __FILE__ ) );