#!/bin/bash

echo "=== Debugging Template Loading ==="

ssh roodev@146.190.76.204 << 'ENDSSH'
cd /home/974670.cloudwaysapps.com/uberrxmprk/public_html

# Check registration page details
echo "Registration page details:"
wp post get 5334 --fields=ID,post_title,post_name,post_status,_wp_page_template

# Check if the template file exists in plugin
echo -e "\nTemplate file in plugin:"
ls -la wp-content/plugins/hvac-community-events/templates/page-trainer-registration.php

# Check if template is in theme
echo -e "\nChecking theme directories:"
ls -la wp-content/themes/astra/ | grep -i template
ls -la wp-content/themes/astra/page-*.php 2>/dev/null || echo "No page templates in theme root"

# Check active plugins
echo -e "\nChecking if HVAC plugin is active:"
wp plugin list --status=active | grep hvac

# Check if template include filter is working
echo -e "\nChecking hooks:"
wp eval 'global $wp_filter; if(isset($wp_filter["template_include"])) { echo "template_include filter exists with " . count($wp_filter["template_include"]) . " callbacks\n"; } else { echo "No template_include filter!\n"; }'

ENDSSH