# HVAC Plugin Deployment Checklist

## Pre-Deployment Checklist

### 1. Code Quality Checks
- [ ] All PHP files pass syntax check (`php -l`)
- [ ] No debug code left in files (`error_log`, `var_dump`, `console.log`)
- [ ] All TODO comments addressed or documented
- [ ] Code follows WordPress coding standards

### 2. Testing Complete
- [ ] All unit tests passing
- [ ] E2E tests passing on staging
- [ ] Manual testing checklist completed
- [ ] Tested with different user roles
- [ ] Mobile responsive testing done

### 3. Security Review
- [ ] All user inputs sanitized
- [ ] All outputs escaped
- [ ] Nonces implemented for forms
- [ ] Capability checks in place
- [ ] No hardcoded credentials

### 4. Performance Check
- [ ] Database queries optimized
- [ ] Caching implemented where appropriate
- [ ] Assets minified (production)
- [ ] Images optimized
- [ ] No unnecessary API calls

### 5. Documentation Updated
- [ ] CLAUDE.md updated with new features
- [ ] README files current
- [ ] Inline code documentation complete
- [ ] API changes documented
- [ ] Changelog updated

## Deployment Steps

### 1. Staging Deployment

```bash
# Run pre-deployment validation
bin/pre-deployment-check.sh

# Deploy to staging
scripts/deploy.sh staging

# Run post-deployment verification
scripts/verify-plugin-fixes.sh
```

### 2. Staging Verification
- [ ] Login functionality working
- [ ] Navigation menus displaying correctly
- [ ] All pages loading (no 404s)
- [ ] Forms submitting properly
- [ ] Certificates generating
- [ ] Email notifications sending
- [ ] No PHP errors in logs
- [ ] No JavaScript console errors

### 3. Data Integrity
- [ ] Database migrations completed
- [ ] User roles properly assigned
- [ ] Page templates correctly set
- [ ] Meta data preserved
- [ ] Settings maintained

### 4. Cache Management
- [ ] WordPress cache cleared
- [ ] Breeze cache purged
- [ ] OPcache reset
- [ ] CDN cache cleared (if applicable)
- [ ] Browser cache considerations documented

### 5. Production Deployment

```bash
# Only when explicitly approved
scripts/deploy.sh production
# Double confirmation required
```

### 6. Production Verification
- [ ] Smoke test critical paths
- [ ] Monitor error logs for 30 minutes
- [ ] Check page load times
- [ ] Verify email delivery
- [ ] Test payment processing (if applicable)
- [ ] Confirm analytics tracking

## Post-Deployment

### 1. Monitoring (First 24 Hours)
- [ ] Error logs checked every 2 hours
- [ ] Performance metrics reviewed
- [ ] User feedback collected
- [ ] Support tickets monitored
- [ ] Database performance checked

### 2. Communication
- [ ] Stakeholders notified of deployment
- [ ] Support team briefed on changes
- [ ] Documentation updated if needed
- [ ] Known issues documented

### 3. Rollback Plan
- [ ] Backup location confirmed
- [ ] Rollback procedure tested
- [ ] Rollback decision criteria defined
- [ ] Team members know rollback process

## Rollback Procedure

If critical issues are discovered:

```bash
# 1. SSH to server
ssh user@server

# 2. Navigate to plugins directory
cd /path/to/wp-content/plugins

# 3. Backup current (problematic) version
mv hvac-community-events hvac-community-events-broken-$(date +%Y%m%d)

# 4. Restore previous version
cp -r hvac-backups/hvac-community-events-backup-[previous-date] hvac-community-events

# 5. Reactivate plugin
wp plugin activate hvac-community-events

# 6. Clear all caches
wp cache flush
wp breeze purge --all
wp eval 'if (function_exists("opcache_reset")) opcache_reset();'

# 7. Verify functionality
# 8. Document issue for investigation
```

## Common Deployment Issues

### Issue: Pages returning 404
```bash
wp rewrite flush
wp eval 'HVAC_Page_Manager::create_required_pages();'
```

### Issue: Styles not loading
```bash
# Check if CSS files exist
ls -la wp-content/plugins/hvac-community-events/assets/css/

# Force cache refresh
wp cache flush
```

### Issue: User roles not working
```bash
# Re-run role creation
wp eval 'HVAC_Roles::create_roles();'
```

### Issue: Database errors
```bash
# Check database integrity
wp db check

# Optimize tables
wp db optimize
```

## Emergency Contacts

- **Lead Developer**: [Contact Info]
- **DevOps**: [Contact Info]
- **Project Manager**: [Contact Info]
- **Hosting Support**: [Contact Info]

## Final Checks

- [ ] All checklist items completed
- [ ] Deployment documented in project log
- [ ] Next deployment date scheduled
- [ ] Lessons learned documented
- [ ] Team debriefed

---

**Remember**: 
- Never deploy on Fridays unless critical
- Always have a rollback plan
- Test everything on staging first
- Document any deviations from process
- Communicate clearly with all stakeholders