Avatar of Howard Bash
Howard Bash
Flag for United States of America

asked on 

Problem building WordPress Plugin that uses lastRSS

I have been going through a tutorial and built a plugin for WordPress that uses lastRSS.  When I activate it.  It displays some of the code on the top left corner of the dashboard.

I will attach the code that uses lastRSS for review.  I'm not clear how to go about debugging it.

<?
/*
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;
 
}

?>

Open in new window

WordPressPHP

Avatar of undefined
Last Comment
Howard Bash

8/22/2022 - Mon