bueltge
7/6/2014 - 12:22 PM

Prevent/Disable Automatic Theme Update Check for comment on WPSE

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;
}