Skip to content

Instantly share code, notes, and snippets.

@jb510
Created April 6, 2014 00:09
Show Gist options
  • Save jb510/9999718 to your computer and use it in GitHub Desktop.
Save jb510/9999718 to your computer and use it in GitHub Desktop.
Don't Update Plugin WordPress API 1.1
/**
* Dont Update the Plugin
* If there is a plugin in the repo with the same name, this prevents WP from prompting an update.
*
* @since 1.0.0
* @author Jon Brown
* @param array $r Existing request arguments
* @param string $url Request URL
* @return array Amended request arguments
*/
function jb_dont_update_plugin( $r, $url ) {
if ( 0 !== strpos( $url, 'https://api.wordpress.org/plugins/update-check/1.1/' ) )
return $r; // Not a plugin update request. Bail immediately.
$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', 'jb_dont_update_plugin', 5, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment