Created
February 10, 2026 13:28
-
-
Save sejas/7a56134bea4a1507c18089de73217354 to your computer and use it in GitHub Desktop.
Deactivate plugins one by one to see which one breaks your Wordpress site
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # This script deactivates all active plugins one by one and checks if the site starts successfully after each deactivation. | |
| set -euo pipefail | |
| echo "Fetching active plugins..." | |
| raw_output=$(studio wp plugin list --status=active --fields=name --format=json 2>/dev/null || true) | |
| # Extract the JSON array from the noisy output (find the first [...] block) | |
| json=$(echo "$raw_output" | grep -oE '\[.*\]' | head -1) | |
| if [[ -z "$json" ]]; then | |
| echo "❌ Failed to parse plugin list. Raw output:" | |
| echo "$raw_output" | |
| exit 1 | |
| fi | |
| # Parse plugin names from JSON | |
| plugins=() | |
| while IFS= read -r line; do | |
| plugins+=("$line") | |
| done < <(echo "$json" | python3 -c " | |
| import sys, json | |
| data = json.load(sys.stdin) | |
| for p in data: | |
| print(p['name']) | |
| ") | |
| if [[ ${#plugins[@]} -eq 0 ]]; then | |
| echo "❌ No active plugins found." | |
| exit 1 | |
| fi | |
| echo "Found ${#plugins[@]} active plugins:" | |
| printf " - %s\n" "${plugins[@]}" | |
| echo "" | |
| conflicting=() | |
| for plugin in "${plugins[@]}"; do | |
| echo "==========================================" | |
| echo "Testing: $plugin" | |
| echo "==========================================" | |
| echo "⏸ Deactivating $plugin..." | |
| if ! studio wp plugin deactivate "$plugin" 2>/dev/null; then | |
| echo "⚠️ Failed to deactivate $plugin, skipping." | |
| continue | |
| fi | |
| echo "🚀 Starting site..." | |
| if studio site start 2>/dev/null; then | |
| echo "" | |
| echo "🎯 Conflicting plugin found: $plugin" | |
| conflicting+=("$plugin") | |
| echo "🛑 Stopping site..." | |
| studio site stop 2>/dev/null || true | |
| else | |
| echo "❌ Site still fails without $plugin." | |
| fi | |
| echo "🔄 Reactivating $plugin..." | |
| studio wp plugin activate "$plugin" 2>/dev/null || true | |
| echo "" | |
| done | |
| echo "==========================================" | |
| echo "RESULTS" | |
| echo "==========================================" | |
| if [[ ${#conflicting[@]} -gt 0 ]]; then | |
| echo "🎯 Conflicting plugins found (${#conflicting[@]}):" | |
| for p in "${conflicting[@]}"; do | |
| echo " ❌ $p" | |
| done | |
| else | |
| echo "✅ No single conflicting plugin found." | |
| echo " The issue may involve multiple plugins interacting." | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment