diff --git a/detect_plugins.sh b/detect_plugins.sh new file mode 100755 index 0000000..bd971e6 --- /dev/null +++ b/detect_plugins.sh @@ -0,0 +1,24 @@ +#!/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" \ No newline at end of file