The WordPress Command Line Interface (WP-CLI) is a powerful tool for managing WordPress websites directly from the command line. With WP-CLI, you can easily perform various tasks, such as installing and updating plugins, managing users, or optimizing databases, without having to navigate through the WordPress user interface. This makes WordPress website management faster, more efficient, and more reliable.
The effective management of WordPress sites is critical to their security, performance, and functionality. With WP-CLI, you can speed up these processes and minimize the risk of errors that can occur when performing tasks manually.
This guide is designed to help you understand and use WP-CLI to manage plugins on your WordPress website. We'll cover the basic commands for installing, updating, deactivating, and removing plugins and show you how to automate these tasks to keep your site running optimally.
Installing and Activating Plugins With WP-CLI
To start managing your plugins with WP-CLI, you first need to connect to your WordPress environment via SSH. Here is a brief overview of the steps:
- Connect via SSH:
- Open Terminal or the SSH client you are using
- Use the following command to connect:
ssh username@hostname.tld -p serverPort
Replace username with your SSH username and hostname.tld with the name of the hosting server. Replace serverPort with the SSH port of the hosting server. For example, to access a shared hosting server on Hosting Jump:
ssh testuser@jump16.jump.bg -p 12545
Use the “cd” command to navigate to the root directory of your WordPress website. For example:
cd public_html
- Before you install or update plugins, you can check which plugins are installed and whether there are updates for them:
wp plugin list
The result of the command is a table with a description of the name of the plugins, their status, whether an update is available, and the current version.
- Installing a new plugin:
wp plugin install plugin-name
If we want the plugin to be activated immediately after installation, we add the activate flag:
wp plugin install -activate plugin-name
- Activating an installed but inactive plugin:
wp plugin activate plugin-name
Here’s a tutorial on how to install WordPress plugins the easy way—from the WP dashboard.
Updating Plugins With WP-CLI
Updating the plugins on WordPress website is crucial for the security and stability of your website. Outdated plugins can introduce vulnerabilities that can be used by malware or hackers to compromise your website. That's why it's important to always keep your plugins up to date.
Commands to update all installed plugins at once
With WP-CLI, you can quickly and easily update all installed plugins with a single command:
wp plugin update --all
This command automatically detects and installs the latest versions of all plugins on your website. This is the most effective way to ensure that all plugins are protected and working optimally.
Different update strategies
Depending on your needs, you can use different strategies for updating plugins:
- Update a specific plugin:
If you only want to update a specific plugin, you can use the following command:
wp plugin update plugin-name
This is useful if you want to test a new version of a plugin before applying it to all installations.
- Update to a specific version:
In some cases, it may be necessary to update a plugin to a specific version instead of the latest available version. You can do this with :
wp plugin update plugin-name --version=1.2.3
This command updates the plugin to version 1.2.3.
- Update all plugins except a specific one:
If you have certain plugins that you do not want to update, you can use the following command:
wp plugin update $(wp plugin list --update=available --field=name | grep -vE 'plugin-name1|plugin-name2')
This updates all plugins except those listed.
With these commands, you can keep your plugins up to date in a way that best suits the needs of your website and ensures maximum security and functionality.
Using WP-CLI to Manage Automatic Plugin Updates
Automatic plugin updates are a powerful tool that you can use to keep your WordPress site secure by ensuring that plugins are always running the latest versions. However, in some cases, you may prefer to control these updates manually to avoid potential conflicts or compatibility issues. WP-CLI gives you the ability to easily manage automatic plugin updates.
To activate/deactivate automatic updates for individual plugins
You can activate or deactivate the automatic updates for each plugin individually via WP-CLI. This gives you more control over how the plugins are updated on your website.
- Activate automatic updates for a plugin:
To enable automatic updates for a specific plugin, use the following command:
wp plugin auto-updates enable plugin-name
- Disable automatic updates for a plugin:
If you prefer to manage the updates manually, you can deactivate the automatic updates with the following command:
wp plugin auto-updates disable plugin-name
Check the status of automatic updates
Before you make any changes, you should check the current status of automatic updates for your plugins. WP-CLI offers an easy way to do this:
- Checking the status of all plugins:
To see which plugins have automatic updates enabled, use:
wp plugin list --format=table --fields=name,auto_update
This command displays a table with all installed plugins and their automatic update status.
- Checking the status of a specific plugin:
To check the status of automatic updates of a specific plugin:
wp plugin auto-updates status plugin-name
This shows you whether automatic updates are activated or deactivated for the respective plugin.
Manage automatic updates for multiple plugins
If you want to enable or disable automatic updates for all plugins at once, you can use the following commands:
- Enable automatic updates for all plugins:
wp plugin auto-updates enable --all
- Disable automatic updates for all plugins:
wp plugin auto-updates disable --all
By effectively managing automatic updates with WP-CLI, you can ensure greater security and stability of your WordPress website while maintaining control over important updates.
Deactivating and Removing Plugins
Sometimes you need to deactivate or remove plugins. WP-CLI makes this process easy.
- Deactivate plugin:
wp plugin deactivate plugin-name
Please note that deactivating a plugin does not delete it. We recommend that you delete plugins that are inactive and that you no longer need.
- Remove plugin:
wp plugin delete plugin-name
- Deactivate and remove plugins in bulk:
To deactivate or remove multiple plugins at once, you can list them separated by spaces.
wp plugin deactivate plugin-name1 plugin-name2
wp plugin delete plugin-name1 plugin-name2
Managing Plugin Checksums for Security
Checksums are unique codes that are generated from the content of plugin files. They act as digital fingerprints that can be used to check the integrity of plugins on your WordPress site. When you install or update a plugin, its files must match the original files published by the developer. If the checksums do not match, this can be a sign that the plugin files have been altered or compromised, posing a serious security risk to your website.
Checksum verification is an important aspect of keeping your WordPress website secure. Here is an example of how you can use this command during daily maintenance:
- Regular check of the plugins:
We recommend that you regularly check the checksums of all installed plugins to ensure that none of them have been compromised.
wp plugin verify-checksums --all
This command checks the checksums of all installed plugins.
- Check after update:
After updating a plugin, you can use the Checksums command to ensure that the update was carried out successfully and without errors.
wp plugin verify-checksums plugin-name
If WP-CLI detects discrepancies in the checksum, you should investigate the problem immediately. This may include looking for malicious code, reinstalling the plugin, or even restoring the files from a backup.
Commands for Scripting and Automation
WP-CLI commands are very flexible and can be integrated into scripts to automate repetitive WordPress management tasks. This allows you to save time and ensure consistency when managing your WordPress site.
Get information about plugins
- Retrieving the plugin path:
wp plugin path plugin-name
- Get plugin details:
wp plugin get plugin-name --fields=name,version,status
This command retrieves specific plugin details such as name, version, and status.
Automate plugin management tasks
Automating plugin management with Bash scripts can speed up your WordPress maintenance tasks.
Example: Updating all plugins and checking the checksums
#!/bin/bash
# Update all plugins
wp plugin update --all
# Get a list of all installed plugins
PLUGINS=$(wp plugin list --field=name)
# Checking the checksums for all plugins
for PLUGIN in $PLUGINS; do
wp plugin verify-checksums $PLUGIN
if [ $? -ne 0 ]; then
echo "Checksums for plugin failed: $PLUGIN"
else
echo "checksums verification is successful for plugin: $PLUGIN"
fi
done
This script updates all plugins and checks their integrity. It outputs a message indicating whether the check was successful for each plugin.
Need Assistance With WordPress Plugin Updates? We Can Help!
Updating and managing WordPress plugins can be a challenge, especially if you don't have the technical know-how or the time. That's where our dedicated WordPress support service from Hosting Jump comes to the rescue. Our team of experts can take care of everything related to your plugins, from installation and updates to diagnostics and troubleshooting.
Whether it's security, performance optimization, or configuring complex settings, we're here for you. With our WordPress support, you can confidently focus on growing your business while we take care of the technical aspects of your website.
Ready to simplify the management of your WordPress website? Check out our WordPress Support service and find out how we can help you keep your website in tip-top shape.
Conclusion
Managing WordPress plugins with WP-CLI offers numerous advantages. By using WP-CLI, you can significantly speed up and simplify your website maintenance while reducing the risk of human error. Not only does WP-CLI allow for quick installation, updating, and management of plugins, but it also offers the ability to automate these tasks, which is especially useful when maintaining large or complex websites.
We encourage you to continue exploring the possibilities of WP-CLI to manage your WordPress plugins more efficiently and securely. The better you get at WP-CLI, the easier it will be to keep your website up to date and secure, giving you more time to focus on growing your content and your business.
Want to know what else you can do with WordPress CLI? Check out these other WP-CLI commands.