Created
January 21, 2014 16:43
-
-
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
This file contains hidden or 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 | |
/** | |
* 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