Programatically download a plugin

I'd like to programmatically download a plugin from the WordPress official repo, using a link/id/whatever identifier token.

How could this be achieved?

Topic get-plugin-data php plugin-development plugins Wordpress

Category Web


PHP has a de-facto standard package manager called Composer. This does not only download packages (themes, plugins, the core) for you, but also solves dependency conflicts in case two of your dependencies/ packages request the same sub-package (de-duplication) and maybe even in different versions.

There's the WordPress specific extension called WP Starter that does all the heavy lifting for you in this case. I'd recommend to go with that.

If that is too much for you, you can build a monorepo and use version control systems like SVN, Git, mercurial and others to download content and later on even update those packages. Be aware that while VCS are capable of managing packages, they are not meant to do so (even with their extensions). Better use the right tool for the job and use a dedicated package manager or above mentioned abstraction/ simplification/ empowerification that is specific to Wordpress.


WP CLI is best tool out there to manage plugins/ themes through command line, instead of uploading plugins through FTP or admin panel.

Once you Install WP-CLI on your machine then run below command and see magic.

wp plugin install bbpress --activate

Please check WP-CLI official documentation for further understanding.


Found: https://gist.github.com/squarestar/37fe1ff964adaddc0697dd03155cf0d0 as well as https://stackoverflow.com/questions/10353859/is-it-possible-to-programmatically-install-plugins-from-wordpress-theme

Turns out there are quite a number of ways to do it, just not mentioned here at the wordpress stack exchange.

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.