WordPress Google Reader Widget

Number 3 in Widget-A-Day is a Google Reader widget.

This widget will display your latest shared stories. You can change the amount of stories to display and how to display them.

Download googlereader.zip

Default display:
googreader1cropped.png

Admin panel:
googreader2cropped.png

Download googlereader.zip

SVN Checkout
svn co http://svn.wp-plugins.org/google-reader-widget/trunk

Requirements

Installation

  1. Download googlereader.zip
  2. Extract and upload googlereader.php to the plugins/ directory
  3. Enable Google Reader in the Plugin admin panel
  4. In widget admin panel, place Google Reader in the sidebar, and edit it to enter your user id

Features

  • Displays your latest shared items from Google Reader
  • Completely customizable display
  • Caching for large traffic sites

User ID

In order to get your shares, you need to know your user id according to Google Reader. This can be found by going to the ‘Shared Items’ link, and copying the 20 digit number at the end of your shared items link.

So something like:
http://www.google.com/reader/shared/02774557510273097991
Where 02774557510273097991 would be my user id.

Formatting

There are 3 parts needed to format the output.

The first part, called items start in the admin panel, is the first part of the widget after the title. For the default formatting, this is just <ul>.

The second part, called items end, is the ending of the widget. By default, this is:
</ul>
<a href="%googlereader%" style="float:right;">Shared Items</a>

The third part is what is called for each item. By default, this is:
<li style="list-style-type: none;"><a href="%link%">%title%</a></li>

The premise of calling each value is this:

  1. start
  2. item
  3. item
  4. item
  5. end

The formatting for items is:

  • %link% – Link to the item
  • %title% – Title of the item
  • %site% – The title of the site the item is from
  • %sitelink% – The link to the site the item is from
  • %number% – The number of the current item
  • %comment% – The comment (note) made when sharing an item

The formatting for start and end is:

  • %googlereader% – Link to your Google Reader shared page
  • %count% – Number of items shown

Download googlereader.zip

162 Comments

  1. At the end of every link ‘/fromfeed’ is added so I alway direct people to a 404.

    My bad maybe, but I’m missing what I did wrong

  2. It’s probably because of an error in the script. On line 47, it should be $after_widget (Thanks Ryan). I had fixed it before, but it slipped back in. You can either change it or download it again and you shouldn’t have that problem. If you still do, it’s probably something else and I can look into it.

  3. Hey James,

    Thanks for that quick response, the solution however didn’t work. The ‘/formfeed’ is still around.

    If you could check the thing out in the wild on my site, don’t rush, I’m patient.

    Thanks again,

    Ger

  4. Hey James,

    No need to look further, problem solved. Shared one item from particular site, think this site adds ‘/fromfeed’ themselves.

    Won’t be shared any longer.

  5. I can’t get this to work for the life of me. The widget displays fine but no stories show up. I’ve double checked all the user variables, I’m running wordpress 2.5 and PHP 5, so I’m not sure what could be wrong.

  6. Can any of you give me a screenshot or just the values in your widget admin panel?

    If you don’t want to put it here, you can send it to j{at}meswilson.com

  7. Then that’s the problem. Earlier in the comments there is a way to make it work with curl instead of file_get_contents.

    I was planning on making it an option to use whichever, but haven’t yet gotten around to do it. Depending on what I’m doing tomorrow, I might do it then.

  8. ack, I’m on Dreamhost as well. I had no idea they disabled file_get_contents by default. I’d LOVE a version of this that uses cURL.

  9. Hi There:
    This widget looks promising. The problem is that I’m working with a 3-column theme that’s supposed to be widgetized. Whenever the widget is turned on and place, it totally replaces the sidebar with the widget and, thus, effectively rids of the other items on my sidebar.

    If I understand the theme that I’m working on, the two sidebars (right and left) start off “after the divs) with a class for each sidebar, yet the class names aren’t in the CSS itself.

    I’d love to use the widget, or at least be pointed to a similar plugin. Oh, I am using WP 2.5 on a production machine.

    Thanks; hope to hear from you,
    Velanche

  10. Weirdly, it seems that if the title for the box is too long, access to the admin panel is lost.

  11. If you want to use CURL on DH, replace:
    $stories = file_get_contents($uri);

    with
    $ch = curl_init();
    curl_setopt ($ch, CURLOPT_URL, $uri);
    curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 5);
    $stories = curl_exec($ch);
    curl_close($ch);

  12. Thanks Ben, that worked as expected. Of course, as I was editing the code, I happened to look in the README file and saw those exact instructions.

  13. I’ve just started using this widget a few days ago on my brand new WordPress blog. I’m in the process of moving my BlogSpot blog over, and had to find a replacement for the Google Shared Items. So far… it’s ok, but I’m having problems. It seems that when I share items, then go look at my blog to ensure they’re showing up – they’re not. I have to edit the widget, make a change (or I just discovered not even change anything), then click Change, and Save Changes, then when I refresh my blog the newly shared items appear. This is on WP 2.5.1. Anybody else seeing this, or have a clue how to fix it?

  14. @Brian, That’s probably because the results are cached (default 60 minutes or 3600 seconds). You can turn off caching by setting cache time to 0 or -1, which will request the shared items feed every page load. Or you can just lower it to something like 15 minutes or 900 seconds to have it update more frequently.

  15. Anybody know – how to display ALL latest stories from Google Reader, not only SHARED?

  16. @Schulte, updated. Only one tag is supported though. If you can have a multiple tags on the RSS feed, let me know.

  17. Pingback: Leonaut.com
  18. @Timmy, I did it wrong. I thought since I only changed a few lines, I couldn’t screw it up, so I didn’t test it.

    I fixed it. I tested it on a fresh install of 2.5.1, and it seemed to work. So you can upgrade to 1.7, and it should be good.

    If you aren’t going to use the tag functionality though, you can keep using 1.5. But I did find that since it had extra whitespace after the ?>, it caused an error after saving the widget configuration.

  19. Is there a way to have a clicked link open in another tab/window for this widget? I want to share my shared google items, but don’t want people to leave my page. Thanks.

  20. @chris, add target="_blank" after the href="..." in items end and item.

    So, something like <a href="%link%"> would become <a href="%link%" target="_blank">

  21. James, that did it. Thanks. For your consideration — how about adding support for multiple Google Reader Widgets (see Flexi Pages widget for an example)?

  22. This is a great plugin! I know it’s been a while since you’ve been making a widget a day, but widgets that showed delicious links and facebook posted items would be stellar. Keep up the good work.

  23. Hi,
    I am trying to make a dedicated page for my Google Reader shared items.

    Is it possible to insert this into a page, rather than into the sidebar?

    Thanks,
    Josh

  24. Hi. Thanks for this plugin! It’s great.

    My blog has multiple authors, so what I’d like to do is have your plugin running multiple times on the sidebar — once for my list, once for a co-blogger’s list, and again for a different co-blogger’s list (etc). But wordpress only gives me the option of putting it on the sidebar once. Is there any way around this, that you know of?

    Thanks!