diff --git a/bl-kernel/abstract/plugin.class.php b/bl-kernel/abstract/plugin.class.php index 59612eff..55313382 100644 --- a/bl-kernel/abstract/plugin.class.php +++ b/bl-kernel/abstract/plugin.class.php @@ -31,9 +31,13 @@ class Plugin { // (boolean) Enable or disable default Save and Cancel button on plugin settings public $formButtons; + // (array) List of custom hooks + public $customHooks; + function __construct() { $this->dbFields = array(); + $this->customHooks = array(); $reflector = new ReflectionClass(get_class($this)); diff --git a/bl-kernel/boot/rules/60.plugins.php b/bl-kernel/boot/rules/60.plugins.php index 66e885e4..7918123b 100644 --- a/bl-kernel/boot/rules/60.plugins.php +++ b/bl-kernel/boot/rules/60.plugins.php @@ -101,6 +101,16 @@ function buildPlugins() // If the plugin is installed insert on the hooks if ($Plugin->installed()) { + // Include custom hooks + if (!empty($Plugin->customHooks)) { + foreach ($Plugin->customHooks as $customHook) { + if (!isset($plugins[$customHook])) { + $plugins[$customHook] = array(); + $pluginsEvents[$customHook] = array(); + } + } + } + $pluginsInstalled[$pluginClass] = $Plugin; foreach ($pluginsEvents as $event=>$value) { if (method_exists($Plugin, $event)) { @@ -111,9 +121,9 @@ function buildPlugins() // Sort the plugins by the position for the site sidebar uasort($plugins['siteSidebar'], function ($a, $b) { - return $a->position()>$b->position(); - } - ); + return $a->position()>$b->position(); + } + ); } }