kaiseki / wp-hook
Register classes with add_filter and add_action hooks
1.0.1
2022-02-06 10:23 UTC
Requires
- php: ^7.4
- kaiseki/wp-config: ^1.0
- psr/container: ^1.1
Requires (Dev)
- bnf/phpstan-psr-container: ^1.0
- eventjet/coding-standard: ^3.7
- infection/infection: ^0.25.3
- maglnet/composer-require-checker: ^3.5
- phpstan/extension-installer: ^1.0
- phpstan/phpstan: ^1.2
- phpstan/phpstan-phpunit: ^1.0
- phpstan/phpstan-strict-rules: ^1.1
- phpunit/phpunit: ^9.5
- thecodingmachine/phpstan-safe-rule: ^1.1
This package is auto-updated.
Last update: 2025-03-05 11:45:43 UTC
README
Register classes with add_filter
and add_action
hooks
Install
composer require kaiseki/wp-hook
Usage
- Implement a class with the
HookProviderInterface
, e.g.:
final class DoSomething implements \Kaiseki\WordPress\Hook\HookProviderInterface { public function registerCallbacks(): void { \add_action('after_setup_theme', [$this, 'doSomething'], 10, 1); } public function doSomething(): string { /*...*/ } }
- Add class name to config key
hook/provider
return [ 'hook' => [ 'provider' => [ DoSomething::class ], ], ];
- Classes registered on this key will be called by using
HookProviderRegistry
and callingregisterCallbacks