1. Go to this page and download the library: Download shinepress/hooks 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/ */
shinepress / hooks example snippets
use ShinePress\Hooks\HookManager;
function callback_function($param1, $param2) {
// code
}
// this can be used prior to initialization
HookManager::addFilter('filter_name', 'callback_function', 10, 2);
use ShinePress\Framework\Module;
use ShinePress\Hooks\Filter;
class CustomModule extends Module {
#[Filter('lowercase')]
public function lowercase(string $value): string {
return strtolower($value);
}
#[Filter('uppercase')]
public function uppercase(string $value): string {
return strtoupper($value);
}
}
CustomModule::register();
// WordPress Equivalent:
// add_filter('lowercase', [CustomModule::instance(), 'lowercase'], 10, 1);
// add_filter('uppercase', [CustomModule::instance(), 'uppercase'], 10, 1);
use ShinePress\Framework\Module;
use ShinePress\Hooks\Action;
use ShinePress\Hooks\Filter;
class CustomModule extends Module {
#[Filter('example-filter', 12)]
#[Action('example-action')]
public function exampleFunction(mixed $value) {
// do something
}
}
CustomModule::register();
// WordPress Equivalent:
// add_filter('example-filter', [CustomModule::instance(), 'exampleFunction'], 12, 1);
// add_action('example-action', [CustomModule::instance(), 'exampleFunction'], 10, 1);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.