Update 60.plugins.php

With custom hooks, you can place your plugin's data anywhere you want. For example, you have a footer and you want to have links in your footer. There is a link plugin that displays links in the SiteBar with "<? Php Theme :: plugins ('siteSidebar');?>". If you put this code in your footer, all plugins that use "siteSidebar" will be placed in your footer. With my pull request you can now create your own hooks and it can be guaranteed that only a single plugin places its data there but only if its the only plugin implementing your custom hook.

How to create custom hooks:
in your plugin.php you have to place a  public function "registerHooks" returning an array of String.

´´´ public function registerHooks()
    {
        return array(
            "akLinks",
            "akBusinessHours"
        );
    }
```
This commit is contained in:
Anika Kaiser 2019-03-06 23:24:51 +01:00 committed by GitHub
parent 98acc58597
commit 4f1c27255c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -104,6 +104,20 @@ function buildPlugins()
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) {