Added My Del.icio.us Bookmarks

I added my recent del.icio.us bookmarks to this blog under the calendar in the side bar. I googled for the basic plugin, and tweaked it a bit to suit how I wanted to use it.

The plugin looks like:

<?php

/*
Plugin Name: del.icio.us
Plugin URI: http://del.icio.us/
Description: Fetches your <a href="http://del.icio.us/">del.icio.us</a> bookmarks list using the standard HTML method.
Provides one function, delicious().
Author: Phil Ulrich
Author URI: http://interalia.org/
*/
function delicious($username='sweatje', $count=10, $extended="Bookmarks",
 $divclass="link", $aclass="storytitle", $tags="yes", $tagclass="meta", 
 $tagsep="/", $tagsepclass="delTagSep", $bullet="raquo",
 $rssbutton="yes", $extendeddiv="no", $extendedclass="")
{
    $cache = 'cache/del.icio.us';
    if (file_exists($cache)
        && false !== ($mtime = filemtime($cache) )
        && (mktime() - $mtime) < 3600) {
        echo file_get_contents($cache);
        return;
    }
    $queryString = "http://del.icio.us/html/";
    $queryString .= "$username/";
    $queryString .= "?count=$count";
    $queryString .= "&extended=$extended";
    $queryString .= "&divclass=$divclass";
    $queryString .= "&aclass=$aclass";
    $queryString .= "&tags=$tags";
    $queryString .= "&tagclass=$tagclass";
    $queryString .= "&tagsep=$tagsep";
    $queryString .= "&tagsepclass=$tagsepclass";
    $queryString .= "&bullet=$bullet";
    $queryString .= "&rssbutton=$rssbutton";
    $queryString .= "&extendeddiv=$extendeddiv";
    $queryString .= "&extendedclass=$extendedclass";

    $html = implode(' ', file($queryString));
    $data = str_replace(array('<div class="link">',''),array('<li>','</li>'),$html);
    // php5 only file_put_contents($cache, $data);
    $fh = fopen($cache, 'w');
    fwrite($fh, $data);
    fclose($fh);
    echo $data;
}
</>
?>

Update: Per the comment from Darren, I added caching. I was on me “TODO” list, but you know how those go 😉