I use the following code in my PHP script to automatically download the latest version of WordPress...
$wordpress_zip_file_url = 'https://wordpress.org/latest.zip';
file_put_contents("wordpress.zip", file_get_contents($wordpress_zip_file_url));
Does this work for plugins the same way? For example, I'd like to automatically download the latest backupwordpress plugin version --> https://wordpress.org/plugins/backupwordpress/
Is there a generic link to download the latest version of a plugin?
latest.zip
option for plugins and can't immediately see one; you might need to hook into the Wordpress plugin management system to grab the URL. It'll be possible, but you might need to trawl through how core does it to work it out.