jon-b
4/6/2014 - 12:09 AM

Don't Update Plugin WordPress API 1.1

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 );