diff options
author | Andrew Dolgov <[email protected]> | 2021-02-15 19:53:37 +0300 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2021-02-15 19:53:37 +0300 |
commit | caa5fe9c1541947067114e0968be7a2a28e35bc0 (patch) | |
tree | 28f5875d48ddb87d7b7bcb3f2bd750bd49e26fea |
update for tt-rss changes
-rw-r--r-- | init.php | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/init.php b/init.php new file mode 100644 index 0000000..49320e5 --- /dev/null +++ b/init.php @@ -0,0 +1,36 @@ +<?php +class Labels_To_Tags extends Plugin { + private $host; + + public function about() { + return array(1.0, + 'Add labels as tags in generated feeds', + 'vnab', + true); + } + + public function api_version() { + return 2; + } + + public function init( $host ) { + $this->host = $host; + $host->add_hook( $host::HOOK_ARTICLE_EXPORT_FEED, $this ); + } + + public function hook_article_export_feed( $line, $feed, $is_cat, $owner_uid ) { + + // get all LABELS for this article / line + $labels = Article::_get_labels($line['id'], $owner_uid); + + if (count($labels) > 0) { + foreach ($labels as $label) { + array_push($line['tags'], $label[1]); // the name of the label is in [1] + } + + $line['tags'] = array_unique($line['tags']); + } + + return $line; + } +} |