Skip to content

Instantly share code, notes, and snippets.

@grayayer
Created October 10, 2016 22:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save grayayer/fc52837a75cedc1b0c517d3f9d945808 to your computer and use it in GitHub Desktop.
Save grayayer/fc52837a75cedc1b0c517d3f9d945808 to your computer and use it in GitHub Desktop.
Disable a plugin's check for updates - useful when you've modified the plugin directly (don't do that though)
add_filter( 'http_request_args', 'dm_prevent_update_check', 10, 2 );
function dm_prevent_update_check( $r, $url ) {
if ( 0 === strpos( $url, 'http://api.wordpress.org/plugins/update-check/' ) ) {
$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;
}
@grayayer
Copy link
Author

make sure that you don't use a numeral in a function name, especially to start it. It will break the site, making your boss unhappy.

@grayayer
Copy link
Author

you can also drop in code like this to the plugin's main file:

add_filter('site_transient_update_plugins', 'dd_remove_update_nag'); function dd_remove_update_nag($value) { unset($value->response[ plugin_basename(__FILE__) ]); return $value; }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment