WordPress 3.0 Released

Happy Thursday and just to make your day a little better WordPress 3.0 “Thelonious”, named in honor of Thelonious Monk, has been released. You can easily upgrade from your dashboard by going to Tools > Upgrade or from the update message at the top of the dashboard.

The single most important feature of WordPress 3.0 is the WPMU merge which allows you to easily manage a network of sites (blogs) on a single WordPress install. You can find the instructions for enabling multisite here.

The WordPress 3.0 development cycle included over 1200 tickets (bugs and enhancements).

You can download WordPress 3.0 here and read the official release announcement on the WordPress Development Blog.

Prevent Update Checks for a WordPress Plugin

Earlier today, Jason Gegere asked me how to prevent WordPress from checking for updates on a plugin. This may be helpful if you are running a custom version of a plugin from the repository and you don’t want to accidently update the plugin and lose the customizations, or if you are running a private plugin and don’t want WordPress to check for updates from the plugin repository. WordPress doesn’t know if your plugin is in the WordPress plugins repository and it will request the update check on all installed plugins.

WordPress checks for updates using wp_update_plugins() in wp-includes/update.php but there are no hooks in this function which could be used to exclude your plugin from the update check. However, you can hook into http_request_args and remove your plugin from the query arguments passed in the http request. You can add the following code to your plugin to prevent WordPress from checking for updates for your plugin:

add_filter( 'http_request_args', 'dm_prevent_update_check', 10, 2 );
function dm_prevent_update_check( $r, $url ) {
	if ( 0 === strpos( $url, 'http://api.wordpress.org/plugins/update-check/' ) ) {
		$my_plugin = plugin_basename( __FILE__ );
		$plugins = unserialize( $r['body']['plugins'] );
		unset( $plugins->plugins[$my_plugin] );
		unset( $plugins->active[array_search( $my_plugin, $plugins->active )] );
		$r['body']['plugins'] = serialize( $plugins );
	}
	return $r;
}

How to Tweak the WordPress Generator Meta Tag

WordPress adds a generator meta tag to the head element of every page that includes the version of WordPress you are using. Many people have debated the need for this and recommend removing it especially if you haven’t been upgrading WordPress regularly. A crawler can easily scan this info and look for sites that are running an older version of WordPress with a known exploit. You can add the following code to your theme’s function.php file or in a plugin.

Tweak the WordPress Generator Meta Tag

The following code will remove the version number from the meta tag:

function devmnd_tweak_generator( $generator ) {
        return str_replace( ' ' . get_bloginfo( 'version' ), '', $generator );
}
add_filter( 'the_generator', 'devmnd_tweak_generator' );

Before: <meta name="generator" content="WordPress 3.0-RC1-15112" />
After: <meta name="generator" content="WordPress" />

You can even add your own custom version number in the generator meta tag:

return str_replace( get_bloginfo( 'version' ), '4.0', $generator );

Remove the WordPress Generator Meta Tag:

if ( function_exists( 'wp_generator' ) ) {
        remove_action( 'wp_head', 'wp_generator' );
}