1. Go to this page and download the library: Download amphibee/hookable library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
amphibee / hookable example snippets
use AmphiBee\Hooks\Action;
Action::add($name, $callback, $priority);
use AmphiBee\Hooks\Action;
Action::add('init', function () {
// do something here...
})->then([MyPlugin::class, 'checkUserIsAdmin']);
class MyPlugin
{
public static function checkUserIsAdmin($resultFromInitialCallback, ...$extraArgs)
{
// ...
}
}
use AmphiBee\Hooks\Action;
Action::do('my_plugin_action', $argument, $another);
use AmphiBee\Hooks\Action;
Action::remove('init', $callbackToRemove, $priority);
use AmphiBee\Hooks\Filter;
Filter::add('the_title', function ($title) {
return $title . ' is the title.';
});
use AmphiBee\Hooks\Filter;
Filter::add('the_title', function ($title) {
return $title . ' is the title.';
})->then('strtoupper');
use AmphiBee\Hooks\Contracts\Hookable;
class InitAction implements Hookable
{
public function execute()
{
// ...
}
}
Action::add('init', InitAction::class);
use AmphiBee\Hooks\Contracts\Hookable;
class TheTitleFilter implements Hookable
{
private string $title;
public function __construct(string $title)
{
$this->title = $title;
}
public function execute()
{
if ($this->title !== 'My First Post') {
return $this->title;
}
return "{$this->title} is Amazing!";
}
}
Filter::add('the_title', TheTitleFilter::class);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.