# Care Book Block Ultimate Advanced appointment control system for KiviCare - Hide doctors/services with intelligent CSS-first filtering approach. ## ๐Ÿš€ Features - **CSS-First Filtering**: Instant hiding of restricted doctors/services without page reload - **Modern PHP 8.3**: Leverages latest PHP features (readonly classes, enums, typed properties) - **WordPress Integration**: Native WordPress hooks and security - **KiviCare Compatible**: Works seamlessly with KiviCare 3.6.8+ - **Performance Optimized**: <1.5% page load overhead with intelligent caching - **Admin Interface**: Easy-to-use toggle system for managing restrictions - **Bulk Operations**: Manage multiple restrictions efficiently - **MySQL 8.0+ Optimized**: Advanced indexing and JSON metadata support ## ๐Ÿ“‹ System Requirements - **WordPress**: 6.0+ (Tested up to 6.8) - **PHP**: 8.1+ (Recommended: 8.3+) - **MySQL**: 8.0+ - **KiviCare Plugin**: 3.6.8+ ## ๐Ÿ—๏ธ Architecture ### Modern PHP 8+ Features - **Readonly Classes**: Immutable data models for security - **Enums**: Type-safe restriction types - **Strict Typing**: `declare(strict_types=1)` throughout - **PSR-4 Autoloading**: Modern namespace organization ### CSS-First Approach The plugin uses a CSS-first strategy to hide elements immediately on page load, preventing FOUC (Flash of Unstyled Content) and ensuring smooth user experience. ### Database Schema (MySQL 8.0+) Custom table `wp_care_booking_restrictions` with JSON metadata support and optimized indexing for high-performance queries. ### Security Framework (Multi-Layer) 1. WordPress nonces for CSRF protection 2. Capability checking for admin access 3. Input validation with PHP 8+ type safety 4. Output escaping and sanitization 5. Rate limiting for AJAX endpoints 6. Health monitoring and alerting 7. Audit logging system ## ๐ŸŽฏ Performance Targets (Updated) - **Page Load Overhead**: <1.5% (improved with PHP 8.3) - **Admin AJAX Response**: <75ms (MySQL 8.0 optimization) - **Restriction Toggle**: <200ms (enhanced caching) - **Cache Hit Ratio**: >98% (intelligent invalidation) - **Memory Usage**: <8MB (PHP 8+ efficiency) ## ๐Ÿงช Testing Strategy RED-GREEN-Refactor TDD with modern PHPUnit 10+: ```bash # Install dev dependencies (requires PHP extensions) composer install --dev # Run unit tests composer test # Run with coverage report composer test:coverage # Code quality checks composer quality ``` ## ๐Ÿ“ Project Structure (PSR-4) ``` care-book-block-ultimate/ โ”œโ”€โ”€ src/ # Modern PHP 8+ source code โ”‚ โ”œโ”€โ”€ Models/ # Domain models (readonly classes) โ”‚ โ”œโ”€โ”€ Services/ # Business logic services โ”‚ โ”œโ”€โ”€ Admin/ # Admin interface & AJAX โ”‚ โ”œโ”€โ”€ Integrations/KiviCare/ # KiviCare-specific integration โ”‚ โ”œโ”€โ”€ Cache/ # Caching system โ”‚ โ”œโ”€โ”€ Security/ # Multi-layer security โ”‚ โ””โ”€โ”€ Database/ # Migration & schema management โ”œโ”€โ”€ tests/ # PHPUnit 10+ tests โ”‚ โ”œโ”€โ”€ Unit/ # Unit tests (>90% coverage target) โ”‚ โ”œโ”€โ”€ Integration/ # WordPress/KiviCare integration tests โ”‚ โ””โ”€โ”€ Performance/ # Performance regression tests โ”œโ”€โ”€ vendor/ # Composer dependencies โ”œโ”€โ”€ care-book-block-ultimate.php # Main plugin file โ””โ”€โ”€ composer.json # Modern dependency management ``` ## ๐Ÿš€ Quick Start 1. **System Check** ```bash php -v # Ensure PHP 8.1+ mysql --version # Ensure MySQL 8.0+ ``` 2. **Install Dependencies** ```bash composer install --optimize-autoloader ``` 3. **Plugin Installation** - Upload to `/wp-content/plugins/care-book-block-ultimate/` - Activate in WordPress admin - Verify KiviCare 3.6.8+ is active 4. **Database Migration** - Automatic on activation - Creates optimized MySQL 8.0+ schema - Includes rollback capability ## ๐Ÿ”ง Development Guidelines ### Modern PHP Standards - **PHP 8.1+**: Required minimum version - **Strict Types**: `declare(strict_types=1)` in all files - **Readonly Properties**: Use for immutable data - **Enums**: Type-safe constants - **Match Expressions**: Instead of switch statements ### Database Best Practices - **MySQL 8.0+ Features**: JSON support, improved indexing - **Prepared Statements**: Always use $wpdb->prepare() - **Optimal Indexing**: Composite indexes for performance - **Health Monitoring**: Built-in performance tracking ### Security Implementation - **Multi-Layer Validation**: 7-layer security framework - **Type Safety**: PHP 8+ strict typing prevents injections - **WordPress Standards**: Nonces, capabilities, sanitization - **Real-time Monitoring**: Health checks and alerting ## ๐ŸŽฏ Implementation Status ### โœ… Completed (Phase 0) - [x] **T0.1**: Development Environment (PHP 8.3 + MySQL 8.0 verified) - [x] **T0.2**: Plugin Foundation Structure (PSR-4, security framework) - [x] **T0.3**: Database Migration System (MySQL 8.0 optimized) ### ๐Ÿ”„ In Progress (Phase 1) - [ ] **T1.1**: Core Domain Models (PHP 8+ features) - [ ] **T1.2**: Repository Pattern Implementation - [ ] **T1.3**: Multi-Layer Security System ### โณ Planned (Phase 2-3) - [ ] CSS Injection System with FOUC Prevention - [ ] WordPress Admin Interface (AJAX) - [ ] KiviCare Hook Integration - [ ] Advanced Caching System - [ ] Production Health Monitoring ## ๐Ÿ“Š Quality Metrics ### Code Quality - **Unit Test Coverage**: Target >90% - **PHP 8+ Compatibility**: Full support - **WordPress Standards**: Compliant - **Security Score**: Multi-layer validated ### Performance Benchmarks - **Plugin Load Time**: <50ms - **Database Queries**: <30ms average - **Memory Efficiency**: <8MB footprint - **Cache Performance**: >98% hit ratio ## ๐Ÿค Contributing 1. **Environment Setup**: PHP 8.1+ + MySQL 8.0+ required 2. **Fork Repository**: Create feature branch 3. **Write Tests First**: RED-GREEN-Refactor methodology 4. **Modern PHP**: Use readonly classes, enums, strict typing 5. **Security Review**: Multi-layer validation required 6. **Performance Testing**: Meet benchmark targets ## ๐Ÿ”’ Security & Compliance - **EOL Software**: PHP 7.4 and MySQL 5.7 not supported (security risks) - **Active Support**: Only latest stable versions supported - **Security Audits**: Multi-layer framework with continuous monitoring - **Data Protection**: GDPR-compliant data handling ## ๐Ÿ“„ License & Support **License**: GPL v2 or later **Support**: [https://descomplicar.pt](https://descomplicar.pt) **Documentation**: Full API documentation available **Issue Tracking**: GitHub Issues with security disclosure policy --- **Status**: ๐Ÿ”„ **Active Development** | **Phase**: 0-1 Foundation | **Next**: T1.1 Core Models