• 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  ('&oacute;', 'ó', $z);
        $z = str_ireplace  ('&middot;', '-', $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’ 🙂

    http://wordpress.org/extend/plugins/rss-in-page/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter ascetix

    (@ascetix)

    as an example of page with mentioned changes:
    http://blog.koszykzdomenami.pl/domenowe-wiadomosci/

    Thread Starter ascetix

    (@ascetix)

    Hi,

    I don’t know why, but for me strip_htmltags for “img” doesn’t work properly- I see many <img> tags with some images in parsed feeds. To work it out I’ve added another preg_replace line.

    I always added “iframe” to strip_htmltags. So, now, after some additional cleanings/customisations I use:

    $feed->strip_htmltags(array('p', 'a', 'b', 'strong', 'i', 'em', 'u', 'div', 'table', 'iframe', 'td', 'tr', 'img', 'span', 'h1', 'h2', 'h3', 'h4', 'ul', 'ol', 'li' ..... /* and other tags */ ));
    $feed->strip_comments(true);
    
    [...]
    
    if ($rss_items[$i]->get_description() != '') $z = $rss_items[$i]->get_description();
        $z = str_ireplace  ('&oacute;', 'ó', $z);
        $z = str_ireplace  ('&middot;', '-', $z);
        $z = preg_replace  ('/<br\s+\/>/i', ' ', $z);
        $z = preg_replace  ('/<br\/>/i', ' ', $z);
        $z = preg_replace  ('/<br>/i', ' ', $z);
        $z = preg_replace  ('/[ \t\f]+/i', ' ', $z);
        $z = preg_replace  ('/https?[^\s]+/i', '[url]', $z);
        $z = preg_replace  ('/<img[^>]*>/i', '[img]', $z);
        $z = preg_replace  ('/[\r\n]/i', '•', $z);
    
    if ($rssdescriptionlength != 'all') {
    if(strlen($z) > $rssdescriptionlength)
     { $z = mb_substr($z, 0, $rssdescriptionlength,  'UTF-8').'... '; }
    }
        $z = str_ireplace  ('[url]', '<i>[url]</i> ', $z);
        $z = str_ireplace  ('[img]', '<i>[img]</i> ', $z);
        $z = preg_replace  ('/•[ •]*/i', '&diams;', $z);

    It results in importing more interesting texts from rss feed. It’s also safer.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Plugin: RSS in Page] great plugin, some changes expected’ is closed to new replies.