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.
This commit is contained in:
ArthurHoaro 2016-03-12 14:39:06 +01:00
parent e67712ba0f
commit bcd078bf0a
2 changed files with 32 additions and 1 deletions
plugins/demo_plugin

View file

@ -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.');
}
}
}
/**
* 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;
}