YOURL’s WordPress Plugin Update for 3.0

UPDATE: Thanks to Ozh’s Comments I have updated the post below. It sounds like the plugin will be updated for WP 3.0. However, it will then stop working with WP 2.9 and below. I am leaving this page up for those of you who wish to use an older version of WP but would still recommend updating to a newer release when one becomes available.

I’ve been using YOURLS to host my own shortlink site at for quite some time. I recently found the YOURL’s WordPress to Twitter Plugin. This plugin is great however the, get_shortlink function added to WP 3.0 as well as the latest version of Stats plugin caused some small usability issues. Such as the “Get Shortlink” button showing up twice.

My solution? Make it so when you click on the “Get Shortlink” button it gets the YOURLS shorlink instead of the one. This required the following changes that I’m hoping OZH will adopt or modify.

Remove the following from inc/options.php (Lines 427-428)

$('#edit-slug-box').append('<span id="<span class=">yourls-shorturl-button</span>"><a onclick="prompt(\'Short URL:\', \'<?php echo $shorturl; ?>\'); return false;" href="#">Get Short URL</a>');
 $('#yourls-shorturl-button a').css('border-color','#bbf');

Next add the following functions to either inc/core.php or plugin.php

//the following two functions are from Stats Plugin by Andy Skelton Thanks Andy
//shortlink url for WP <= 2.9
function wp_ozh_yourls_get_shortlink_html($html) {
 $url = wp_ozh_yourls_geturl($id);
 $html .= '<input id="YOURLS-shorturl" type="hidden" value="' . $url . '" /><a onclick="prompt('URL:', jQuery(\'#YOURLS-shorturl\').val()); return false;" href="#">' . __('Get Shortlink') . '</a>';
 return $html;


The final step is to modify the plugin.php file to change the renamed wpme functions and update for WP 3.0

// WP 2.9/3.0 & play nice together
add_action('plugins_loaded', 'wp_ozh_yourls_wpme' );
function wp_ozh_yourls_wpme() {
 if( ! function_exists('wp_get_shortlink') ) {
 // Remove these only for WP < 3.0.
 remove_action('wp_head', 'wpme_shortlink_wp_head');
 remove_action('wp', 'wpme_shortlink_header');
 //Add shortlink URL html
 add_filter( 'get_sample_permalink_html', 'wp_ozh_yourls_get_shortlink_html');
 } else {
 // Add a shortlink handler for WP >= 3.0.
 add_filter( 'get_shortlink', 'wp_ozh_yourls_raw_url');

That should do the trick and be backwards compatible!

WordPress Theme Exists and WP_THEME_DIR?

This is more of an open question than a fantastic discovery. One thing we want to do with WPBook is allow custom theme modification that won’t be overwritten by plugin upgrades. I’ve been looking into ways to check to see if a theme exists. If it does uses it if not use the default plugin theme from the plugin directory.

I know how to do a php check for “if file_exists” however, checking for all theme files seems a bit silly. What I’m wondering is if there is a way to check if the theme exists with at least a folder and index.php file.

Another thing I’ve been wondering, there is a WP_PLUGIN_DIR function but not WP_THEME_DIR function is there a workaround for this?

Any help on this issue would be great!

Earth Hour Your Website

Earth Hour is quickly approaching, this year’s date, March 27th at 8:30pm. Well the team at Brave New Code wrote a fantastic WordPress plugin that will turn your site “off” for earth hour. This is great if your site is ran by WordPress. My problem, only my blog is WordPress everything else is custom code.

My Solution was to modify their script to a simple php file. Basically it does the same thing as the plugin but outside of WordPress. The download also replaces your site with a message letting the user know that it’s Earth Hour.

You can download your copy of my script here.

Or get the original WordPress plugin here.


Don’t want my code just add this to your site’s header or wherever you want the earth hour to be displayed.

If you’re not in GMT set your offset with $GMT_offset.

You may also echo out $earth_hour_minutes for the amount of minutes left in Earth Hour.

// Basic time settings
$GMT_offset = "0";
$start_time = gmmktime( 20, 30, 0, 3, 27, 2010 );
$end_time = $start_time + 60*60;</pre>
// adjust for local time
 $adjusted_time = time() + $GMT_offset*60*60;
$in_earth_hour = ( $adjusted_time >= $start_time && $adjusted_time <= $end_time );
$earth_hour_minutes = ($end_time - $adjusted_time)/60;

if ($in_earth_hour){

    //Do this during earth hour
    die(); //stop the rest of your site from running

What the Hell Facebook?

UPDATE 3/18: This issue has now been resolved. You may go back to using this plugin as normal. Thanks Facebook.

As some of you may know I contribute to the development of Facebook CommentsTNG. This is a WordPress plugin that pulls comments from a Facebook note back into your self-hosted WordPress blog. This is extremely handy if you have your blog automatically pulled into your Facebook account as notes and want the comments left on those notes to be displayed on your public website.

This is all fine and dandy unless Facebook goes and breaks their mobile site, which is how the plugin gets the comments thus preventing the comments from being pulled in. At first I thought “oh they are Facebook they have good developers and I’m sure they are working on it.” Well, it’s been over a week now and it’s still broken. I’ve submitted a few bug reports myself and I know I’m not the only one. The main developer, Phil over at Philtopia also wrote a post explaining the problem and encouraging you to write a bug report.  And I am doing the same.

The problem is that the comments show up blank and display the date “December 31st 1969” which I believe is the default date if a date field isn’t being pulled properly. It looks something like this

So how do you go about writing a bug report?
Fill out the note bug report:
Fill out the mobile bug report:

Extending wp-lifestream to include DailyBooth

With almost 130,000 downloads and support for more than 50 sites it is safe to say that David Cramer’s wp-lifestream is the best WordPress Lifestream plugin out there. The idea of a lifestream is to bring all your data from the sites you visit to one place. The current version of this plugin doesn’t support DailyBooth one of my favorite photo publishing sites. So I took the challenge of writing the extension for it.

This lead me to loving the plugin even more. Extending the class was remarkably easy. However, for some of you who are less technically inclined or don’t want to go though the work of writing this class yourself I have packaged the DailyBooth extension here. Just download it and up place it in wp-content/lifestream/extensions and you should be good to go by adding your DailyBooth username under feeds.

Hope you find this extension useful.

%d bloggers like this: