We help IT Professionals succeed at work.
Get Started

Problem building WordPress Plugin that uses lastRSS

Howard Bash
Howard Bash asked
on
1,302 Views
Last Modified: 2012-05-11
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

Comment
Watch Question
This problem has been solved!
Unlock 1 Answer and 18 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE