Added My Bookmarks

I added my recent 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:


Plugin Name:
Plugin URI:
Description: Fetches your <a href=""></a> bookmarks list using the standard HTML method.
Provides one function, delicious().
Author: Phil Ulrich
Author URI:
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/';
    if (file_exists($cache)
        && false !== ($mtime = filemtime($cache) )
        && (mktime() - $mtime) < 3600) {
        echo file_get_contents($cache);
    $queryString = "";
    $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);
    echo $data;

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