The WordPress plugin repository at wordpress.org/plugins is a great resource. I often use WP CLI to install plugins on my WordPress site from there, e.g.
wp plugin install stop-emails --activate
Sometimes I’m dealing with plugins that are not on the official WordPress.org repository but I’d still like to install them with WP CLI. If they are available for download as a zip file from a URL, you can do this.
Iron Code Studio Hello World Plugin
I’ve created a plugin called Iron Code Studio Hello World Plugin (source code below). This plugin is not available on the WordPress.org repository but I’ve zipped a copy of it and make it available at http://static.ironcodestudio.com/fe-hello-world.zip
.
<?php
/**
* Plugin Name: Iron Code Hello World
* Plugin URI: http://static.ironcodestudio.com/fe-hello-world.zip
* Description: An example WordPress plugin that displays "Hello World, from Iron Code Studio"
* Author: Sal Ferrarello
* Version: 1.1
* Author URI: https://salferrarello.com
* Text Domain: fe-hello-world
*/
function fe_hello_world() {
echo '<div class="notice notice-success">
<p><strong>"Hello World", from Iron Code Studio.</strong></p>
</div>';
}
add_action( 'admin_notices', 'fe_hello_world' );
WP CLI Install Plugin from Zip File
Because the fe-hello-world
plugin is available at http://static.ironcodestudio.com/fe-hello-world.zip, you can install it with WP CLI with the following command.
wp plugin install http://static.ironcodestudio.com/fe-hello-world.zip --activate
Security Warning
Installing a plugin from a URL without first examining the plugin is a huge security vulnerability. I recommend only installing a plugin in this manner if it is coming from a site you control and the URL uses https
. Based on this, I’d recommend limiting installing my fe-hello-world plugin above only on development sites.
Further Reading
WP CLI plugin install documentation
Leave a Reply