WC_CLI_COM_Extension_Command::install()
Installs one or more plugins from wccom marketplace.
OPTIONS
- <extension>...
- One or more plugins to install. Accepts a plugin slug.
- [--force]
- If set, the command will overwrite any installed version of the plugin, without prompting for confirmation.
- [--activate]
- If set, the plugin will be activated immediately after install.
- [--activate-network]
- If set, the plugin will be network activated immediately after install
- [--insecure]
- Retry downloads without certificate validation if TLS handshake fails. Note: This makes the request vulnerable to a MITM attack.
EXAMPLES
# Install the latest version from WooCommerce.com and activate $ wp wc com extension install automatewoo --activate Downloading install package from http://s3.amazonaws.com/bucketname/automatewoo.zip?AWSAccessKeyId=123&Expires=456&Signature=abcdef...... Using cached file '/home/vagrant/.wp-cli/cache/plugin/automatewoo.zip'... Unpacking the package... Installing the plugin... Plugin installed successfully. Activating 'automatewoo'... Plugin 'automatewoo' activated. Success: Installed 1 of 1 plugins.
# Forcefully re-install an installed plugin $ wp wc com extension install automatewoo --force Downloading install package from http://s3.amazonaws.com/bucketname/automatewoo.zip?AWSAccessKeyId=123&Expires=456&Signature=abcdef... Unpacking the package... Installing the plugin... Removing the old version of the plugin... Plugin updated successfully Success: Installed 1 of 1 plugins.
Method of the class: WC_CLI_COM_Extension_Command{}
No Hooks.
Return
null
. Nothing (null).
Usage
$WC_CLI_COM_Extension_Command = new WC_CLI_COM_Extension_Command(); $WC_CLI_COM_Extension_Command->install( $args, $assoc_args );
- $args(array) (required)
- WP-CLI positional arguments.
- $assoc_args(array) (required)
- WP-CLI associative arguments.
WC_CLI_COM_Extension_Command::install() WC CLI COM Extension Command::install code WC 9.4.2
public function install( $args, $assoc_args ) { $subscriptions = WC_Helper_Updater::get_available_extensions_downloads_data(); $extension = reset( $args ); $extension_package_url = null; // Remove `--version` as we don't support it. unset( $assoc_args['version'] ); // Filter by slug. foreach ( $subscriptions as $subscription ) { if ( $subscription['slug'] === $extension && ! is_null( $subscription['package'] ) ) { $extension_package_url = $subscription['package']; break; } } // No package found. if ( is_null( $extension_package_url ) ) { WP_CLI::warning( sprintf( 'We couldn\'t find a Subscription for \'%s\'', $extension ) ); WP_CLI\Utils\report_batch_operation_results( $this->item_type, 'install', count( $args ), 0, 1 ); return; } parent::install( array( $extension_package_url ), $assoc_args ); }