The plugin follows a modular architecture with clear separation of concerns:
woocommerce-percentage-shipping.php # Main plugin file
├── includes/
│ ├── class-wc-percentage-shipping-method.php # WooCommerce Shipping Method
│ ├── class-wc-percentage-shipping-calculator.php # Calculation logic
│ ├── class-wc-percentage-shipping-validator.php # Input validation
│ ├── class-wc-percentage-shipping-cache.php # Caching system
│ └── class-wc-percentage-shipping-logger.php # Logging system
├── assets/
│ ├── admin.css # Admin styles
│ └── admin.js # Admin JavaScript (Vanilla JS)
├── languages/ # Translation files
└── tests/ # Test suite
- PHP 8.3+
- WordPress 6.8+
- WooCommerce 10.0+
- MySQL 8.0+ or MariaDB 10.6+
- Composer (for dependencies)
# Clone repository
git clone https://github.com/tobiashaas/Woo-Percentage-Shipping.git
cd Woo-Percentage-Shipping
# Install dependencies
composer install
# Run tests
composer test# Alle Tests
composer test
# Mit Coverage-Report
composer test-coverage
# Tests im Watch-Modus
composer test-watch- Unit Tests: Einzelne Klassen und Methoden
- Integration Tests: Plugin-Integration mit WooCommerce
- Performance Tests: Caching und Performance-Metriken
Das Plugin implementiert ein intelligentes Caching-System:
// Cache-Schlüssel generieren
$cache_key = WC_Percentage_Shipping_Cache::generate_cache_key($package, $options);
// Cache abrufen
$cached_cost = WC_Percentage_Shipping_Cache::get($cache_key);
// Cache setzen
WC_Percentage_Shipping_Cache::set($cache_key, $result, 3600);- Cache-Hit-Rate: Überwachung der Cache-Effektivität
- Execution-Time: Messung der Berechnungszeit
- Memory-Usage: Überwachung des Speicherverbrauchs
- DEBUG: Detaillierte Debug-Informationen
- INFO: Allgemeine Informationen
- WARNING: Warnungen und Performance-Probleme
- ERROR: Fehler und Exceptions
// Debug-Log
WC_Percentage_Shipping_Logger::debug('Calculation started', $context);
// Info-Log
WC_Percentage_Shipping_Logger::info('Settings updated');
// Warning-Log
WC_Percentage_Shipping_Logger::warning('Slow calculation detected', $metrics);
// Error-Log
WC_Percentage_Shipping_Logger::error('Calculation failed', $error_context);- CSRF-Protection: Nonce-Verification für alle Formulare
- Input-Sanitization: Validierung und Sanitization aller Eingaben
- XSS-Protection: Proper Output Escaping
- Rate-Limiting: Schutz vor DoS-Angriffen
- Capability-Checks: Berechtigungsprüfungen
// AJAX-Requests limitieren
private function check_rate_limit(): bool
{
$user_id = get_current_user_id();
$key = 'wc_percentage_shipping_rate_limit_' . $user_id;
$requests = get_transient($key) ?: 0;
if ($requests >= (int) PluginSecurity::AJAX_RATE_LIMIT->value) {
return false;
}
set_transient($key, $requests + 1, 60);
return true;
}Das Plugin verwendet moderne Vanilla JavaScript ohne jQuery:
// Tooltip-System
class VanillaTooltip {
constructor() {
this.init();
}
showTooltip(event) {
// Tooltip-Logik
}
}
// Live-Preview-System
class LivePreview {
updatePreview() {
// Real-time Updates
}
}- Mobile-First: Responsive Design
- CSS-Grid: Moderne Layout-Techniken
- CSS-Variables: Konsistente Farben und Abstände
- Accessibility: ARIA-Labels und Keyboard-Navigation
- PSR-12: PHP Coding Standards
- Strict Types:
declare(strict_types=1) - Type Hints: Vollständige Typisierung
- DocBlocks: Umfassende Dokumentation
- PHP 8+ Features verwendet (Enums, Union Types, etc.)
- Proper Error Handling implementiert
- Security-Checks vorhanden
- Performance-Optimierungen berücksichtigt
- Tests geschrieben/aktualisiert
- Dokumentation aktualisiert
// Plugin-Version in mehreren Stellen synchronisieren:
// 1. Plugin-Header
// 2. PluginConfig::VERSION
// 3. README.md
// 4. Changelog- Tests ausführen:
composer test - Code-Quality prüfen: PHPStan, PHPCS
- Version aktualisieren: Alle Version-Referenzen
- Changelog aktualisieren: README.md
- Tag erstellen:
git tag v1.2.1 - Release erstellen: GitHub Release
// In den Plugin-Einstellungen
'debug_mode' => 'yes'- WooCommerce → Status → Logs
- Filter:
wc-percentage-shipping - Log-Level: Debug für detaillierte Informationen
- Cache-Probleme: Cache löschen bei Einstellungsänderungen
- Performance-Issues: Logs auf langsame Berechnungen prüfen
- Security-Warnings: Rate-Limiting und Nonce-Verification prüfen
WC_Percentage_Shipping_Plugin: Haupt-Plugin-KlasseWC_Percentage_Shipping_Method: WooCommerce Shipping MethodWC_Percentage_Shipping_Calculator: BerechnungslogikWC_Percentage_Shipping_Validator: Input-ValidierungWC_Percentage_Shipping_Cache: Caching-SystemWC_Percentage_Shipping_Logger: Logging-System
// Plugin-Hooks
add_action('woocommerce_shipping_init', 'include_shipping_method');
add_filter('woocommerce_shipping_methods', 'register_shipping_method');
// Cache-Hooks
add_action('woocommerce_settings_saved', 'clear_cache_on_settings_save');
// Cleanup-Hooks
add_action('wp_scheduled_delete', 'cleanup_old_logs');- Fork des Repositories
- Feature-Branch erstellen
- Tests schreiben für neue Features
- Code-Quality sicherstellen
- Pull-Request erstellen mit detaillierter Beschreibung
- Funktionalität und Tests
- Sicherheit und Performance
- Code-Qualität und Standards
- Dokumentation und Kommentare
- Backward-Compatibility
Bei Fragen oder Problemen:
- Issues: GitHub Issues für Bug-Reports
- Discussions: GitHub Discussions für Fragen
- Documentation: Diese Entwicklungsdokumentation
- Logs: WooCommerce Logs für Debugging