# MaplePress Plugin Changelog

## [1.0.0] - 2024-10-27

### Added - API Key Authentication Flow

#### Activation Experience
- Plugin now redirects to settings page upon activation
- Setup wizard shows welcome message with step-by-step instructions
- Admin notice appears on all pages until API key is configured
- Links to external MaplePress dashboard for account creation

#### Settings Page Enhancements
- **Welcome Screen**: First-time users see detailed setup instructions
- **External Dashboard Links**:
  - Sign Up button: `https://getmaplepress.com/register`
  - Login button: `https://getmaplepress.com/login`
  - Dashboard link: `https://getmaplepress.com/dashboard`
- **API Key Validation**:
  - Validates key with backend on save
  - Shows clear success/error messages
  - Displays site details after successful connection
- **Connection Status Display**:
  - Site ID
  - Tenant ID
  - Domain
  - Plan tier
  - Active/Inactive status indicator

#### API Integration
- Enhanced API client error handling
- Stores site details from `/api/v1/plugin/status` response:
  - `site_id`
  - `tenant_id`
  - `domain`
  - `plan_tier`
  - `is_verified`
- Validates API key on every settings save
- Clear error messages for connection failures

#### Admin Experience
- **Admin Notice**: Persistent warning banner when setup is incomplete
- **Auto-redirect**: Redirects to settings page after activation
- **Smart Display**: Notices don't show on settings page itself
- **Status Indicators**: Visual feedback (✓/✗ and colored dots)

### Technical Changes

#### New Fields in Settings
- `tenant_id` - Tenant UUID from API
- `domain` - Site domain from API
- `plan_tier` - User's subscription plan
- `is_verified` - Boolean flag for valid API key
- `needs_setup` - Boolean flag to trigger setup notices

#### Modified Files
- `includes/class-maplepress-activator.php`
  - Added new settings fields
  - Default API URL set to `http://localhost:8000`
  - Added activation redirect transient

- `includes/class-maplepress-admin.php`
  - Added `display_admin_notices()` method
  - Added `activation_redirect()` method
  - Enhanced `validate_settings()` with site details storage
  - Better error handling and user feedback

- `includes/admin-settings-display.php`
  - Complete redesign of settings page
  - Conditional display based on connection status
  - Welcome wizard for first-time setup
  - Site details table for connected sites

### User Workflow

1. **Install & Activate**
   - Plugin activates → redirects to settings page
   - Sees welcome message with instructions

2. **Get API Key**
   - Clicks "Sign Up at MaplePress.io"
   - Creates account and site in external dashboard
   - Copies API key (shown only once)

3. **Configure Plugin**
   - Pastes API key in settings
   - Clicks "Save Settings & Verify Connection"
   - Plugin validates key with backend
   - Success: Shows site details and status
   - Failure: Shows error message

4. **Ongoing Use**
   - If not configured: Admin notice appears on all pages
   - If configured: Status shows in settings page
   - Can manage sites from external dashboard

### API Endpoints Used
- `GET /api/v1/plugin/status` - Verify API key and get site details

### Security
- API keys stored in WordPress options table
- All user input sanitized and escaped
- API communication over HTTPS (production)
- WordPress nonces for form submissions
