Update Code and shortend it

the new code allows mutliple plugins using the custom hook instead of overwriting the existing array
This commit is contained in:
Anika Kaiser 2019-03-17 11:46:44 +01:00 committed by GitHub
parent 4f1c27255c
commit 77b1c119e9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -99,25 +99,23 @@ function buildPlugins()
// If the plugin is installed insert on the hooks
if ($Plugin->installed()) {
// If the plugin contains the function "registerHooks" returning a String array,
//it will called and if those hooks are not existing they will added
if(method_exists($Plugin, "registerHooks")) {
foreach (call_user_func("{$Plugin->className()}::registerHooks") as $customEvent) {
if(!isset($plugins[$customEvent])){
$plugins[$customEvent] = array();
$pluginsEvents[$customEvent] = array();
}
}
}
foreach ($pluginsEvents as $event=>$value) {
if (method_exists($Plugin, $event)) {
array_push($plugins[$event], $Plugin);
}
}
/* THIS PART IS FOR CUSTOM HOOKS */
if(method_exists($Plugin, "registerHooks"))
{
foreach (call_user_func("{$Plugin->className()}::registerHooks") as $customEvent)
{
if (method_exists($Plugin, $customEvent))
{
$plugins[$customEvent] = array();
array_push($plugins[$customEvent], $Plugin);
}
}
}
/* THIS PART IS FOR CUSTOM HOOKS */
}
uasort($plugins['siteSidebar'], function ($a, $b) {