Skip to content

Instantly share code, notes, and snippets.

@thefuxia
Created April 7, 2013 15:28
Show Gist options
  • Save thefuxia/5330923 to your computer and use it in GitHub Desktop.
Save thefuxia/5330923 to your computer and use it in GitHub Desktop.
Stop Plugin Upgrade Notices
<?php # -*- coding: utf-8 -*-
/*
* Place the following code in the main plugin file (the one with the plugin
* headers) to stop upgrade notices for this plugin.
*/
if ( ! function_exists( 't5_no_upgrade_check' ) )
{
add_filter( 'http_request_args', 't5_no_upgrade_check', 5, 2 );
/**
* Blocks update checks for this plugin.
*
* @author Mark Jaquith http://markjaquith.wordpress.com
* @link http://wp.me/p56-65
* @param array $r
* @param string $url
* @return array
*/
function t5_no_upgrade_check( $r, $url )
{
// Not a plugin update request. Bail immediately.
if ( 0 !== strpos( $url, 'http://api.wordpress.org/plugins/update-check' ) )
return $r;
$plugins = unserialize( $r['body']['plugins'] );
$p_base = plugin_basename( __FILE__ );
unset (
$plugins->plugins[$p_base],
$plugins->active[array_search( $p_base, $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