Created
October 10, 2016 22:59
-
-
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)
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
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; | |
} |
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
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.