The plugin follows a modern PHP architecture with the following components:
- Core: Base functionality and plugin lifecycle
- Services: Reusable business logic
- Models: Database interaction and data structures
- Admin: WordPress admin interface components
- API: REST API endpoints and handlers
custom-plugin/
├── assets/
│ ├── css/
│ ├── js/
│ └── vendor/
├── config/
│ ├── app.php
│ └── database.php
├── docs/
├── languages/
├── src/
│ ├── Admin/
│ ├── Api/
│ ├── Core/
│ ├── Database/
│ ├── Models/
│ └── Services/
├── templates/
│ ├── admin/
│ ├── components/
│ └── layouts/
├── composer.json
└── custom-plugin.php
- Clone the repository
- Install dependencies:
composer install- Set up development environment:
composer run-script dev-setupThe plugin follows WordPress Coding Standards with some modern PHP practices:
- PSR-4 autoloading
- PHP 7.4+ features
- WordPress coding style for templates
- ESLint for JavaScript
- SCSS for stylesheets
namespace CustomPlugin\Feature;
class FeatureClass {
private string $property;
public function doSomething(): void {
// Implementation
}
}- Create service class in
src/Services/ - Register in
Pluginclass - Add configuration if needed
- Write tests
- Create endpoint class in
src/Api/ - Register routes in
RestApiclass - Add documentation
- Write tests
- Create page class in
src/Admin/ - Add templates in
templates/admin/ - Register in
AdminInterface - Add assets if needed
composer testcomposer test-integrationcomposer test-wordpresscomposer build-devcomposer buildcustom_plugin_init: Fired when plugin initializescustom_plugin_loaded: Fired after all components are loadedcustom_plugin_admin_init: Fired when admin interface initializes
custom_plugin_settings: Modify plugin settingscustom_plugin_api_response: Modify API responsescustom_plugin_cache_ttl: Modify cache duration
Create new migration:
composer create-migration "AddNewTable"Create new model:
composer create-model "CustomModel"- Fork the repository
- Create feature branch
- Write tests
- Submit pull request
See CONTRIBUTING.md for detailed guidelines.