Skip to content

Instantly share code, notes, and snippets.

@wpsmith
Last active August 29, 2015 13:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wpsmith/8787298 to your computer and use it in GitHub Desktop.
Save wpsmith/8787298 to your computer and use it in GitHub Desktop.
PHP: Prevent Theme from Updating
<?php
add_filter( 'http_request_args', 'gs_prevent_theme_update', 5, 2 );
/**
* Don't update theme from .org repo.
*
* If there is a theme in the repo with the same name,
* this prevents WP from prompting an update. Future proofs themes.
*
* @since 1.1.0
*
* @author Mark Jaquith
* @author Travis Smith
* @link http://markjaquith.wordpress.com/2009/12/14/excluding-your-plugin-or-theme-from-update-checks/
*/
function gs_prevent_theme_update( $r, $url ) {
if ( 0 !== strpos( $url, 'http://api.wordpress.org/themes/update-check' ) ) {
// Not a theme update request. Bail immediately.
return $r;
}
$themes = unserialize( preg_replace( '!s:(\d+):"(.*?)";!e', "'s:'.strlen('$2').':\"$2\";'", $r['body']['themes'] ) );
unset( $themes[ get_option( 'template' ) ] );
unset( $themes[ get_option( 'stylesheet' ) ] );
$r['body']['themes'] = serialize( $themes );
return $r;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment