Plugin Activation, Deactivation & Status
Overview
Controlling plugin states is essential for WordPress management. WP-CLI makes it instant to activate, deactivate, and check plugin status—critical for troubleshooting, testing, and managing multiple sites.
Understanding Plugin States
WordPress plugins can be in different states:
- Active: Plugin is running and affecting the site
- Inactive: Plugin is installed but not running
- Must-Use: Plugin automatically active (in
wp-content/mu-plugins/) - Dropin: Special plugin replacing WordPress core functionality
WP-CLI lets you control these states instantly without touching wp-admin.
Activating Plugins
Activate Single Plugin
# Activate a plugin
wp plugin activate woocommerce
Output:
Success: Plugin 'woocommerce' activated.
Activate Multiple Plugins
# Activate several plugins at once
wp plugin activate elementor wordfence updraftplus
# Output shows success for each
Activate All Plugins
# Activate all installed plugins
wp plugin activate --all
Use With Caution
Activating all plugins can cause conflicts. Use this primarily when:
- Re-enabling plugins after troubleshooting
- Setting up a cloned/migrated site
- You know all plugins are compatible
Network Activation (Multisite)
# Activate plugin network-wide
wp plugin activate akismet --network
# Activate on specific subsite
wp plugin activate woocommerce --url=shop.example.com
Deactivating Plugins
Deactivate Single Plugin
# Deactivate a plugin
wp plugin deactivate yoast-seo
Deactivate Multiple Plugins
# Deactivate several plugins
wp plugin deactivate elementor contact-form-7
Deactivate All Plugins
# Deactivate all plugins (emergency troubleshooting)
wp plugin deactivate --all
Use cases:
- White screen of death - disable all plugins to identify culprit
- Plugin conflict - isolate which plugin is causing issues
- Site migration - prepare for export/import
Network Deactivation (Multisite)
# Deactivate network-wide
wp plugin deactivate akismet --network
# Deactivate on specific subsite
wp plugin deactivate woocommerce --url=shop.example.com
Checking Plugin Status
Get Plugin Status
# Check status of specific plugin
wp plugin status woocommerce
Example output:
Plugin woocommerce details:
Name: WooCommerce
Status: Active
Version: 8.3.0
Author: Automattic
Description: An eCommerce toolkit...
List Plugins by Status
# List all plugins
wp plugin list
# List only active plugins
wp plugin list --status=active
# List only inactive plugins
wp plugin list --status=inactive
# List must-use plugins
wp plugin list --status=must-use
# List dropins
wp plugin list --status=dropin
Example output:
+-------------------+----------+--------+---------+
| name | status | update | version |
+-------------------+----------+--------+---------+
| akismet | active | none | 5.3 |
| contact-form-7 | inactive | none | 5.8 |
| woocommerce | active | 8.3.0 | 8.2.0 |
+-------------------+----------+--------+---------+
Check if Plugin is Installed
# Check if plugin exists
wp plugin is-installed woocommerce && echo "Installed" || echo "Not installed"
# Use in scripts
if wp plugin is-installed woocommerce; then
echo "WooCommerce is installed"
else
echo "WooCommerce not found"
fi
Get Active Plugin List
# Get names of all active plugins
wp plugin list --status=active --field=name
# Count active plugins
wp plugin list --status=active --field=name | wc -l
Real-World Scenarios
Scenario 1: Emergency Site Recovery (White Screen of Death)
Problem: Site shows white screen, wp-admin inaccessible.
Solution:
# SSH into server
cd /var/www/html
# Deactivate all plugins
wp plugin deactivate --all
# Site should now be accessible
# Check which plugin caused the issue by activating one by one
# Activate plugins individually
wp plugin activate akismet
# Test site...
wp plugin activate contact-form-7
# Test site...
# When site breaks, you've found the culprit
Scenario 2: Plugin Conflict Diagnosis
#!/bin/bash
# diagnose-plugin-conflict.sh
echo "Deactivating all plugins..."
wp plugin deactivate --all
echo "Testing each plugin individually..."
for plugin in $(wp plugin list --status=inactive --field=name); do
echo "Testing: $plugin"
wp plugin activate $plugin
# Test if site is working (customize this check)
if curl -s -o /dev/null -w "%{http_code}" http://localhost | grep -q "200"; then
echo "✓ $plugin OK"
else
echo "✗ $plugin FAILED - This is the problematic plugin!"
wp plugin deactivate $plugin
exit 1
fi
done
echo "All plugins tested successfully!"
Scenario 3: Bulk Plugin Management Across Sites
#!/bin/bash
# activate-security-plugins.sh
# Activate security plugins on all sites
sites=(
"/var/www/site1"
"/var/www/site2"
"/var/www/site3"
)
for site in "${sites[@]}"; do
echo "Activating security plugins for $site"
wp plugin activate wordfence --path=$site
wp plugin activate updraftplus --path=$site
echo "---"
done
Scenario 4: Conditional Plugin Activation
#!/bin/bash
# conditional-plugin-activation.sh
# Activate WooCommerce only if not already active
if ! wp plugin is-active woocommerce; then
echo "WooCommerce is inactive. Activating..."
wp plugin activate woocommerce
else
echo "WooCommerce is already active."
fi
# Activate plugin and check for errors
if wp plugin activate problematic-plugin 2>&1 | grep -q "Error"; then
echo "Activation failed! Rolling back..."
wp plugin deactivate problematic-plugin
else
echo "Plugin activated successfully!"
fi
Scenario 5: Multisite Plugin Management
# Enable plugin for network
wp plugin activate wordfence --network
# Activate on specific subsites only
for url in site1.example.com site2.example.com; do
wp plugin activate woocommerce --url=$url
done
# Deactivate on all subsites but keep network-enabled
wp site list --field=url | xargs -I {} wp plugin deactivate akismet --url={}
Advanced Plugin Status Checks
Get Detailed Plugin Information
# Get all details about a plugin
wp plugin get woocommerce
# Get specific field
wp plugin get woocommerce --field=version
wp plugin get woocommerce --field=status
wp plugin get woocommerce --field=author
# Get plugin path
wp plugin path woocommerce
Check Plugin Dependencies
# List plugins with their required PHP version
wp plugin list --fields=name,version,requires_php
# Check if plugin requires specific WordPress version
wp plugin get elementor --field=requires
Export Plugin List
# Export active plugins to file
wp plugin list --status=active --format=json > active-plugins.json
# Export as CSV
wp plugin list --status=active --format=csv > active-plugins.csv
# Export plugin names only
wp plugin list --status=active --field=name > active-plugins.txt
Automation & Scripts
Auto-Activate After Installation
# Install and activate in one command
wp plugin install contact-form-7 --activate
# Bulk install and activate
wp plugin install elementor wordfence updraftplus --activate
Scheduled Plugin Checks
#!/bin/bash
# check-plugin-status.sh
# Log inactive plugins
echo "=== Inactive Plugins Report ===" > plugin-report.txt
echo "Date: $(date)" >> plugin-report.txt
wp plugin list --status=inactive --format=table >> plugin-report.txt
# Email report
mail -s "Weekly Plugin Status" admin@example.com < plugin-report.txt
Toggle Plugins for Maintenance Mode
#!/bin/bash
# maintenance-mode.sh
if [ "$1" == "on" ]; then
echo "Enabling maintenance mode..."
wp plugin deactivate --all
wp plugin activate maintenance-mode-plugin
elif [ "$1" == "off" ]; then
echo "Disabling maintenance mode..."
wp plugin deactivate maintenance-mode-plugin
wp plugin activate --all
fi
Best Practices
1. Always Test Plugin Activation on Staging
# On staging
wp plugin activate new-plugin
# Test thoroughly...
# On production (after successful test)
wp plugin activate new-plugin
2. Document Plugin States
# Before making changes, document current state
wp plugin list --status=active --field=name > plugins-before.txt
# Make changes...
# Compare after
wp plugin list --status=active --field=name > plugins-after.txt
diff plugins-before.txt plugins-after.txt
3. Use Activation Hooks Carefully
# Some plugins run activation hooks that modify database
# Always backup before activating unknown plugins
wp db export backup-before-activation.sql
wp plugin activate unknown-plugin
4. Regular Plugin Audits
# Weekly audit: Check for inactive plugins
wp plugin list --status=inactive
# Security best practice: Delete unused plugins
wp plugin delete unused-plugin-1 unused-plugin-2
5. Monitor Plugin Conflicts
# After activating new plugin, check for PHP errors
wp plugin activate new-plugin
tail -f wp-content/debug.log
Troubleshooting
Plugin Won't Activate
# Check for activation errors
wp plugin activate problematic-plugin 2>&1 | tee activation-error.log
# Enable debug mode
wp config set WP_DEBUG true --raw
wp config set WP_DEBUG_LOG true --raw
# Try activating again
wp plugin activate problematic-plugin
# Check debug log
tail -f wp-content/debug.log
Plugin Won't Deactivate
# Force deactivate by removing from active plugins option
wp option get active_plugins
# Manually remove plugin from active list (advanced)
# Better: Check for fatal errors preventing deactivation
wp plugin deactivate problematic-plugin 2>&1
Activation Breaks Site
# Immediately deactivate
wp plugin deactivate problematic-plugin
# If site completely broken
wp plugin deactivate --all
# Restore from backup if needed
wp db import backup-before-activation.sql
Quick Reference
Essential Commands
# Activate plugins
wp plugin activate <plugin> # Activate one
wp plugin activate plugin1 plugin2 # Activate multiple
wp plugin activate --all # Activate all
wp plugin activate <plugin> --network # Network activate (multisite)
# Deactivate plugins
wp plugin deactivate <plugin> # Deactivate one
wp plugin deactivate plugin1 plugin2 # Deactivate multiple
wp plugin deactivate --all # Deactivate all (emergency)
wp plugin deactivate <plugin> --network # Network deactivate
# Check status
wp plugin status <plugin> # Get plugin details
wp plugin list # List all plugins
wp plugin list --status=active # List active only
wp plugin list --status=inactive # List inactive only
wp plugin is-installed <plugin> # Check if installed
wp plugin get <plugin> --field=status # Get status field
# Advanced
wp plugin path <plugin> # Get plugin directory path
wp plugin list --format=json # Export as JSON
wp plugin list --fields=name,status,version # Custom fields
Common Workflows
# Emergency troubleshooting
wp plugin deactivate --all
# Site should work now - activate plugins one by one
# Safe plugin activation
wp db export backup.sql
wp plugin activate new-plugin
# Test site...
# Bulk activation
wp plugin activate plugin1 plugin2 plugin3
# Check before activating
wp plugin is-installed woocommerce && wp plugin activate woocommerce
Comparison: WP-CLI vs wp-admin
| Task | WP-CLI | wp-admin |
|---|---|---|
| Activate 10 Plugins | ~2 seconds | 1-2 minutes |
| Deactivate All | Instant | 1-2 minutes |
| Works When Site Broken | ✅ Yes | ❌ No |
| Bulk Operations | ✅ Native | ⚠️ One-by-one |
| Automation | ✅ Scriptable | ❌ Manual |
| Visual Feedback | ❌ Text only | ✅ Visual interface |
| Plugin Description | ⚠️ Limited | ✅ Full details |
Key Takeaway
WP-CLI is essential for troubleshooting (especially when wp-admin is broken) and bulk operations. Use wp-admin when you need to browse plugin details and read descriptions before activating.
Next Steps
- Install and update plugins: Installation & Updates
- Handle special cases: Advanced Plugin Management
- Manage themes: Theme Management