Skip to content

Instantly share code, notes, and snippets.

@bueltge
Last active January 31, 2019 17:53
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bueltge/5a3545ada7e68d367424 to your computer and use it in GitHub Desktop.
Save bueltge/5a3545ada7e68d367424 to your computer and use it in GitHub Desktop.
Prevent/Disable Automatic Theme Update Check for comment on WPSE
// More background
// @see http://wordpress.stackexchange.com/questions/102554
add_filter( 'http_request_args', 'fb_hidden_theme_12345', 5, 2 );
function fb_hidden_theme_12345( $r, $url ) {
if ( FALSE !== strpos( $url, 'https://api.wordpress.org/themes/update-check' ) )
return $r; // Not a theme update request. Bail immediately.
if ( isset( $r['body'] ) && isset( $r['body']['themes'] ) ) {
// get current (child)theme
$template = get_stylesheet();
// remove theme
$themes = json_decode( $r['body']['themes'] );
if ( $themes->active == $template )
unset( $themes->active );
unset( $themes->themes->$template );
$r['body']['themes'] = json_encode( $themes );
// remove translation
if ( isset( $r['body']['translations'] ) ) {
$translations = json_decode( $r['body']['translations'] );
unset( $translations->$template );
$r['body']['translations'] = json_encode( $translations );
}
}
return $r;
}
@bueltge
Copy link
Author

bueltge commented Jul 6, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment