Twitter Shortcode

Here’s a shortcode I made recently for a WordPress site. It stores the retrieved data as a transient, minimizing HTTP requests and subsequently reducing page load times for users. Feel free to use it. Post any comments if you want clarification.

// Twitter Feed
add_shortcode( 'twitter', 'rl_twitter_feed' );
function rl_twitter_feed( $atts ) {
	
	// Attributes
	if( isset( $atts['handle'] ) )
		$handle = $atts['handle'];
		
	// Check transients
	$body = get_transient( 'rl_twitter_data' );	
	if( empty( $body ) ) {
		$twitter_url = 'http://twitter.com/statuses/user_timeline/' . $handle . '.json?count=3';	
		$data = wp_remote_get( $twitter_url );
		$body = wp_remote_retrieve_body( $data );
		
		if( empty( $body ) )
			return false;
		
		$body = json_decode( $body, true );
		set_transient( 'rl_twitter_data', $body, 300 );
	}
	
	//Begin Output
	$output = '<aside class="twitter-feed"><ul>';

	// Work with decoded data
	foreach( $body as $tweet ) {
		$output .= '<li>';
		$output .= '<p><span class="twitter-meta"><time datetime="' . date( 'Y-m-d', strtotime( $tweet['created_at'] ) ) . '">' . date( 'd F, Y', strtotime( $tweet['created_at'] ) ) . '</time>';
		$output .= ' - <a href="http://twitter.com/' . $tweet['user']['screen_name'] . '">@' . $tweet['user']['screen_name'] . '</a></span>';
		$output .= $tweet['text'];
		$output .= '<span class="twitter-source">Via ' . $tweet['source'] . '</span>';	
		$output .= '</p></li>';
	}
	$output .= '</ul></aside>';
	
	return $output;
}

Show Me My Opponent

I’ve been listening to D.Veloped’s Work: Party mixtape… and this. DIFF is 1:18:56 of non-stop fun. My favourite section is around 54:22, “Big Stuntin'”. It’s awesome.

The best thing about long mashups like this is I can just go to town on a problem. If I haven’t solved it by the time the song is over, then I suck and should just quit. This has yet to fail.

If You Only Knew The Power Of the Dark-Side

This song is amazing. Tim sent me the link to it when I was in Vancouver last-week. It’s a dubstep remix of ‘Binary Sun’ – the Jedi theme from the Star Wars movies. There are three voice samples that are absolutely amazing. The last one, right after the bridge is Vader.

I’d be lying if I said that I haven’t listened to it a hundred times by now.

Work: Party

Here’s what I’m listening to while building the new site. It took me a couple listens, but now I’m really digging it. The lead in from The Childish Games to Fly Like An Eagle is amazing.

Time keeps on slippin’ slippin’ slippin’ into the future

Norwegian Recycling – Don’t Stop Believing

Don’t Stop Believin by Norwegian Recycling is today’s awesome Mashup. Get after it!

On this track:

1. Journey – Dont Stop Believin’
2. Shakira – Waka Waka (This Time for Africa)
3. Brintey Spears – Till the World Ends
4. Robyn – Dancing On My Own
5. Bruno Mars – Just The Way You Are
6. Tim Berg – Seek Bromance

Norwegian Recycling – Kiss

Beauty Queen of only 18…

I mean they’re all kinda corny, but you’ve gotta respect the ability to throw them together. I think Norwegian Recycling might be my new favourite mashup artist!!!

Samples on Kiss

1. Sixpence None The Richer – Kiss Me
2. Bruno Mars – Just The Way You Are
3. Maroon 5 – She Will Be Loved
4. Savage Garden – Crash And Burn
5. Jason Derulo – In My Head
6. Jason Derulo – What If

Add Google+ Button to WordPress Blog

Sounds like it’s probably pretty easy doesn’t it? To Add Google+ Button to your WordPress Blog, simply follow this lil link and the instructions from our bros at The NextWeb and you’ll be all set.

Hmmm maybe we should think about getting one of these bad boys?

TheNextWeb.com/Google+