diff --git a/bl-kernel/boot/rules/60.plugins.php b/bl-kernel/boot/rules/60.plugins.php index 1edb520e..afbee658 100644 --- a/bl-kernel/boot/rules/60.plugins.php +++ b/bl-kernel/boot/rules/60.plugins.php @@ -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) {