#!/bin/bash
# Fix Find a Trainer page content
# Usage: ./scripts/fix-find-trainer-page-v2.sh
source .env
echo "=== Fixing Find a Trainer Page Content ==="
# Create a PHP file with the update code
cat > /tmp/fix-page.php << 'EOF'
Find certified HVAC trainers in your area. Use the filters below to discover trainers who match your specific needs.
[hvac_trainer_directory]
Are you an HVAC Trainer that wants to be listed in our directory?
Become a Trainer
';
wp_update_post([
"ID" => $page->ID,
"post_content" => $updated_content
]);
echo "Page content updated\n";
} else {
echo "Page not found\n";
}
EOF
# Upload and execute the PHP file
scp -o StrictHostKeyChecking=no /tmp/fix-page.php "$UPSKILL_STAGING_SSH_USER@$UPSKILL_STAGING_IP:/tmp/"
ssh -o StrictHostKeyChecking=no "$UPSKILL_STAGING_SSH_USER@$UPSKILL_STAGING_IP" << 'ENDSSH'
cd /home/974670.cloudwaysapps.com/uberrxmprk/public_html
# Execute the fix
wp eval-file /tmp/fix-page.php
# Clear cache
wp cache flush
# Clean up
rm /tmp/fix-page.php
ENDSSH
echo "=== Testing Page Load ==="
HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" https://upskill-staging.measurequick.com/find-a-trainer/)
echo "Page returns HTTP $HTTP_CODE"
echo "=== Taking Screenshot ==="
npx playwright screenshot https://upskill-staging.measurequick.com/find-a-trainer/ find-trainer-fixed.png --wait-for-timeout=3000
echo "=== Fix Complete ==="