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/wallabag/wallabag.php | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'plugins/wallabag') diff --git a/plugins/wallabag/wallabag.php b/plugins/wallabag/wallabag.php index ec09c8a1..641e4cc2 100644 --- a/plugins/wallabag/wallabag.php +++ b/plugins/wallabag/wallabag.php @@ -6,10 +6,21 @@ require_once 'WallabagInstance.php'; -$wallabagUrl = $conf->get('plugins.WALLABAG_URL'); -if (empty($wallabagUrl)) { - $GLOBALS['plugin_errors'][] = 'Wallabag plugin error: '. - 'Please define the "WALLABAG_URL" setting in the plugin administration page.'; +/** + * Init function, return an error if the server is not set. + * + * @param $conf ConfigManager instance. + * + * @return array Eventual error. + */ +function wallabag_init($conf) +{ + $wallabagUrl = $conf->get('plugins.WALLABAG_URL'); + if (empty($wallabagUrl)) { + $error = 'Wallabag plugin error: '. + 'Please define the "WALLABAG_URL" setting in the plugin administration page.'; + return array($error); + } } /** -- cgit v1.2.3