wp-media / event-manager
Event Management System for WordPress
Installs: 2 057
Dependents: 3
Suggesters: 0
Security: 0
Stars: 2
Watchers: 13
Forks: 0
pkg:composer/wp-media/event-manager
Requires
- php: >=7.4
Requires (Dev)
- php: >=7.4
- dealerdirect/phpcodesniffer-composer-installer: ^0.7.0
- php-stubs/wordpress-tests-stubs: ^6.8
- phpcompatibility/phpcompatibility-wp: ^2.0
- phpstan/extension-installer: ^1.3
- phpstan/phpstan-mockery: ^1.1
- phpstan/phpstan-phpunit: ^1.4
- roave/security-advisories: dev-master
- szepeviktor/phpstan-wordpress: ^1.3
- wp-coding-standards/wpcs: ^3
- wp-media/phpunit: ^3
This package is auto-updated.
Last update: 2025-11-28 21:07:53 UTC
README
Event management system for WordPress
Overview
This event management system provides a centralized way to handle WordPress hooks (actions and filters) through an event subscriber pattern. It allows you to organize hook callbacks into dedicated subscriber classes, making your WordPress code more maintainable and testable by decoupling hook registration from business logic.
Purpose
This system provides a robust and scalable solution for managing events within WordPress, following best practices for event-driven architecture.
Installation
Install via Composer:
composer require wp-media/event-manager
Initialization
Initialize the Event Manager in your WordPress plugin or theme:
use WPMedia\EventManager\EventManager; use WPMedia\EventManager\PluginApiManager; $event_manager = new EventManager(new PluginApiManager()); $event_manager->add_subscriber(new YourEventSubscriber());
Usage
Creating an Event Subscriber
Implement the SubscriberInterface to listen to WordPress hooks:
use WPMedia\EventManager\SubscriberInterface; class YourEventSubscriber implements SubscriberInterface { public static function get_subscribed_events(): array { return [ 'init' => 'on_init', 'wp_enqueue_scripts' => ['on_enqueue_scripts', 10], ]; } public function on_init() { // Handle init hook } public function on_enqueue_scripts() { // Handle script enqueuing } }
Reference
- Original Design Article: Designing a System for WordPress Event Management
- Author: Carl Alexander
Implementation Notes
This implementation adapts the concepts from the referenced article to create a practical event management solution for WordPress applications.