Extending a widget with included PHP class
-
I’m pretty new to creating sidebar widgets and OOP programming in general so please excuse any ignorance you see. ??
So I have a widget that takes an RSS feed url, passes it to a class and ultimately spits out HTML. The class itself is in a second file that gets included. It works just fine if I put the code on, say, sidebar.php, but as soon as I put it in it’s own widget I get the following error:
Fatal error: Call to undefined method stdClass::addStory() in /THEPATH/wp-content/plugins/widgets/rss/rssreader.php on line 413
It’s a lot of code to paste in context here, but here’s the cut down version:
WIDGET
——–
include(‘rss/rssreader.php’);
$url = ‘myrssurl’;
$rss = new rssFeed($url);
$rss->parse();RSSREADER.PHP
————–
class rssFeed {
function parse() {
someFunction();
}function someFunction() {
$rss->addStory($story);
}I really appreciate any input.
Thanks
- The topic ‘Extending a widget with included PHP class’ is closed to new replies.