# EventBookings Plugin v1.5 - Release Notes

**Release Date**: 2026-04-20
**Version**: 1.5
**Previous Version**: 1.4

---

## 🎯 Release Highlights

Version 1.5 focuses on **caching bug fixes** and **admin UX improvements** for the event display settings.

### Key Improvements
- ✅ **Fixed Stale Customized Settings**: AJAX responses no longer served from browser/proxy cache
- ✅ **Fixed Bool Cast Corruption**: Non-boolean DB columns no longer incorrectly cast to `true`/`false`
- ✅ **Clear Cache Button**: Admins can now flush the object cache from the Settings page

---

## 🐛 Bug Fixes

### 1. `customized_settings` Returning Stale Data in `eventbookings_wp_get_event_details`
**File**: `includes/class-eventbookings-shortcode.php`

**Issue**: The AJAX handler was sending `Cache-Control: max-age=30000, public` (~8.3 hours), causing browsers and proxies to cache the entire response — including `customized_settings`. Changes made in the admin Settings page were not reflected until the cache expired.

**Fix**:
```php
// Before
header("Cache-Control: max-age=30000, public");

// After
header("Cache-Control: no-cache, no-store, must-revalidate");
```

---

### 2. All DB Columns Cast to Boolean in `customized_settings`
**File**: `includes/class-eventbookings-shortcode.php`

**Issue**: A `foreach` loop was casting every column returned by `SELECT *` to `(bool)`, which corrupted non-boolean fields such as `id` and `organisation_uuid` (both became `true`).

**Fix**: Cast only the known boolean `display_*` fields by name:
```php
// Before
foreach ($customized_settings as $key => $value) {
    $customized_settings[$key] = (bool)$value;
}

// After
$bool_fields = [
    'display_event_description', 'display_countdown', 'display_booking_start_countdown',
    'display_discount_end_countdown', 'display_event_start_countdown', 'display_event_end_countdown',
    'display_event_location_map', 'display_ticket_price_on_event_page', 'display_terms_and_condition'
];
foreach ($bool_fields as $field) {
    if (isset($customized_settings[$field])) {
        $customized_settings[$field] = (bool)$customized_settings[$field];
    }
}
```

The same fix was applied in `eventbookings_wp_get_events` and `eventbookings_wp_get_events_featured`.

---

## ✨ New Features

### 3. Clear Cache Button on Settings Page
**File**: `includes/class-eventbookings-settings.php`

Added a **Clear Cache** button next to **Save Settings** in the Customize Event Display section. Clicking it flushes all `eventbookings` object cache entries, so the next page load fetches fresh event data and settings from the API.

**Implementation**:
- Uses `wp_cache_flush_group('eventbookings')` on WordPress 6.1+
- Falls back to `wp_cache_flush()` on older versions
- Protected by the existing `eventbookings_secure_action` nonce
- Displays a "Cache cleared successfully!" admin notice on completion

---

## 🔧 Technical Changes

### Modified Files
- `eventbookings.php` — Version bump to 1.5
- `includes/js/package.json` — Version bump to 1.5
- `includes/class-eventbookings-shortcode.php` — Cache-Control header fix; bool cast scoped to display fields only
- `includes/class-eventbookings-settings.php` — Clear Cache button, handler, and success notice

### Database
No schema changes. `$eventbookings_db_version` remains at `1.4`.

---

## 📦 Deployment Checklist

- [x] Version numbers updated (`eventbookings.php`, `package.json`)
- [x] Cache-Control headers corrected
- [x] Bool cast fix applied to all three AJAX handlers
- [x] Clear Cache button tested in admin
- [ ] Full plugin testing in staging environment
- [ ] WordPress 6.8 compatibility verified

---

## ⚠️ Known Issues

None reported as of v1.5 release.

---

## 📄 License

This plugin is licensed under GPLv2 or later.
License URI: https://www.gnu.org/licenses/gpl-2.0.html
