Last active
January 31, 2019 17:53
-
-
Save bueltge/5a3545ada7e68d367424 to your computer and use it in GitHub Desktop.
Prevent/Disable Automatic Theme Update Check for comment on WPSE
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
// 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; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Source example for this comment on WPSE - http://wordpress.stackexchange.com/questions/102554/prevent-disable-automatic-update-check#comment220608_102575