2008-05-18, 08:13 PM
Hi i want to suggest new improvements to the pluginSystem class.
1. have the ability to call a class method
You'll have only to edit a bit the caching of the $hooks array as add_hook expects that $function is a string, but what about if it is an array? Anyway it should be very easy to implement.
2. second is to check if the function exists
Easy to do but useful IMO.
1. have the ability to call a class method
$plugins->add_hook("global_start", array(a, "a"));
You'll have only to edit a bit the caching of the $hooks array as add_hook expects that $function is a string, but what about if it is an array? Anyway it should be very easy to implement.
$this->hooks[$hook][$priority][$function] = array(
"function" => $function,
"file" => $file
);
As you can see the key of the array has the value of $function, but what about if it is an array?2. second is to check if the function exists
function add_hook($hook, $function, $priority=10, $file="")
{
// Check to see if we already have this hook running at this priority
if(is_array($this->hooks[$hook][$priority][$function]))
{
return true;
}
// Add the hook
if(function_exists($function))
{
$this->hooks[$hook][$priority][$function] = array(
"function" => $function,
"file" => $file
);
return true;
}
}
Easy to do but useful IMO.