[Plugin: RSS in Page] great plugin, some changes expected
-
Hello,
I’m a new user of “RSS in page”. Plugin is great, but I had to made some changes.
Some of them would be interesting for other users. Some of them are just ‘improvements’.
1) for UTF-8 pages
You used substr for cropping titles/descriptions that were longer that should be. I’ve changed to mb_substr:
– for title:
if(strlen($rsstitle) > $rsstitlelength) // <strong>original</strong>: { $rsstitle = substr($rsstitle, 0, $rsstitlelength).'... '; } { $rsstitle = mb_substr($rsstitle, 0, $rsstitlelength, 'UTF-8').'... '; } }
– for description:
if ($rssdescriptionlength != 'all') { if(strlen($z) > $rssdescriptionlength) // <strong>original</strong>: { $z = substr($z, 0, $rssdescriptionlength).'... '; } { $z = mb_substr($z, 0, $rssdescriptionlength, 'UTF-8').'... '; } }
2) change frequency for reading rss feeds
In your plugin you set up 60 seconds for cache ‘freshness’. I’ve changed for my blog to 3600s, to protect rss sources:$feed->set_cache_duration('3600');
3) setting rel=”nofollow” for links
For SEO improvement:// orig: $Y = '<a href="'.$rss_itemlink.'" target="'.$rsstarget.'" title="'.$rsslinketitle.'">'.$rsstitle.'</a>'; } else { $Y = $rsstitle; } $Y = '<a rel="nofollow" href="'.$rss_itemlink.'" target="'.$rsstarget.'" title="'.$rsslinketitle.'">'.$rsstitle.'</a>'; } else { $Y = $rsstitle; }
I think you could put an option for “nofollow” (like option rsstarget for “_blank”)
4) removing some html tags/comments from descriptions
There are numbers of reasons for doing it (cropping text sometimes breaks html tags; someone may not want to have links/pictures in feeds etc).$feed->strip_htmltags(array('p', 'a', 'b', 'strong', 'i', 'em', 'u', 'div', 'table', 'td', 'tr', 'img', 'span', 'h1', 'h2', 'h3', 'h4', 'ul', 'ol', 'li')); $feed->strip_comments(true);
5) I also did some other replacements for content of descriptions (below some examples, not a complete list):
if ($rss_items[$i]->get_description() != '') $z = $rss_items[$i]->get_description(); $z = str_ireplace ('ó', 'ó', $z); $z = str_ireplace ('·', '-', $z); $z = preg_replace ('/<br\s+\/>/i', ' ', $z); $z = preg_replace ('/<br\/>/i', ' ', $z); $z = preg_replace ('/<br>/i', ' ', $z); $z = preg_replace ('/[\r\n]/i', ' ', $z); $z = preg_replace ('/https?[^\s]+/i', '[url] ', $z);
(putting br to strip_htmltags array was not a good idea; strip_htmltags just cuts tags, I wanted to replace some of them to space – but, of course, one may prefer doing it the other way)
——–
I think 1), 2) and 3) could be interesting to others, 4) – many may want this as an option for some feeds, 5) is just a ‘feature’ ??
- The topic ‘[Plugin: RSS in Page] great plugin, some changes expected’ is closed to new replies.