Skip to content

Instantly share code, notes, and snippets.

@nigelheap
Created May 19, 2017 14:31
Show Gist options
  • Save nigelheap/9b1f6415b4aea1c42f2532b31218b9e2 to your computer and use it in GitHub Desktop.
Save nigelheap/9b1f6415b4aea1c42f2532b31218b9e2 to your computer and use it in GitHub Desktop.
<?php
add_filter('http_request_args', function( $r, $url ) {
if ( 0 === strpos( $url, 'https://api.wordpress.org/plugins/update-check/1.1/' ) ) {
$blocked_plugins = array(
'plugin_name_1',
'plugin_name_2',
'plugin_name_3'
);
if (!empty($blocked_plugins)){
foreach ($blocked_plugins as $plugin){
$plugins = json_decode($r['body']['plugins'], true);
if (array_key_exists($plugin, $plugins['plugins'])){
unset($plugins['plugins'][$plugin]);
}
$r['body']['plugins'] = json_encode( $plugins );
}
}
}
return $r;
},10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment