Download the PHP package pinkcrab/hook-loader without Composer

On this page you can find all versions of the php package pinkcrab/hook-loader. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package hook-loader

Hook_Loader

The PinkCrab Hook Hook_Loader.

alt text Open Source Love codecov

For more details please visit our docs. https://perique.info/lib/Hook_Loader.html

Version

Release 1.2.0

Since v1.0.0 we have made some changes to have this all works under the hood, we have changed from Loader to Hook_Loader as the main class, but Loader has been left in as pollyfill for older versions.

Why?

WordPress and especially WooCommerce is built around hooks and if you have to register a lot of them, it can be hard to keep track of them all and what is currently being registered with WP.

The PinkCrab Hook_Loader gives a more manageable way of registering and removing hook call, shortcode and ajax calls.

Setup

Once you have the hook loader installed it just case of putting it to use. As this is all held as a class, you can pass the instance as depenedecnies to any class you wish to give access to the loader.

Registering Hooks (actions & filters)

Hook_Loader::action(string $hook, callable $method, int $priority=10, int $args = 1): void

Hook_Loader::admin_action(string $hook, callable $method, int $priority=10, int $args = 1): void

Hook_Loader::front_action(string $hook, callable $method, int $priority=10, int $args = 1): void

Hook_Loader::filter(string $hook, callable $method, int $priority=10, int $args = 1): void

Hook_Loader::admin_filter(string $hook, callable $method, int $priority=10, int $args = 1): void

Hook_Loader::front_filter(string $hook, callable $method, int $priority=10, int $args = 1): void

Use with a class.

Hook Removal (actions & filters)

Hook_Loader::remove(string $hook, callable $method, int $priority=10): void

Hook_Loader::remove_filter(string $hook, callable $method, int $priority=10): void

Hook_Loader::remove_hook(string $hook, callable $method, int $priority=10): void

While remove_action() and remove_filter() are prefectly suitable 90% of the time, it can be tricky to unset hooks with have been added as isntance to classes, you can not recall the same instance. Out Hook_Removal class will manually remove all hooks based on the class name (instance or static use). Allowing for the removal of hooks created by other plugins.

Even if the hook was added via a class instance, you only need to use the class name to add the method used. This allows the avoidance of having to recreate an instance of the class and potentially rerunning other hooks and setup routines.

Shortcodes

Hook_Loader::shortcode(string $hook, callable $method): void

You can easily add shortcodes using the loader, not only that you ensure they come with fully populated objects behind them

Ajax

Hook_Loader::ajax(string $hook, callable $method, bool $public, bool $private): void

If you want to register ajax calls, it requires 2 hook calls. This soon gets messy if you are setting up multiple calls. The Hook_Loader can handle registering either or both of this with a single declaration.

As with the other examples this can be used as part of class to create self contained ajax calls. While this can be done manually, the Registerables package comes with a very useful Ajax abstract class which can be used.

Filtering Hooks

It is possible access the Hook Collection before it is registered, this allows for the filtering of the hooks.

You can either use the Hook_Collection class constant Hook_Collection::REGISTER_HOOKS or its literal string value pinkcrab/loader/register_hooks

License

MIT License

http://www.opensource.org/licenses/mit-license.html

Change Log


All versions of hook-loader with dependencies

PHP Build Version
Package Version
Requires php Version >=7.1.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package pinkcrab/hook-loader contains the following files

Loading the files please wait ....