Fix for Tweet This plugin used with WordPress 3.2

As always when an updated version of some kind of software comes out, I updated the software.

Today, I updated this WordPress site, using the WordPress autoupdater feature.

Immediately after updating the site, the following error was shown:

The system is trying to load the file /wp-includes/class-json.php, but the file doesn’t exist.

The class-json.php file contains functions for encoding and decoding json in PHP. WordPress 3.2 requires at least PHP 5.2.4, where encoding and decoding functions are built-in.

The fix is as follows:

Open up the file /wp-includes/plugins/tweet-this/tweet-this.php

Find the following lines:

if(!class_exists('Services_JSON')) {
	if(version_compare($GLOBALS['wp_version'], '2.9', '<'))
		require_once(TT_JSON);
	else require_once(TT_WP_JSON);}

and replace with

if(!class_exists('Services_JSON')) {
	if(version_compare($GLOBALS['wp_version'], '2.9', '<') || version_compare($GLOBALS['wp_version'], '3.2', '>='))
		require_once(TT_JSON);
	else require_once(TT_WP_JSON);}

Save and close the file, and the plugin (and site) works again.

If you find this useful – please leave a comment!

Edit: An updated version of Tweet This is now available on the website. Thanks to Richard for getting the bug fixed! :)

Post to Twitter