#!/bin/bash

################################################################################
# WordPress Management Menu
################################################################################
# Purpose: Submenu for WordPress-specific management tools
# Features:
# - WordPress cron management
# - (Future: plugin updates, theme management, security hardening, etc.)
################################################################################

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
source "$SCRIPT_DIR/lib/common-functions.sh"

if [ "$EUID" -ne 0 ]; then
    print_error "This menu must be run as root"
    exit 1
fi

# Main menu loop
while true; do
    clear
    print_banner "WordPress Management"

    echo ""
    echo -e "${BOLD}Available WordPress Tools${NC}"
    echo ""
    echo "  1) WordPress Cron Manager"
    echo "     └─ Convert WordPress sites from wp-cron to system cron"
    echo ""
    echo "  ${DIM}2) WordPress Plugin Manager (Coming Soon)"
    echo "     └─ Bulk update, scan vulnerabilities, manage plugins${NC}"
    echo ""
    echo "  ${DIM}3) WordPress Security Hardening (Coming Soon)"
    echo "     └─ Apply security best practices, file permissions${NC}"
    echo ""
    echo "  ${DIM}4) WordPress Theme Manager (Coming Soon)"
    echo "     └─ Update themes, check compatibility${NC}"
    echo ""
    echo "  0) Return to Website Diagnostics Menu"
    echo ""
    echo -n "Select option: "
    read -r choice

    case "$choice" in
        1)
            bash "$SCRIPT_DIR/modules/website/wordpress/wordpress-cron-manager.sh"
            ;;
        2|3|4)
            echo ""
            print_warning "This feature is coming soon!"
            echo ""
            press_enter
            ;;
        0)
            exit 0
            ;;
        *)
            print_error "Invalid option"
            sleep 1
            ;;
    esac
done
