PHP code example of dbout / wp-module-hook

1. Go to this page and download the library: Download dbout/wp-module-hook 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/ */

    

dbout / wp-module-hook example snippets


$loader = new \Dbout\Framework\Hook\HookLoader(
    directory: get_template_directory() . '/hooks',
);

$loader->register();

use Dbout\Framework\Hook\Attributes\Action;
use Dbout\Framework\Hook\Attributes\Filter;

class MyFirstHook {

    #[Action(name: 'wp_dashboard_setup', priority: 999)]
    public function setupDashboard(): void
    {
        // Do something   
    }
    
    #[Filter(name: 'crontrol/filtered-events', acceptedArgs: 2)]
    public function filterEvents(array $filtered, array $events): array
    {
        // Do something
        return $filtered;
    }
}