Prevent Theme from Update

Recently there was a question on wrong theme update on WordPress support forums , he had a custom theme developed for his site , but when he updated the theme which is a different theme but same , his site got collapsed.

Points to note for theme developers:

  • First of all don’t use a generic name for custom themes.
  • Use a unique name like for example site’s address (cloudspier.com)
  • Bump theme version to very large number if you do want to use a generic name.

Otherwise use the following snippet.

[php]
/**
* Don’t Update Theme
* If there is a theme in the repo with the same name,
* this prevents WP from prompting an update.
*/

function spi_dont_update_theme( $r, $url ) {
if ( 0 !== strpos( $url, ‘http://api.wordpress.org/themes/update-check’ ) )
return $r; // Not a theme update request. Bail immediately.
$themes = unserialize( $r[‘body’][‘themes’] );
unset( $themes[ get_option( ‘template’ ) ] );
unset( $themes[ get_option( ‘stylesheet’ ) ] );
$r[‘body’][‘themes’] = serialize( $themes );
return $r;
}
add_filter( ‘http_request_args’, ‘spi_dont_update_theme’, 5, 2 );

[/php]

Put the above code in the theme’s functions.php. This only checks for active theme updates since you have placed this code in functions.php.

Ref: Update Checks