Login   Register  
PHP Classes
elePHPant
Icontem

File: init.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  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: 6 years ago
Size: 1,027 bytes
 

Contents

Class file image Download
<?php

//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
$SHP->developer_set_hook('test');

//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
$SHP->load_plugins();

//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) {
    global 
$SHP;
    
$SHP->add_hook($where$function);
}

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

?>