Skip to content

Instantly share code, notes, and snippets.

@mustardBees
Created December 20, 2013 19:12
Show Gist options
  • Save mustardBees/8059840 to your computer and use it in GitHub Desktop.
Save mustardBees/8059840 to your computer and use it in GitHub Desktop.
WordPress snippet which prevents your plugin from being included in the list of plugins sent to WordPress.org to check for updates.
<?php
/**
* Don't update this plugin
*
* This prevents you from being prompted to update if there's a public plugin
* with the same name.
*
* @author Phil Wylie
* @link http://link.from.pw/1cFfcFZ
* @param array $r Request arguments
* @param string $url Request url
* @return array Request arguments
*/
function pw_hidden_plugin( $r, $url ) {
if ( 0 === strpos( $url, 'https://api.wordpress.org/plugins/update-check/1.1/' ) ) {
$plugins = json_decode( $r['body']['plugins'], true );
unset( $plugins['plugins'][plugin_basename( __FILE__ )] );
$r['body']['plugins'] = json_encode( $plugins );
}
return $r;
}
add_filter( 'http_request_args', 'pw_hidden_plugin', 5, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment