yard / brave-hooks
Brave hooks
Installs: 8
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 3
Forks: 0
Open Issues: 3
Type:package
pkg:composer/yard/brave-hooks
Requires
- php: >=8.2
- ext-dom: *
- ext-libxml: >=8.1
- lib-libxml: >=2.9
- roots/acorn: ^4.0|^5.0
- spatie/laravel-csp: ^2.0
- spatie/laravel-package-tools: ^1.16
- yard/wp-hook-registrar: ^2.0
Requires (Dev)
- 10up/wp_mock: ^0.4.2
- pestphp/pest: ^2.36
- szepeviktor/phpstan-wordpress: ^1.3
- yard/php-cs-fixer-rules: ^1.0
This package is auto-updated.
Last update: 2025-12-05 11:48:10 UTC
README
Features
- Register Hooks using php attributes
- Configure Hook registration using a config file
- Load plugin-specific hooks only when the plugin is active
Installation
-
Install this package with Composer:
composer require yard/brave-hooks
-
Run the Acorn WP-CLI command to discover this package:
wp acorn package:discover
-
Publish the config file with:
wp acorn vendor:publish --provider="Yard\Brave\Hooks\HookServiceProvider" -
Register all your project hooks in the published configuration file
config/hooks.php.
Usage
Add your custom hook classes to the hooks configuration file. Any hooks defined within these classes will be automatically registered with WordPress.
This plugin leverages wp-hook-registrar for hook registration. For detailed information about the hook registration process, please refer to that package's documentation.
Plugin-specific Hooks
Some classes contain hooks that should only be active when a specific WordPress plugin is active.
To achieve this, add the #[Plugin] attribute to the class containing hooks and provide the plugin's file path:
The plugin path should match the format required by the WordPress function is_plugin_active()
#[Plugin('advanced-custom-fields-pro/acf.php')] class ACF { ... }