From bcd078bf0a5119fe0c8441b803b4fe05fdaa6d18 Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Sat, 12 Mar 2016 14:39:06 +0100 Subject: Plugin: add render_feed hook and call it while generating ATOM and RSS feed. Create an example of the new hook in the demo plugin. --- plugins/demo_plugin/demo_plugin.php | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) (limited to 'plugins') diff --git a/plugins/demo_plugin/demo_plugin.php b/plugins/demo_plugin/demo_plugin.php index f5f028e0..18834e53 100644 --- a/plugins/demo_plugin/demo_plugin.php +++ b/plugins/demo_plugin/demo_plugin.php @@ -322,4 +322,29 @@ function hook_demo_plugin_delete_link($data) if (strpos($data['url'], 'youtube.com') !== false) { exit('You can not delete a YouTube link. Don\'t ask.'); } -} \ No newline at end of file +} + +/** + * Execute render_feed hook. + * Called with ATOM and RSS feed. + * + * Special data keys: + * - _PAGE_: current page + * - _LOGGEDIN_: true/false + * + * @param array $data data passed to plugin + * + * @return array altered $data. + */ +function hook_demo_plugin_render_feed($data) +{ + foreach ($data['links'] as &$link) { + if ($data['_PAGE_'] == Router::$PAGE_FEED_ATOM) { + $link['description'] .= ' - ATOM Feed' ; + } + elseif ($data['_PAGE_'] == Router::$PAGE_FEED_RSS) { + $link['description'] .= ' - RSS Feed'; + } + } + return $data; +} -- cgit v1.2.3