Skip to content

Instantly share code, notes, and snippets.

@jimboobrien
Forked from wpscholar/hidden-plugin.php
Created September 20, 2017 22:42
Show Gist options
  • Save jimboobrien/b5788da0724db1e76087abf149d977b6 to your computer and use it in GitHub Desktop.
Save jimboobrien/b5788da0724db1e76087abf149d977b6 to your computer and use it in GitHub Desktop.
<?php
/**
* Ensure that a specific plugin is never updated. This works by removing the
* plugin from the list of available updates.
*/
add_filter( 'http_request_args', function ( $response, $url ) {
if ( 0 === strpos( $url, 'https://api.wordpress.org/plugins/update-check' ) ) {
$basename = plugin_basename( __FILE__ );
$plugins = json_decode( $response['body']['plugins'] );
unset( $plugins->plugins->$basename );
unset( $plugins->active[ array_search( $basename, $plugins->active ) ] );
$response['body']['plugins'] = json_encode( $plugins );
}
return $response;
}, 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment