Download the PHP package wp-kit/invoker without Composer
On this page you can find all versions of the php package wp-kit/invoker. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package invoker
wp-kit/invoker
This is a wp-kit component that handles the invoking of controllers and closures based on a condition.
This component was built to run within an so is perfect for frameworks such as , and .
Often, WordPress developers want to group their actions and filters in a more defined context but do not want to use a traditional controller and would rather invoke a controller based on a condition rather than a path.
Sure, if we are using we can use , but we cannot pass in closures directly into the condition. With , you can invoke controllers more easily. Examples are below.
Lastly, as expected a is invoked once, and once only during the lifecycle of the application regardless of the number of times the condition is met to invoke the .
Installation
If you're using , install via in the root fo your installtion, otherwise install in your driven theme folder:
Setup
Add Service Provider
Just register the service provider and facade in the providers config and theme config:
Add Facade
If you are using Themosis or another driven framework, you may want to add , simply add them to your aliases:
Add Config File
The recommended method of installing config files for components is via command.
First, install WP CLI, and then install this component, will automatically be installed with , once installed you can run:
For more information, please visit .
Alternatively, you can place the config file(s) in your directory manually.
How To Use
Invoking
This may see back to front in terms of how works however we feel it is more intuitive to lead with the callback when using the Invoker.
Controllers
comes shipped with a that you can extend too to enable you to benefit from the enqueue scripts feature which helps to reduce the amount of code you need to write to output scripts and styles through .
Helpfully, wp-kit comes with two functions to more easily add hooks with reference to the current class. These two functions are action
and filter
; these functions fallback to the traditional functions add_action
and add_filter
which means they can be used 100% of the time.
Get Involved
To learn more about how to use check out the docs:
Any help is appreciated. The project is open-source and we encourage you to participate. You can contribute to the project in multiple ways by:
- Reporting a bug issue
- Suggesting features
- Sending a pull request with code fix or feature
- Following the project on GitHub
- Sharing the project around your community
For details about contributing to the framework, please check the contribution guide.
Requirements
Wordpress 4+
PHP 5.6+
License
wp-kit/invoker is open-sourced software licensed under the MIT License.