7

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?

1
  • Hmm good question.. I don't know of a 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.
    – Tim Malone
    May 2, 2016 at 22:02

3 Answers 3

14

https://downloads.wordpress.org/plugin/{plugin-name}.latest-stable.zip

The structure should be the same for all WordPress.org plugins and the link you're looking for is:

https://downloads.wordpress.org/plugin/backupwordpress.latest-stable.zip.

You can see an example here on how this might be used.


To update plugins through WP-CLI:

wp plugin update backupwordpress
2
  • 2
    Nice and clean! I didn't know that a latest-stable link existed. This should be the answer.
    – Luis Sanz
    May 3, 2016 at 12:07
  • 1
    good to know, just tested other patterns like {slug}.latest.zip and {slug}.trunk.zip but that didn't work ;-)
    – birgire
    May 3, 2016 at 12:59
5

Sounds like what you are really after is wp-cli which will let you write shell script that automate such tasks.

2
  • I would also recommend this. Maybe you could add an example to extend the answer ;-)
    – birgire
    May 3, 2016 at 13:00
  • LOL @birgire, I leave the long answer to the heros of this site :) but maybe will updtae later if will not forget May 3, 2016 at 13:07
0

When you're doing a plugin update, in the process where it shows you all the steps, you can also see the plugin download url. Usually the last version can be always found there.

1
  • But what if you always just want to download the latest version by accessing a URL that never changes?
    – cpcdev
    May 2, 2016 at 23:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.