Last active
August 29, 2015 13:55
-
-
Save wpsmith/8787298 to your computer and use it in GitHub Desktop.
PHP: Prevent Theme from Updating
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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