# CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

[... existing content remains unchanged ...]

## Communication Templates Implementation

The HVAC Community Events plugin includes a comprehensive communication templates system that enables trainers to create, manage, and reuse email templates for communicating with event attendees.

### Features
1. **Template Management Interface**: Modal-based CRUD operations for email templates
2. **Category Organization**: Templates organized by event phase (pre-event, reminders, post-event, certificates, general)
3. **Dynamic Placeholders**: Smart placeholder system for personalizing emails with attendee and event data
4. **Default Templates**: Professional templates installed automatically for new trainers
5. **AJAX Integration**: Real-time save/load operations without page refresh

### Files
- `includes/communication/class-communication-templates.php`: Core template management functionality and AJAX handlers
- `templates/communication/template-communication-templates.php`: Frontend interface with modal system
- `assets/css/communication-templates.css`: Styling for template interface and modals
- `assets/js/communication-templates.js`: Base JavaScript functionality (overridden by template)
- `tests/e2e/communication-templates-*.test.ts`: Comprehensive E2E test suite

### Technical Implementation
- **Modal System**: Custom overlay modal for create/edit operations
- **JavaScript Override**: Inline script after wp_footer() overrides external JS to ensure modal compatibility
- **Placeholder Processing**: Server-side replacement of dynamic content like {attendee_name}, {event_title}
- **REST API Integration**: Custom post type with REST API support for template operations
- **Permission System**: User-based template ownership with admin override capabilities

### Available Placeholders
- `{attendee_name}`, `{event_title}`, `{event_date}`, `{event_time}`, `{event_location}`
- `{trainer_name}`, `{business_name}`, `{trainer_email}`, `{trainer_phone}`
- `{current_date}`, `{website_name}`, `{website_url}`

### Recent Implementation (2025-06-13)
- Implemented full CRUD operations for template management
- Created modal-based interface with form validation
- Added JavaScript override system to handle external script conflicts
- Integrated AJAX handlers for real-time operations
- Added comprehensive E2E test coverage with Playwright
- Validated all functionality with extensive debugging and testing

## Memory Entries

- Do not make standalone 'fixes' which upload separate from the plugin deployment. Instead, always redeploy the whole plugin with your fixes. Before deploying, always remove the old versions of the plugin. Always activate and verify after plugin upload
- The deployment process now automatically clears Breeze cache after plugin activation through wp-cli. This ensures proper cache invalidation and prevents stale content issues.
- Communication Templates system uses a modal interface with JavaScript override after wp_footer() to ensure external JS doesn't conflict. Scripts load on communication-templates page only.
- When testing the UI, use playwright + screenshots which you inspect personally to verify that your features are working as intended.

[... rest of the existing content remains unchanged ...]