1

Please consider that I am not a Wordpress plugin developer, but I am maintaining a lot of Wordpress websites. In case I have to perform a change to all of them, I will have to log in each site and this is consuming a lot of time.

To resolve the problem, I devlop my own PHP scripts, which get use of the functions defined in Wordpress. This way I only need to run the script to resolve the particular issue.

Lets assume that I want to install a plugin. I will use the following code:

function install_plugin($Plugin_name) {

  get_downloadurl_from_api($Plugin_name); /* A function defined by me to get the download URL of the desired plugin by using the Wordpress API. */
  download_extract_plugin($Plugin_name); /* A function defined by me to download the plugin archive and extract it in the wp-content/plugins directory */
  activate_plugin($Plugin_name); /* Activate the plugin. This function is defined in wp-admin/includes/plugin.php */ }

My code works seamlessly, but I was wondering if there is a Wordpress defined function that does the same as get_downloadurl_from_api() and download_extract_plugin()?

1 Answer 1

2

OK, so I think I got everything that is needed. So yes, you could work with a combination of:

  1. plugins_api
  2. install_plugin_install_status
  3. install from an instance of Plugin_Upgrader

This may seem elaborate but you can actually see from the WP-CLI project that it is quite straight-forward. Of course, you can just install that excellent plugin and be done with it if you can also get access to a remote terminal session.

1
  • WP CLI is definitely the way to go
    – Andy
    Commented Aug 14, 2015 at 0:41

Your Answer

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

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