/ plugins / yotsuba_plugins.php
yotsuba_plugins.php
 1  <?
 2  
 3  	// yotsuba plugin API
 4  
 5  	// add a function $function to the list of callbacks named by $hook.
 6  	function register_callback($hook, $function) {
 7  		global $HOOKS;
 8  		if( !isset($HOOKS[$hook]) )
 9  			$HOOKS[$hook] = array($function);
10  		else
11  			array_push($HOOKS[$hook], $function);
12  	}
13  
14  	// run all the callback functions associated with the name $hook.
15  	// they will be passed $args.
16  	function run_callback($hook, $args) {
17  		global $HOOKS;
18  		if(isset($HOOKS[$hook]))
19  			foreach($HOOKS[$hook] as $function)
20  				if(function_exists($function))
21  					$function($args);
22  	}
23  
24  	// load plugins
25  	if(defined('PLUGIN_DIR'))
26  		foreach(explode(',', PLUGINS) as $plugin)
27  			include_once PLUGIN_DIR . trim($plugin) . '.php';
28  ?>