From 7fde6de1212323418401c15efba06026c704ca87 Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Fri, 14 Oct 2016 13:22:58 +0200 Subject: New init function for plugins, supports errors reporting All plugins can optionally add an init function named `pluginname_init()` which is called when the plugin is loaded. This function is aware of the config, and can return initialization errors, which are displayed in the header template. Note that the previous error system hack no longer work. --- plugins/demo_plugin/demo_plugin.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'plugins/demo_plugin/demo_plugin.php') diff --git a/plugins/demo_plugin/demo_plugin.php b/plugins/demo_plugin/demo_plugin.php index 18834e53..7335c9d4 100644 --- a/plugins/demo_plugin/demo_plugin.php +++ b/plugins/demo_plugin/demo_plugin.php @@ -14,6 +14,23 @@ * and check user status with _LOGGEDIN_. */ +/** + * Initialization function. + * It will be called when the plugin is loaded. + * This function can be used to return a list of initialization errors. + * + * @param $conf ConfigManager instance. + * + * @return array List of errors (optional). + */ +function demo_plugin_init($conf) +{ + $conf->get('toto', 'nope'); + + $errors[] = 'This a demo init error.'; + return $errors; +} + /** * Hook render_header. * Executed on every page redering. -- cgit v1.2.3