kaiseki/wp-hook

Register classes with add_filter and add_action hooks

Installs: 1 277

Dependents: 26

Suggesters: 0

Security: 0

Stars: 1

Watchers: 2

Forks: 1

Open Issues: 2

pkg:composer/kaiseki/wp-hook

1.0.1 2022-02-06 10:23 UTC

This package is auto-updated.

Last update: 2025-10-05 13:11:59 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 calling registerCallbacks