asked on
<?
/*
Plugin Name: RSS Processor
Plugin URI: http://localhost
Description: Plugin to fetch parse and show RSS feeds.
Author: Author
Version: 1.0
Author URI: http://localhost
Feature: So far none to be seen.
*/
?>
<?
add_filter('the_content', 'rss_parse');
/*
RSS PARSE FUNCTION
Sample format for rss tag:
{rss uri=http://rss.groups.yahoo.com/phpexperts/rss count=5}
uri and how many feeds to show
param is content of post
returns none
*/
include './lastRSS.php';
function rss_parse($content)
{
$rss=new lastRSS();
$pattern="~{rss\s*uri=(.*)\s*limit=(.*)}~iU";
$matches = "";
preg_match_all($pattern, $content, $matches);
$rsses = 0;
while ($rsses<count($matches[0]))
{
$p_content="";
$uri=$matches[1][$rsses];
$count=$matches[2][$rsses];
if (empty($count)) $count=10;
$rss_content = $rss->Get($uri);
$items = $rss_content['items'];
$i = 0;
while ($i < $count)
{
$p_content .= "<div id='rss_item'><strong><a href='{$items[$i]['link']}'>".$items[$i]['title']."</a></strong><br/>";
$p_content .= "".$items[$i]['description']."</div><br/><br/>";
$i++;
}
$content = str_replace($matches[0][$rsses], $p_content, $content);
$rsses +=1;
}
return $content;
}
?>