Download the PHP package morningtrain/wp-hooks without Composer
On this page you can find all versions of the php package morningtrain/wp-hooks. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download morningtrain/wp-hooks
More information about morningtrain/wp-hooks
Files in morningtrain/wp-hooks
Package wp-hooks
Short Description A system for organizing WordPress hooks
License MIT
Informations about the package wp-hooks
WP Hooks
To let you organize all your WordPress actions and filters.
Table of Contents
- Introduction
- Getting Started
- Installation
- Dependencies
- morningtrain/php-loader
- Usage
- Creating a hook
- Adding an action
- Adding a filter
- Adding a view on an action
- Creating a hook
- Credits
- Testing
- License
Introduction
This tool is made for organizing WordPress hooks.
This tool lets you:
- Load all .php files recursively in a directory
- Add filters and action using a fluid api
- Render Blade views directly on an action (if morningtrain/wp-view is installed)
Getting Started
To get started install the package as described below in Installation.
To use the tool have a look at Usage
Installation
Install with composer
Dependencies
morningtrain/php-loader
PHP Loader is used to load and initialize all Hooks
morningtrain/wp-view (optional)
WP View is used to load and initialize all Hooks
Usage
To load all Hooks of a given directory
Multiple Directories
Since this tool uses PHP Loader, you may use multiple directories.
Creating a Hook
To create a hook first call Hook::action
, Hook::filter
or Hook::view
. Then start a chain to add additional
parameters.
Adding an action
To add an action call Hook::action
. You may either add the callback as the second parameter or by using handle()
Note that it is not necessary to define the number of args for the callback. The action (or filter) will look at the callback's definition to know how many arguments it takes.
Adding a filter
Adding filters is just like adding action. Call Hook::filter
. You may either add the callback as the second parameter
or by using filter()
Note that it is not necessary to define the number of args for the callback. The action (or filter) will look at the callback's definition to know how many arguments it takes.
Adding a view on an action
You may, if the morningtrain/wp-view
package is installed, render a blade view directly from an action.
Note that you MUST define the number of args used in the hook since the hook has no callback method to analyze.
If you need to use the action params in your view you may render your view from another method or use view composing.
Using single use handlers (invokable)
You can use a single use class like so:
Credits
- Mathias Munk
- All Contributors
Testing
License
The MIT License (MIT). Please see License File for more information.