RSS feed item content selection plugin

Post plugins and custom CSS snippets here
svangren
Bear Rating Trainee
Bear Rating Trainee
Posts: 3
Joined: 14 Feb 2017, 00:58

RSS feed item content selection plugin

Postby svangren » 14 Feb 2017, 23:54

I came across an RSS feed in which the description at times ended up being longer than the actual contents. The default behaviour in this case is to use the longest of the two fields as content, and for this feed, that sucked.

So, at the behest of fox, I've slapped together a plugin to help alleviate the issue!

Once the plugin is installed and enabled, you can configure it on a per-feed basis: Edit feed->Plugins, and you'll find "RSS Force Content Item" with three options: "Default" (doesn't do anything), "Force Description" (this setting will in fact remove the contents entirely, leaving only the description behind), and "Force Content" (like the previous setting, except it removes the description entirely, leaving only the contents).

It should ignore Atom feeds entirely, as they are not subject to the same issue (they always prioritize the contents over the description).

It's pretty quick and dirty (mostly because I'm an absolute n00b when it comes to PHP), but should do the job! Let me know if it blows up. I haven't really testet it much yet...



For the underlying technicalities: For unknown reasons (or, more specifically, for the reason "because publishers are idiots and can't use tags properly", according to the changelogs), the RSS feed items concider the "description" as content in certain cases when the description is longer than the content [classes/feeditem/rss.php, line 69].

This can cause a clash with how the entry contents are decided on [include/rssfuncs.php, line 664], in which it first tries the contents, and then the description if the contents are empty. For these RSS feed items, the description has already been decided as the content, causing the actual contents to be discarded.

This plugin can circumvent this by removing the description entirely (causing the feed item to always go for the content), or, if need be, removing the content entirely (forcing the description to always be used).

Atom feed items do not have the description/content conflation in the get_content() method [classes/feeditem/atom.php, line 62], and so the content will always have priority for these feeds.
Attachments
af_forcecontent.zip
Plugin to force an RSS feed item to use either description or content as the article contents
(1.67 KiB) Downloaded 204 times

Return to “Themes and plugins”

Who is online

Users browsing this forum: No registered users and 1 guest