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 am a developer based in Austin, Texas. I run a little theme shop called DevPress and help manage a WooCommerce shop with Universal Yums. Find me on twitter @devinsays.

4 Responses

  1. nancy

    just fyi, because I got burned on this, it’s not the theme name in your stylesheet but the Directory name that seems to matter. My theme name was different, but the directory name was the same, and WP auto updated it.

  2. Something else may have changed since this time this code was working well: I added it to a functions.php and got a long string of notices and warnings, many relating to wp-includes/class-http.php

    Haven’t looked into it in any detail, but my wild guess is that WP Core has loaded more into the update check.

Leave a Reply to ashraf Cancel reply