PHP code example of kaiseki / wp-hook

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

    

kaiseki / wp-hook example snippets


use Kaiseki\WordPress\Hook\HookProviderInterface;

final class SetupTheme implements HookProviderInterface
{
    public function addHooks(): void
    {
        add_action('after_setup_theme', [$this, 'registerMenus']);
    }

    public function registerMenus(): void
    {
        // register_nav_menus(...);
    }
}

return [
    'hook' => [
        'provider' => [
            SetupTheme::class,
        ],
    ],
];

use Kaiseki\WordPress\Hook\HookProviderRegistry;

/** @var HookProviderRegistry $registry */
$registry = $container->get(HookProviderRegistry::class);
$registry->addHooks();