Disable Theme Update Checks

All WordPress themes check for updates on WordPress.org, regardless of whether it was developed custom for a client or built by a commercial theme shop. This can be a problem if a new theme gets added to WordPress.org that has the same name as your custom or commercial theme.

There’s a couple ways to get around this issue.

Name Wisely

Themes hosted on WordPress.org are not allowed to use “Theme” or “WordPress” in their name. So, if you’re developing a theme for a client- you could call the theme “[Client Name] Theme”. This is the best option as it works in all cases.

Version High

WordPress.org checks are based on theme name and version. So, if your theme has a really high version number- it’s unlikely to find an update. You can also increase the version of a theme that is available on WordPress.org that you don’t want to see updates for.

However, this is not a silver bullet as some theme authors also use high version numbers, such as the date of their release, e.g. “20140101”.

Disable Updates With Code

There’s a way to disable automatic updates from your theme code- but this can also be problematic as it only works while the theme is active. If your client were to switch themes temporarily, they might see an update notice.

But here’s the code for that:

/**
 * Disable requests to wp.org repository for this theme.
 *
 * @since 1.0.0
 */
function prefix_disable_wporg_request( $r, $url ) {

	// If it's not a theme update request, bail.
	if ( 0 !== strpos( $url, 'https://api.wordpress.org/themes/update-check/1.1/' ) ) {
			return $r;
		}

		// Decode the JSON response
		$themes = json_decode( $r['body']['themes'] );

		// Remove the active parent and child themes from the check
		$parent = get_option( 'template' );
		$child = get_option( 'stylesheet' );
		unset( $themes->themes->$parent );
		unset( $themes->themes->$child );

		// Encode the updated JSON response
		$r['body']['themes'] = json_encode( $themes );

		return $r;
}
add_filter( 'http_request_args', array( $this, 'prefix_disable_wporg_request' ), 5, 2 );

Thanks to Jared Atchison for that snippet.

About Devin

I'm a WordPress developer based in Austin, Texas. Follow my projects on GitHub, or more general WordPress ramblings as @devinsays on twitter.

2 Responses

Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>