Resolved conflicts: - package.json: Use version 0.1.15 from main - wp-plugin-starter-template.php: Use version 0.1.15, keep Plugin class usage - AGENTS.md: Merge both versions, keep CI/CD content - .wiki/Architecture-Overview.md: Use .agents/ directory structure - wiki/* files: Delete (moved to .wiki/) - .agents/error-checking-feedback-loops.md: Keep from feature branch Also includes: - Renamed .ai-workflows/ to .agents/ - Renamed .ai-assistant.md to AGENTS.md - Updated version to 0.1.15
4.9 KiB
Architecture Overview
This document provides an overview of the plugin's architecture, explaining the core components and how they interact.
Directory Structure
The plugin follows a structured organization to maintain clean separation of concerns:
wp-plugin-starter-template/
├── admin/ # Admin-specific functionality
│ ├── css/ # Admin stylesheets
│ ├── js/ # Admin JavaScript files
│ └── lib/ # Admin PHP classes
├── assets/ # Frontend assets
│ ├── css/ # Frontend stylesheets
│ ├── js/ # Frontend JavaScript files
│ └── images/ # Images used by the plugin
├── includes/ # Core plugin functionality
│ ├── core.php # Core functionality class
│ ├── plugin.php # Main plugin class
│ └── Multisite/ # Multisite-specific functionality
├── languages/ # Translation files
├── tests/ # Test files
│ ├── e2e/ # End-to-end tests
│ └── unit/ # Unit tests
├── cypress/ # Cypress testing files
│ └── e2e/ # End-to-end test specifications
├── bin/ # Utility scripts
│ └── setup-test-env.sh # Test environment setup script
├── .github/ # GitHub-specific files
│ └── workflows/ # GitHub Actions workflows
├── .agents/ # AI workflow documentation
├── .wiki/ # Wiki documentation
│ ├── Testing-Framework.md # Testing framework documentation
│ └── Multisite-Development.md # Multisite development guide
└── wp-plugin-starter-template.php # Main plugin file
Core Components
Main Plugin File
The wp-plugin-starter-template.php file serves as the entry point for WordPress. It:
- Defines plugin metadata
- Prevents direct access
- Defines plugin constants
- Loads the main plugin class
- Initializes the plugin
Plugin Class
The Plugin class in includes/plugin.php is the main controller for the plugin. It:
- Initializes core functionality
- Sets up hooks and filters
- Manages plugin activation/deactivation
- Handles plugin updates
Core Class
The Core class in includes/core.php contains the core functionality of the plugin. It:
- Implements the main plugin features
- Provides utility methods
- Manages data processing
Admin Class
The Admin class in admin/lib/admin.php handles all admin-specific functionality. It:
- Creates admin menu pages
- Registers settings
- Enqueues admin assets
- Processes admin form submissions
Multisite Support
The Multisite class in includes/Multisite/class-multisite.php provides a foundation for multisite-specific functionality. It:
- Serves as a placeholder for multisite features
- Can be extended for custom multisite functionality
- Provides examples of multisite-specific methods
Object-Oriented Approach
The plugin follows object-oriented programming principles:
- Encapsulation: Each class encapsulates its own functionality
- Inheritance: Classes can extend others to inherit functionality
- Namespaces: PHP namespaces are used to avoid conflicts
- Autoloading: PSR-4 autoloading for efficient class loading
Hook System
The plugin integrates with WordPress through its hook system:
- Actions: Used to add functionality at specific points
- Filters: Used to modify data before it's used by WordPress
Data Flow
- WordPress loads the main plugin file
- The Plugin class is instantiated
- The Plugin class initializes the Core class
- The Plugin class initializes the Admin class (in admin context)
- WordPress hooks trigger plugin functionality as needed
Extensibility
The plugin is designed to be extensible:
- Filters: Key data points can be modified via filters
- Actions: Additional functionality can be added via actions
- Class Structure: Classes can be extended to add or modify functionality
Testing
The plugin includes a comprehensive testing framework:
- Unit Tests: For testing individual components
- End-to-End Tests: For testing the plugin as a whole
- WordPress Environment: Using wp-env for local testing
- Multisite Testing: Support for testing in multisite environments
- Continuous Integration: Automated tests via GitHub Actions
Conclusion
This architecture provides a solid foundation for WordPress plugin development, following best practices and modern coding standards. It's designed to be maintainable, extensible, and easy to understand.
For more details on using the testing framework, see Testing Framework. For multisite development guidelines, refer to Multisite Development.