soderlind.no

I code for fun

delicious tagroll for WordPress

| 9 Comments

The Delicious tagroll for WordPress plugin adds a new shortcode to WordPress, the the shortcode shortcode. The shortcode creates a tag cloud or a list of tags (see parameters below).


Demo: http://soderlind.no/bookmarks/

Plugin: You’ll find the plugin at http://wordpress.org/extend/plugins/delicious-tagroll-shortcode/

Installation: Download the plugin and save it in wp-content/plugins (remember to activate in Plugins) or wp-content/mu-plugins or install it from inside WordPress in Plugins->Add New (search for “delicious tagroll”)

Usage: Add the shortcode to a Page. The shortcode supports the following parameters:

  • Mandatory:
    • username=”delicious username” (if you forget it, my tagroll is displayed instead ;) )
  • Optional:
    • title=”tagroll title” (default =”My Delicious Tags”, use ” ” if you don’t want a tagroll title)
    • count=”number of tags” (default=”100″)
    • sort=”alpha or freq” (default = “alpha”)
    • showcounts=”true or false” (default = “false”, show tag counts)
    • mincount (default mincount=”10″), eg. show only tags with 10 or more links
    • minfont=”12″
    • maxfont=”35″
    • tags (default empty), eg. used to filter which tags you’d like to display eg. tags=”javascript,jquery,nodejs

Change log

v 2.1.2

  • Bugfix, you need this one if you are running a version less than PHP 5.3, since $xml->channel->item->count() is only supported in PHP 5.3 and newer.
    function ps_delicious_tagroll_get_tags($username = 'soderlind',$count = 10){
    
    	$key = 'delicious_tagroll_' . $username;
    
    	$feed_url = sprintf("http://feeds.delicious.com/v2/rss/tags/%s?count=%s",$username,$count);
    
    	$rs = get_transient($key);									// read "cache"
    	if ($rs != false) return $rs;
    
    	$data  = wp_remote_get($feed_url.'');
    	if (is_wp_error($data)) {
    		return (array)get_option($key); 						// retrieve fallback
    	} else {
    		$body = wp_remote_retrieve_body($data);
    		$xml = new SimpleXMLElement($body);
    		$rs = json_decode(json_encode($xml->channel),TRUE);	// convert xml object to array
    		if (count($rs['item']) > 0) {
    			set_transient($key, $rs, 60*60);					//expire after 1 hour
    			update_option($key, $rs); 							//fallback storage
    		} else {
    			$rs = (array)get_option($key); 						// retrieve fallback
    		}
    		return $rs;
    	}
    }
    

v 2.1.1

  • Replaced LastRSS with WordPress built in methods and set/get transient for caching:
    function ps_delicious_tagroll_get_tags($username = 'soderlind',$count = 10){
    
    	$key = 'delicious_tagroll_' . $username;
    
    	$feed_url = sprintf("http://feeds.delicious.com/v2/rss/tags/%s?count=%s",$username,$count);
    
    	$rs = get_transient($key);									// read cache
    	if ($rs != false) return $rs;
    
    	$data  = wp_remote_get($feed_url.'');
    	if (is_wp_error($data)) {
    		return (array)get_option($key); 						// retrieve fallback
    	} else {
    		$body = wp_remote_retrieve_body($data);
    
    		$xml = new SimpleXMLElement($body);
    
    		if ($xml->channel->item->count() > 0) {
    			$rs = json_decode(json_encode($xml->channel),TRUE);	// convert xml object to array
    			set_transient($key, $rs, 60*60);					//save cache, expire after 1 hour
    			update_option($key, $rs); 							//save fallback
    		} else {
    			$rs = (array)get_option($key); 						// retrieve fallback
    		}
    		return $rs;
    	}
    }
    
  • Added a new optional attribute:
    • tags (default empty), used to filter which tags you’d like to display eg. tags=”javascript,jquery,nodejs”

v 2.0

  • Delicious removed their JavaScript feed so I had to do a total rewrite
    • Creates the tag cloud server-side (good for SEO) and lets you change the look and feel using the included style sheet.
    • Uses the Delicious RSS feed API
    • Caches the feed for one hour. Delicious might block you if you access their feed API too often.
  • Some attributes are removed from the shortcode (you can change these using the ps_delicious_tagroll.css style sheet in the plugin directory):
    • mincolor
    • maxcolor
    • flow
  • Also removed the attributes
    • showname
    • showadd
    • icon
  • Added a new attribute:
    • mincount (default mincount=”10″), eg. show only tags with 10 or more links

v 1.1

  • changed parameter name=”true” to showname=”true”
  • added missing parameter showcounts=”false”

v 1.0

  • initial release

9 Comments

  1. Any way to point it to a different stylesheet?

  2. Is it just me, or did this plug in (and the underlying javascript and/or API from delicious) stop working recently?

  3. Great job :o j

    Is it possible to add a selection of some tags from my Delicious account?

Click on a tab to select how you'd like to leave your comment

Leave a Reply

Required fields are marked *.

*