Skip to content

Instantly share code, notes, and snippets.

@rundef
Created January 29, 2015 19:18
Show Gist options
  • Save rundef/9374eed44d5a56e0e2a8 to your computer and use it in GitHub Desktop.
Save rundef/9374eed44d5a56e0e2a8 to your computer and use it in GitHub Desktop.
add_filter('http_request_args', 'dm_prevent_update_check', 10, 2);
function dm_prevent_update_check( $r, $url ) {
if (strpos($url, 'http://api.wordpress.org/plugins/update-check/1.1/') === 0 || strpos($url, 'https://api.wordpress.org/plugins/update-check/1.1/') === 0) {
$my_plugin = plugin_basename(__FILE__);
$plugins = json_decode($r['body']['plugins'], true);
if(isset($plugins['plugins'][$my_plugin]))
unset($plugins['plugins'][$my_plugin]);
$k = array_search($my_plugin, $plugins['active']);
if($k !== FALSE)
unset($plugins['active'][$k]);
$r['body']['plugins'] = json_encode($plugins);
}
// older versions of wordpress
else if(strpos($url, 'http://api.wordpress.org/plugins/update-check/') === 0) {
$my_plugin = plugin_basename(__FILE__);
$plugins = unserialize($r['body']['plugins']);
unset($plugins->plugins[$my_plugin]);
unset($plugins->active[array_search($my_plugin, $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