KB Plugins

The best Wordpress plugins are free

Print this post

KB Advanced RSS Widget

The KB Advanced RSS widget is done. Read about it here.

17 comments »

1
par7133 says
at 4:35 pm on June 23, 2007 #

prob with wordpress 2.2.1, no data are displayed

2
BadAReviews adds
at 2:45 pm on July 24, 2007 #

Adam, something doesn’t seem quiet right. I’m running 2.2.1 and it installs everything fine. I actually send it a category feed so that on my sidebar it shows the latest posts of the a category I have going.

But then that’s it. It doesn’t update itself! I can post all the posts I want in that new category feed, and the system doesn’t seem update the listing.

Is there a delay in updating the feed? And if so, how long, and for debugging purposes, is there anyway to shorting this time?

Other then that, if there is no delay, then it’s just not working, which is strange. Help, and thanks!

3
BadAReviews adds
at 2:51 pm on July 24, 2007 #


To keep page loads quick, the widget stores a copy of the feed in cache. Only when the cache is more than 1 hour old will the widget update. You can change this. Search the widget file for “3600″ and change it to the number of seconds that you want it to cache. (3600 seconds is 1 hour).

- Adam (May 23, 2007, 5:58 pm) » Permalink

DOH! Nevermind. Thank you!

4
Thus saith Adam
at 2:52 pm on July 24, 2007 #

Caching defaults to 1 hour, but it’s buggy in the newest versions of WP. Wordpress’s built-in RSS parser has a 1-hour cache. In earlier versions of WP, this cache was buggy and would sometimes not update at all. I built a workaround into the widget. Search the widget file for “3600″ to see the bit where I flush the RSS cache if it’s more than 1 hour old. But this workaround has problems with the newest versions of WP. I still need to work on it, but am swamped with my real work right now.

5
Thus saith Adam
at 2:52 pm on July 24, 2007 #

Looks like you posted while I was writing my response… So now I guess you have it twice.

6
brandon contributes
at 1:39 am on December 4, 2007 #

Awesome plugin :-D just what i needed. I need to be able to use this and it goes away when there isnt a feed.
Think Emergency weather broadcast. I want it to pop up with flashing lights when there is an bad storm alert and go away when there isnt one.
Is there a way to do this? right now it will just say no current feeds.
thanks

7
Thus saith Adam
at 9:13 am on December 4, 2007 #

Brandon:

Search the code for this:

echo $before_widget;
if ( '' != $title )
	print($before_title . $title . $after_title);
echo $output_begin;

That’s where the widget starts printing output to your page. If you don’t want it to print anything when the feed is empty, then just before that block of code, try pasting in this:

if ( !is_array( $rss->items ) )
   return;

That should do the trick.

8
brandon contributes
at 9:36 am on December 4, 2007 #

Thanks for the quick response. I believe this will work. However. the feed is actually i guess pumping out “There are no active watches, warnings or advisories in Pennsylvania (Montgomery/PAZ068)”

so what i want to do is when That particular text shows up in the feed, it widget doesnt come up. (sorry im horrible at php, it just wont sink in)
Thanks again!

9
Thus saith Adam
at 9:40 am on December 4, 2007 #

Ahh. Then you just need to check whether that’s what the message says. Then instead of this

if ( !is_array( $rss->items ) )
   return;

… which checks whether the feed is empty, you want something like this:

// first check whether the feed is empty
if ( !is_array( $rss->items ) )
   return;
// then check whether the feed contains the message to ignore
$ignore = 'There are no active watches, warnings or advisories';
if ( false!==strpos($rss->items[0], $ignore) )
   return;
10
brandon thinks
at 9:53 am on December 4, 2007 #

[moderated: Released from Akismet queue]

your damn quick man! awesome. okay i inserted the code. and nothing. well its still there. :(.
am i doing it right? Once again Thank you so much!

if ( '' != $icon )
			$title = "<a class='kbrsswidget' href='$url' title='Winter Weather ALERT!'><img width='50' height='50' src='$icon' alt='RSS' /></a> $title";
		/* else
			$title = "$title"; */

// first check whether the feed is empty
                        if ( !is_array( $rss->items ) )
                        return;

// then check whether the feed contains the message to ignore
                        $ignore = 'There are no active watches, warnings or advisories';
                        if ( false!==strpos($rss->items[0], $ignore) )
   return;

			echo $before_widget;
			if ( '' != $title )
				print($before_title . $title . $after_title);
			echo $output_begin;
11
brandon comments
at 10:00 am on December 4, 2007 #

hrmm. my comment seems to have gotten lost. I did everything as you said. and its still coming up :(

if ( '' != $icon )
			$title = "<a class='kbrsswidget' href='$url' title='Winter Weather ALERT!'><img width='50' height='50' src='$icon' alt='RSS' /></a> $title";
		/* else
			$title = "$title"; */
                        if ( !is_array( $rss->items ) )
                        return;
// then check whether the feed contains the message to ignore
                        $ignore = 'There are no active watches, warnings or advisories in Pennsylvania';
                        if ( false!==strpos($rss->items[0], $ignore) )
   return;
			echo $before_widget;
			if ( '' != $title )
				print($before_title . $title . $after_title);
			echo $output_begin;
12
brandon opines
at 10:08 am on December 4, 2007 #

okay i see whats happening. the rss doesnt have anything for that location so i just comes up with “‘There are no active watches, warnings or advisories in montgomery county” etc. but the rss is full of stuff.. so i dont think this is going to be easy :(

reference: [link]

13
Thus saith Adam
at 10:22 am on December 4, 2007 #

I’m a little confused. When I look at that feed, I don’t see the text “there are no active watches” anywhere in it, so I’m not sure where that message is coming from if not from the feed. Is that the exact URL you’re using?

14
brandon says
at 10:28 am on December 4, 2007 #

ha no its not. In the widget this is the rss url:

[link]

sorry

15
Thus saith Adam
at 10:36 am on December 4, 2007 #

Ahh. My bad. My little piece of code doesn’t specify which part of the feed it’s checking. Change the code I gave above to this so that it’s checking against the title:

// first check whether the feed is empty
if ( !is_array( $rss->items ) )
   return;
// then check whether the feed contains the message to ignore
$ignore = 'There are no active watches, warnings or advisories';
if ( false!==strpos($rss->items[0]['title'], $ignore) )
   return;

By the way, the $ignore thing only needs to be a substring of the title. I noticed in the code you pasted that you added on the “in Pennsylvania” stuff. It won’t hurt, but it’s not necessary.

16
brandon contributes
at 10:52 am on December 4, 2007 #

awesome thank you.

17
brandon contributes
at 10:56 am on December 4, 2007 #

it works :-D

Leave a comment

Comment Guidelines
  • Yes, your comments will be visible to everybody. (Unless you use the private contact form.)
  • Allowed HTML: <a> <b> <blockquote> <cite> <code> <em> <i> <strong>
  • Code: Put code in `backticks` (above your "Tab" key) or it won't display well
  • Gravatars: To override the default image by your comment, use a gravatar
  • Links: If you include more than one link, your comment will go into the spam queue

Please read before commenting: Because my real job has me swamped at the moment, I am not supporting my plugins at this time. Sorry. This may last several weeks.

If you have a bug report, feature request, or other general feedback about a plugin, please leave a comment—but do not expect an immediate response. If you are requesting help, though, please check the plugin's documentation thoroughly rather than ask your question as a comment.

Thank you for your understanding.