Skip to content

Instantly share code, notes, and snippets.

@tomjn
Created January 21, 2014 16:43
Show Gist options
  • Save tomjn/8543481 to your computer and use it in GitHub Desktop.
Save tomjn/8543481 to your computer and use it in GitHub Desktop.
Mark Jaquith has a snippet of code at http://markjaquith.wordpress.com/2009/12/14/excluding-your-plugin-or-theme-from-update-checks/ however there is an edge case it misses, causing notices and warnings when wordpress.org cannot be reached. Happens more on local developer and QA environments rather than production but should still be fixed
<?php
/**
* Exclude from official repo update check.
*
* @link http://markjaquith.wordpress.com/2009/12/14/excluding-your-plugin-or-theme-from-update-checks/
*
* @param array $r
* @param string $url
* @return array
*/
public function http_request_args( $r, $url ) {
if ( 0 !== strpos( $url, 'http://api.wordpress.org/plugins/update-check' ) )
return $r; // Not a plugin update request. Bail immediately.
if ( $r['response']['code'] != 200 ) {
// this is a failed request! We cant modify the results if the results timed out/failed
return $r;
}
$plugins = unserialize( $r[ 'body' ][ 'plugins' ] );
unset( $plugins->plugins[plugin_basename( __FILE__ )] );
unset( $plugins->active[ array_search( plugin_basename( __FILE__ ), $plugins->active ) ] );
$r[ 'body' ][ 'plugins' ] = serialize( $plugins );
return $r;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment