#!/bin/bash # Usage: # ./export-wp-plugins.sh [base_directory] [output_file] BASE_DIR="${1:-/var/www}" OUTPUT_FILE="${2:-plugins.csv}" # Check for WP-CLI if ! command -v wp &>/dev/null; then echo "WP-CLI not found. Install WP-CLI first: https://wp-cli.org/" exit 1 fi # Loop through subdirectories for dir in "$BASE_DIR"/*/; do if [ -f "$dir/wp-config.php" ]; then site=$(basename "$dir") echo "=== $site ===" | tee -a "$OUTPUT_FILE" wp --allow-root --path="$dir" plugin list --format=csv>> "$OUTPUT_FILE" echo "" >> "$OUTPUT_FILE" fi done echo "Plugins saved to $OUTPUT_FILE"