PHP Classes

File: init.php

Recommend this page to a friend!
  Classes of Nemanja Avramovic   Simple Hooks Plugin   init.php   Download  
File: init.php
Role: Example script
Content type: text/plain
Description: Class initalization
Class: Simple Hooks Plugin
Setup and call application plug-in scripts
Author: By
Last change: defined new hook
Date: 15 years ago
Size: 1,027 bytes


Class file image Download

//include Simple Hooks Plugin Class
include "SHP.class.php";

//create instance of class
$SHP = new SHP();

//set hook to which plugin developers can assign functions

//set multiple hooks to which plugin developers can assign functions
$SHP->developer_set_hooks(array('test1','test2', 'with_args'));

//load plugins from folder, if no argument is supplied, a './plugins/' constant will be used
//trailing slash at the end is REQUIRED!
//this method will load all *.plugin.php files from given directory, INCLUDING subdirectories

//now, this is a workaround because plugins, when included, can't access $SHP variable, so we
//as developers have to basically redefine functions which can be called from plugin files
function add_hook($where, $function) {
$SHP->add_hook($where, $function);

//same as above
function register_plugin($plugin_id, $data) {
$SHP->register_plugin($plugin_id, $data);