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?
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It only takes a minute to sign up.Sign up to join this community
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.
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.