# Boseat Booking

**Version:** 1.0.1  
**Requires at least:** WordPress 5.2  
**Tested up to:** 6.7  
**Requires PHP:** 7.2  
**License:** GPLv2 or later  
**Plugin URI:** https://boseat.com/wordpress-plugin  
**Author:** [Boseat](https://boseat.com)

---

## Description

The **Boseat Booking** plugin allows you to easily embed the **Boseat reservation widget** into your WordPress site.  
You can display it as a **modal**, **inline element**, **floating button**, or **direct iframe**.


### Key Features

- Easy integration with the `[boseat]` shortcode
- 4 display modes: `modal`, `inline`, `float`, `direct`
- Customizable parameters (tenant, workspace, seat, etc.)
- JavaScript event support for developers
- Avoid cookie-related redirect issues with direct iframe mode

---

## Installation

1. Download or clone this plugin into `/wp-content/plugins/`
2. Activate it via the **Plugins** menu
3. Configure the plugin under **Settings > Boseat Booking**
4. Use the `[boseat]` shortcode in your pages or posts

---

## Usage

### Basic shortcode

```plaintext
[boseat]
```

### With custom parameters

```plaintext
[boseat tenant="boseat" workspace="test" seat="test" button_text="Book now" display="modal"]
```

If you do not provide a `button_text`, the plugin will use a **localized default label** (for example, `"Réserver"` in French).

### Direct iframe display

```plaintext
[boseat display="direct" width="100%" height="600px"]
```

You can also force direct iframe mode via the shortcode attribute:

```plaintext
[boseat tenant="boseat" workspace="test" seat="test" use_direct_iframe="true" width="100%" height="600px"]
```

### Shortcode parameters

- `tenant` - Tenant identifier
- `workspace` - Workspace identifier
- `seat` - Seat identifier
- `button_text` - Button label (localized default if omitted)
- `display` - Display mode: `modal`, `inline`, `float` or `direct`
- `width` - Widget width in inline or direct mode
- `height` - Widget height in inline or direct mode
- `mode` - Execution mode: `live` or `test`
- `use_direct_iframe` - Set to `"true"`/`"1"` to always use direct iframe mode (bypasses the JS widget and can help with cookie/redirect issues)

---

## FAQ

### How to fix redirection issues?

1. Use `display="direct"` or enable **"direct iframe"** in the plugin settings.
2. Clear cookies related to `app.boseat.com`.
3. Ensure your site uses **HTTPS**.
4. Try in a private/incognito window.

### How can I listen to reservation events?

You can add custom JavaScript event listeners like this:

```javascript
document.addEventListener('boseat:booking-success', function(e) {
    console.log('Booking successful:', e.detail.bookingId);
});

document.addEventListener('boseat:booking-cancel', function(e) {
    console.log('Booking canceled:', e.detail.bookingId);
});

document.addEventListener('boseat:modal-open', function() {
    console.log('Modal opened');
});

document.addEventListener('boseat:modal-close', function() {
    console.log('Modal closed');
});
```

---

## Development

### Docker Setup

This repository includes a Docker Compose setup for local WordPress development.

**Important:** The Docker configuration mounts only the plugin file directly (read-only), protecting your repository from WordPress file operations.

**To get started:**

1. **Start Docker containers:**
   ```bash
   cd compose
   docker-compose up -d
   ```

2. **Access WordPress:**
   - WordPress: http://localhost:8888
   - **Default admin credentials:**
     - Username: `admin`
     - Password: `admin`
     - Email: `admin@example.com`
   
   These credentials are automatically set up on first run.

3. **After making changes to the plugin:**
   ```bash
   # Sync updated plugin file to compose directory
   compose/sync-plugin.sh
   
   # Restart WordPress to reload the plugin
   cd compose
   docker-compose restart wordpress
   ```

The plugin file is mounted read-only, so your repository remains safe from WordPress operations.

---

## Changelog

### 1.0.1
- Updated `Tested up to` to WordPress 6.7
- Added `readme.txt` for WordPress.org plugin directory compatibility

### 1.0.0
- First stable release of the plugin.