More often then we would like to admit, we are unwilling or unable to submit our WordPress plugins back to the repository for everyone to use. But how do you exclude your plugin from WordPress updates? As usual, the answer is with filters. Check out the code below to see how.
1 2 3 4 5 6 7 8 9 10 11 | function exclude_my_plugin( $r, $url ) { if ( 0 !== strpos( $url, 'http://api.wordpress.org/plugins/update-check' ) ) 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; } add_filter( 'http_request_args', 'exclude_my_plugin', 5, 2); |
Attribute: This code is originally from a lead WordPress Developer, Mark Jaquith (thanks Mark!)
But how does this exclude your plugin from the update? First, it takes the HTTP Request args and unserializes the [‘body’][‘plugins’] part of it. From there, it’s as simple as unsetting your plugin from the array, then re-serializing the request args. Also the first part checks to see if this is actually and update check. If it’s not, you exit the function.
2 replies on “How to Exclude WordPress Plugins From Updates”
[…] This post was mentioned on Twitter by Eddi Hughes, Re-CycledAir. Re-CycledAir said: How to Exclude WordPress Plugins From Updates – http://fwds.me/2l […]
[…] more from the original source: How To Exclude WordPress Plugins From Updates Posted in WordPress, WordPress Plugins Tags: php, plugins, post, post-explains, private, […]