#!/bin/bash

# Deploy the fixed HVAC Community Events plugin to the staging server

# Set variables
PLUGIN_NAME="hvac-community-events"
PLUGIN_DIR="/Users/ben/dev/upskill-event-manager/wordpress-dev/wordpress/wp-content/plugins/${PLUGIN_NAME}"
BACKUP_DIR="/Users/ben/dev/upskill-event-manager/wordpress-dev/plugin-backups"
ZIP_FILE="${BACKUP_DIR}/${PLUGIN_NAME}.zip"
TIMESTAMP=$(date +"%Y%m%d%H%M%S")

# Create backup directory if it doesn't exist
mkdir -p "${BACKUP_DIR}"

# Navigate to the plugins directory
cd "$(dirname "${PLUGIN_DIR}")"

echo "Creating plugin backup..."
# Create a ZIP archive of the current plugin
zip -r "${ZIP_FILE}.${TIMESTAMP}" "${PLUGIN_NAME}"
echo "Backup created at: ${ZIP_FILE}.${TIMESTAMP}"

echo "Packaging fixed plugin for deployment..."
# Create a ZIP archive of the plugin for deployment
zip -r "${ZIP_FILE}" "${PLUGIN_NAME}"
echo "Plugin packaged at: ${ZIP_FILE}"

echo "Plugin archive created successfully!"
echo "To deploy, upload ${ZIP_FILE} through the WordPress plugin uploader or via FTP."