Hacking widget.php for WordPress

I started playing with widgets a little more seriously since I found a fix for my XAMPP installation. On a lark I decided to try and use the builtin RSS widget. I didn’t get the results I expected. The feed I was planning on using is a single item RSS feed that does not have a link in the item element. It does have a guid with the correct http link. The content is in a content:encoded element. So the stuff is in the wrong place for this widget. The RSS widget wants a link element and the content in the description element. What I wanted was a display of the first item with a title linking back to the original website and its content with only the < a > and < br / > html tags allowed through.

So I started looking over the widget.php and the other supplied widgets. I ended up hacking the original RSS widget for my tests. Despite not knowing what I am doing I was able to modify the widget and get the required results pretty quickly. The hardest part was getting the strip_tags function to let the line break tag, < br / >, through as an allowed tag. I am using the optional “allowed tag” parameter with this function. I had to add the slash character(/) to get it to pass the line breaks through. Adding a space before the slash character like I normally would enter a line break caused the function to remove the line break.