Skip to content

blockifywp/hooks

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Blockify Hooks

Hook methods by comment annotation in docblock.

Based on Hook Annotations by Viktor Szépe - https://github.com/szepeviktor/SentencePress

Installation

composer require blockify/hooks

Usage

PHP

First, require Composer's autoloader and then register the hooks with WordPress:

require_once __DIR__ . '/vendor/autoload.php';

Add hook tag and optional priority to method docblock:

class MyPlugin
{
	/**
	 * Enqueue scripts.
	 * 
	 * @hook wp_enqueue_scripts 12
	 */
	public function enqueueScripts()
	{
		wp_enqueue_script('my-script', 'path/to/my-script.js', [], null, true);
	}
}

Then, call the annotations method on the class:

use Blockify\Hooks\Hook;

$my_class = new MyPlugin();

Hook::annotations( $my_class );

About

Hook methods based on annotation.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages