php hooks

PHP-Hooks WordPress like action and filter hooks in php

What is PHP-Hooks?

The PHP Hooks Class is a fork of the WordPress filters hook system rolled in to a class to be ported into any php based system.
This class is heavily based on the WordPress plugin API (props for the guys there) and most (if not all) of the code comes from there.
The way it works is simple and just like you would use them with in WordPress (both filter and action hooks) with one main difference and that is the OOP wrapper.

How To use it?

Simple, Include the class file in your application bootstrap (setup/load/configuration or whatever you call it) and start hooking your filter and action hooks using the global `$hooks`. Ex:

<?php
include_once('php-hooks.php');
global $hooks;
$hooks->add_action('header_action','echo_this_in_header');
function echo_this_in_header(){
   echo 'this came from a hooked function';
}

then all that is left for you is to call the hooked function when you want anywhere in your application, EX:

echo '<div id="extra_header">';
global $hooks;
$hooks->do_action('header_action');
echo '</div>';

and you output will be:

<div id="extra_header">this came from a hooked function</div>

Download and Support

You can download from the github repository.
Feel free to fork,extend and help grow as much as you'd like, and submit any issue you have to the issue tracker

License

Since this class is derived from the WordPress Plugin API so are the license and they are GPL

That is it for now so Enjoy.

Incoming search terms:

Ohad Raz

WordPress Consultant, a WordPress Developer and a WordPress Freelancer With over 10 years experience in architecting web sites and applications. WordPress Development moderator and somethimes Plugin Developer.