rockschtar / wordpress-controller
Controller Trait for handling WordPress Hooks
Installs: 10 439
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Requires
- php: >=7.4
README
Controller Trait for handling WordPress Hooks
Requirements
- PHP >= 7.1
- Composer - Install
Installation
Use composer to install vendor/package-name.
composer install rockschtar/wordpress-controller
Usage
use Rockschtar\WordPress\Controller\HookController; class MyController { use HookController; private function __construct() { $this->addAction('wp_head', 'wpHead'); $this->addFilter('body_class', 'bodyClass'); } private function wpHead(): void { echo '<something></something>'; } private function bodyClass(?array $classes = []): array { if ($classes === null) { $classes = []; } $classes[] = 'my-body-class'; return $classes; } }
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.